aboutsummaryrefslogtreecommitdiffstats
path: root/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-12 17:57:41 -0700
committerfriendica <info@friendica.com>2012-07-18 20:40:31 +1000
commit7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch)
treea9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS
parentcd727cb26b78a1dade09d510b071446898477356 (diff)
downloadvolse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS')
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php28
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php68
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php23
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php21
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php41
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php81
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php29
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php52
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontTest.php34
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ImportantDecoratorTest.php49
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php48
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php35
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php28
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php51
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php24
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php27
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/URITest.php29
17 files changed, 668 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php
new file mode 100644
index 000000000..56efa306f
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/AlphaValueTest.php
@@ -0,0 +1,28 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_AlphaValueTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_AlphaValue();
+
+ $this->assertDef('0');
+ $this->assertDef('1');
+ $this->assertDef('.2');
+
+ // clamping to [0.0, 1,0]
+ $this->assertDef('1.2', '1');
+ $this->assertDef('-3', '0');
+
+ $this->assertDef('0.0', '0');
+ $this->assertDef('1.0', '1');
+ $this->assertDef('000', '0');
+
+ $this->assertDef('asdf', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php
new file mode 100644
index 000000000..a216b2677
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundPositionTest.php
@@ -0,0 +1,68 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_BackgroundPositionTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
+
+ // explicitly cited in spec
+ $this->assertDef('0% 0%');
+ $this->assertDef('100% 100%');
+ $this->assertDef('14% 84%');
+ $this->assertDef('2cm 1cm');
+ $this->assertDef('top');
+ $this->assertDef('left');
+ $this->assertDef('center');
+ $this->assertDef('right');
+ $this->assertDef('bottom');
+ $this->assertDef('left top');
+ $this->assertDef('center top');
+ $this->assertDef('right top');
+ $this->assertDef('left center');
+ $this->assertDef('right center');
+ $this->assertDef('left bottom');
+ $this->assertDef('center bottom');
+ $this->assertDef('right bottom');
+
+ // reordered due to internal impl details
+ $this->assertDef('top left', 'left top');
+ $this->assertDef('top center', 'top');
+ $this->assertDef('top right', 'right top');
+ $this->assertDef('center left', 'left');
+ $this->assertDef('center center', 'center');
+ $this->assertDef('center right', 'right');
+ $this->assertDef('bottom left', 'left bottom');
+ $this->assertDef('bottom center', 'bottom');
+ $this->assertDef('bottom right', 'right bottom');
+
+ // more cases from the defined syntax
+ $this->assertDef('1.32in 4ex');
+ $this->assertDef('-14% -84.65%');
+ $this->assertDef('-1in -4ex');
+ $this->assertDef('-1pc 2.3%');
+
+ // keyword mixing
+ $this->assertDef('3em top');
+ $this->assertDef('left 50%');
+
+ // fixable keyword mixing
+ $this->assertDef('top 3em', '3em top');
+ $this->assertDef('50% left', 'left 50%');
+
+ // whitespace collapsing
+ $this->assertDef('3em top', '3em top');
+ $this->assertDef("left\n \t foo ", 'left');
+
+ // invalid uses (we're going to be strict on these)
+ $this->assertDef('foo bar', false);
+ $this->assertDef('left left', 'left');
+ $this->assertDef('left right top bottom center left', 'left bottom');
+ $this->assertDef('0fr 9%', '9%');
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php
new file mode 100644
index 000000000..83461c365
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BackgroundTest.php
@@ -0,0 +1,23 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_BackgroundTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $config = HTMLPurifier_Config::createDefault();
+ $this->def = new HTMLPurifier_AttrDef_CSS_Background($config);
+
+ $valid = '#333 url("chess.png") repeat fixed 50% top';
+ $this->assertDef($valid);
+ $this->assertDef('url(\'chess.png\') #333 50% top repeat fixed', $valid);
+ $this->assertDef(
+ 'rgb(34, 56, 33) url(chess.png) repeat fixed top',
+ 'rgb(34,56,33) url("chess.png") repeat fixed top'
+ );
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php
new file mode 100644
index 000000000..6cd77fd7a
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/BorderTest.php
@@ -0,0 +1,21 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_BorderTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $config = HTMLPurifier_Config::createDefault();
+ $this->def = new HTMLPurifier_AttrDef_CSS_Border($config);
+
+ $this->assertDef('thick solid red', 'thick solid #FF0000');
+ $this->assertDef('thick solid');
+ $this->assertDef('solid red', 'solid #FF0000');
+ $this->assertDef('1px solid #000');
+ $this->assertDef('1px solid rgb(0, 0, 0)', '1px solid rgb(0,0,0)');
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php
new file mode 100644
index 000000000..f3a74e897
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ColorTest.php
@@ -0,0 +1,41 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_ColorTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Color();
+
+ $this->assertDef('#F00');
+ $this->assertDef('#fff');
+ $this->assertDef('#eeeeee');
+ $this->assertDef('#808080');
+ $this->assertDef('rgb(255, 0, 0)', 'rgb(255,0,0)'); // rm spaces
+ $this->assertDef('rgb(100%,0%,0%)');
+ $this->assertDef('rgb(50.5%,23.2%,43.9%)'); // decimals okay
+
+ $this->assertDef('#G00', false);
+ $this->assertDef('cmyk(40, 23, 43, 23)', false);
+ $this->assertDef('rgb(0%, 23, 68%)', false);
+
+ // clip numbers outside sRGB gamut
+ $this->assertDef('rgb(200%, -10%, 0%)', 'rgb(100%,0%,0%)');
+ $this->assertDef('rgb(256,-23,34)', 'rgb(255,0,34)');
+
+ // color keywords, of course
+ $this->assertDef('red', '#FF0000');
+
+ // malformed hex declaration
+ $this->assertDef('808080', '#808080');
+ $this->assertDef('000000', '#000000');
+ $this->assertDef('fed', '#fed');
+
+ // maybe hex transformations would be another nice feature
+ // at the very least transform rgb percent to rgb integer
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php
new file mode 100644
index 000000000..44bef5551
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php
@@ -0,0 +1,81 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_Composite_Testable extends
+ HTMLPurifier_AttrDef_CSS_Composite
+{
+
+ // we need to pass by ref to get the mocks in
+ function HTMLPurifier_AttrDef_CSS_Composite_Testable(&$defs) {
+ $this->defs =& $defs;
+ }
+
+}
+
+class HTMLPurifier_AttrDef_CSS_CompositeTest extends HTMLPurifier_AttrDefHarness
+{
+
+ protected $def1, $def2;
+
+ function test() {
+
+ generate_mock_once('HTMLPurifier_AttrDef');
+
+ $config = HTMLPurifier_Config::createDefault();
+ $context = new HTMLPurifier_Context();
+
+ // first test: value properly validates on first definition
+ // so second def is never called
+
+ $def1 = new HTMLPurifier_AttrDefMock();
+ $def2 = new HTMLPurifier_AttrDefMock();
+ $defs = array(&$def1, &$def2);
+ $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
+ $input = 'FOOBAR';
+ $output = 'foobar';
+ $def1_params = array($input, $config, $context);
+ $def1->expectOnce('validate', $def1_params);
+ $def1->setReturnValue('validate', $output, $def1_params);
+ $def2->expectNever('validate');
+
+ $result = $def->validate($input, $config, $context);
+ $this->assertIdentical($output, $result);
+
+ // second test, first def fails, second def works
+
+ $def1 = new HTMLPurifier_AttrDefMock();
+ $def2 = new HTMLPurifier_AttrDefMock();
+ $defs = array(&$def1, &$def2);
+ $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
+ $input = 'BOOMA';
+ $output = 'booma';
+ $def_params = array($input, $config, $context);
+ $def1->expectOnce('validate', $def_params);
+ $def1->setReturnValue('validate', false, $def_params);
+ $def2->expectOnce('validate', $def_params);
+ $def2->setReturnValue('validate', $output, $def_params);
+
+ $result = $def->validate($input, $config, $context);
+ $this->assertIdentical($output, $result);
+
+ // third test, all fail, so composite faiils
+
+ $def1 = new HTMLPurifier_AttrDefMock();
+ $def2 = new HTMLPurifier_AttrDefMock();
+ $defs = array(&$def1, &$def2);
+ $def = new HTMLPurifier_AttrDef_CSS_Composite_Testable($defs);
+ $input = 'BOOMA';
+ $output = false;
+ $def_params = array($input, $config, $context);
+ $def1->expectOnce('validate', $def_params);
+ $def1->setReturnValue('validate', false, $def_params);
+ $def2->expectOnce('validate', $def_params);
+ $def2->setReturnValue('validate', false, $def_params);
+
+ $result = $def->validate($input, $config, $context);
+ $this->assertIdentical($output, $result);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php
new file mode 100644
index 000000000..7795643f1
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FilterTest.php
@@ -0,0 +1,29 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_FilterTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Filter();
+
+ $this->assertDef('none');
+
+ $this->assertDef('alpha(opacity=0)');
+ $this->assertDef('alpha(opacity=100)');
+ $this->assertDef('alpha(opacity=50)');
+ $this->assertDef('alpha(opacity=342)', 'alpha(opacity=100)');
+ $this->assertDef('alpha(opacity=-23)', 'alpha(opacity=0)');
+
+ $this->assertDef('alpha ( opacity = 0 )', 'alpha(opacity=0)');
+ $this->assertDef('alpha(opacity=0,opacity=100)', 'alpha(opacity=0)');
+
+ $this->assertDef('progid:DXImageTransform.Microsoft.Alpha(opacity=20)');
+
+ $this->assertDef('progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php
new file mode 100644
index 000000000..fda8e01ff
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontFamilyTest.php
@@ -0,0 +1,52 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_FontFamily();
+
+ $this->assertDef('Gill, Helvetica, sans-serif');
+ $this->assertDef("'Times New Roman', serif");
+ $this->assertDef("\"Times New Roman\"", "'Times New Roman'");
+ $this->assertDef('01234');
+ $this->assertDef(',', false);
+ $this->assertDef('Times New Roman, serif', "'Times New Roman', serif");
+ $this->assertDef($d = "'\xE5\xAE\x8B\xE4\xBD\x93'");
+ $this->assertDef("\xE5\xAE\x8B\xE4\xBD\x93", $d);
+ $this->assertDef("'\\01'", "''");
+ $this->assertDef("'\\20'", "' '");
+ $this->assertDef("\\0020", "' '");
+ $this->assertDef("'\\000045'", "E");
+ $this->assertDef("','", false);
+ $this->assertDef("',' foobar','", "' foobar'");
+ $this->assertDef("'\\000045a'", "Ea");
+ $this->assertDef("'\\00045 a'", "Ea");
+ $this->assertDef("'\\00045 a'", "'E a'");
+ $this->assertDef("'\\\nf'", "f");
+ // No longer supported, except maybe in NoJS mode (see source
+ // file for more explanation)
+ //$this->assertDef($d = '"John\'s Font"');
+ //$this->assertDef("John's Font", $d);
+ //$this->assertDef("'\\','f'", "\"\\5C \", f");
+ //$this->assertDef("'\\27'", "\"'\"");
+ //$this->assertDef('"\\22"', "\"\\22 \"");
+ //$this->assertDef('"\\""', "\"\\22 \"");
+ //$this->assertDef('"\'"', "\"'\"");
+ }
+
+ function testAllowed() {
+ $this->config->set('CSS.AllowedFonts', array('serif', 'Times New Roman'));
+
+ $this->assertDef('serif');
+ $this->assertDef('sans-serif', false);
+ $this->assertDef('serif, sans-serif', 'serif');
+ $this->assertDef('Times New Roman', "'Times New Roman'");
+ $this->assertDef("'Times New Roman'");
+ $this->assertDef('foo', false);
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontTest.php
new file mode 100644
index 000000000..91870d13e
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/FontTest.php
@@ -0,0 +1,34 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_FontTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $config = HTMLPurifier_Config::createDefault();
+ $this->def = new HTMLPurifier_AttrDef_CSS_Font($config);
+
+ // hodgepodge of usage cases from W3C spec, but " -> '
+ $this->assertDef('12px/14px sans-serif');
+ $this->assertDef('80% sans-serif');
+ $this->assertDef("x-large/110% 'New Century Schoolbook', serif");
+ $this->assertDef('bold italic large Palatino, serif');
+ $this->assertDef('normal small-caps 120%/120% fantasy');
+ $this->assertDef("300 italic 1.3em/1.7em 'FB Armada', sans-serif");
+ $this->assertDef('600 9px Charcoal');
+ $this->assertDef('600 9px/ 12px Charcoal', '600 9px/12px Charcoal');
+
+ // spacing
+ $this->assertDef('12px / 14px sans-serif', '12px/14px sans-serif');
+
+ // system fonts
+ $this->assertDef('menu');
+
+ $this->assertDef('800', false);
+ $this->assertDef('600 9px//12px Charcoal', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ImportantDecoratorTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ImportantDecoratorTest.php
new file mode 100644
index 000000000..c7fa8a0fa
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ImportantDecoratorTest.php
@@ -0,0 +1,49 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_ImportantDecoratorTest extends HTMLPurifier_AttrDefHarness
+{
+
+ /** Mock AttrDef decorator is wrapping */
+ protected $mock;
+
+ function setUp() {
+ generate_mock_once('HTMLPurifier_AttrDef');
+ $this->mock = new HTMLPurifier_AttrDefMock();
+ $this->def = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($this->mock, true);
+ }
+
+ protected function setMock($input, $output = null) {
+ if ($output === null) $output = $input;
+ $this->mock->expectOnce('validate', array($input, $this->config, $this->context));
+ $this->mock->setReturnValue('validate', $output);
+ }
+
+ function testImportant() {
+ $this->setMock('23');
+ $this->assertDef('23 !important');
+ }
+
+ function testImportantInternalDefChanged() {
+ $this->setMock('23', '24');
+ $this->assertDef('23 !important', '24 !important');
+ }
+
+ function testImportantWithSpace() {
+ $this->setMock('23');
+ $this->assertDef('23 ! important ', '23 !important');
+ }
+
+ function testFakeImportant() {
+ $this->setMock('! foo important');
+ $this->assertDef('! foo important');
+ }
+
+ function testStrip() {
+ $this->def = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($this->mock, false);
+ $this->setMock('23');
+ $this->assertDef('23 ! important ', '23');
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php
new file mode 100644
index 000000000..9d9fc41f2
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/LengthTest.php
@@ -0,0 +1,48 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_LengthTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Length();
+
+ $this->assertDef('0');
+ $this->assertDef('0px');
+ $this->assertDef('4.5px');
+ $this->assertDef('-4.5px');
+ $this->assertDef('3ex');
+ $this->assertDef('3em');
+ $this->assertDef('3in');
+ $this->assertDef('3cm');
+ $this->assertDef('3mm');
+ $this->assertDef('3pt');
+ $this->assertDef('3pc');
+
+ $this->assertDef('3PX', '3px');
+
+ $this->assertDef('3', false);
+ $this->assertDef('3miles', false);
+
+ }
+
+ function testNonNegative() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Length('0');
+
+ $this->assertDef('3cm');
+ $this->assertDef('-3mm', false);
+
+ }
+
+ function testBounding() {
+ $this->def = new HTMLPurifier_AttrDef_CSS_Length('-1in', '1in');
+ $this->assertDef('1cm');
+ $this->assertDef('-1cm');
+ $this->assertDef('0');
+ $this->assertDef('1em', false);
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php
new file mode 100644
index 000000000..070066705
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/ListStyleTest.php
@@ -0,0 +1,35 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_ListStyleTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $config = HTMLPurifier_Config::createDefault();
+ $this->def = new HTMLPurifier_AttrDef_CSS_ListStyle($config);
+
+ $this->assertDef('lower-alpha');
+ $this->assertDef('upper-roman inside');
+ $this->assertDef('circle outside');
+ $this->assertDef('inside');
+ $this->assertDef('none');
+ $this->assertDef('url("foo.gif")');
+ $this->assertDef('circle url("foo.gif") inside');
+
+ // invalid values
+ $this->assertDef('outside inside', 'outside');
+
+ // ordering
+ $this->assertDef('url(foo.gif) none', 'none url("foo.gif")');
+ $this->assertDef('circle lower-alpha', 'circle');
+ // the spec is ambiguous about what happens in these
+ // cases, so we're going off the W3C CSS validator
+ $this->assertDef('disc none', 'disc');
+ $this->assertDef('none disc', 'none');
+
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php
new file mode 100644
index 000000000..4461cb508
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/MultipleTest.php
@@ -0,0 +1,28 @@
+<?php
+
+// borrowed for the sakes of this test
+class HTMLPurifier_AttrDef_CSS_MultipleTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+ $this->def = new HTMLPurifier_AttrDef_CSS_Multiple(
+ new HTMLPurifier_AttrDef_Integer()
+ );
+
+ $this->assertDef('1 2 3 4');
+ $this->assertDef('6');
+ $this->assertDef('4 5');
+ $this->assertDef(' 2 54 2 3', '2 54 2 3');
+ $this->assertDef("6\r3", '6 3');
+
+ $this->assertDef('asdf', false);
+ $this->assertDef('a s d f', false);
+ $this->assertDef('1 2 3 4 5', '1 2 3 4');
+ $this->assertDef('1 2 invalid 3', '1 2 3');
+
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php
new file mode 100644
index 000000000..94e6ea8cf
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/NumberTest.php
@@ -0,0 +1,51 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_NumberTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Number();
+
+ $this->assertDef('0');
+ $this->assertDef('0.0', '0');
+ $this->assertDef('1.0', '1');
+ $this->assertDef('34');
+ $this->assertDef('4.5');
+ $this->assertDef('.5');
+ $this->assertDef('0.5', '.5');
+ $this->assertDef('-56.9');
+
+ $this->assertDef('0.', '0');
+ $this->assertDef('.0', '0');
+ $this->assertDef('0.0', '0');
+
+ $this->assertDef('1.', '1');
+ $this->assertDef('.1', '.1');
+
+ $this->assertDef('1.0', '1');
+ $this->assertDef('0.1', '.1');
+
+ $this->assertDef('000', '0');
+ $this->assertDef(' 9', '9');
+ $this->assertDef('+5.0000', '5');
+ $this->assertDef('02.20', '2.2');
+ $this->assertDef('2.', '2');
+
+ $this->assertDef('.', false);
+ $this->assertDef('asdf', false);
+ $this->assertDef('0.5.6', false);
+
+ }
+
+ function testNonNegative() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Number(true);
+ $this->assertDef('23');
+ $this->assertDef('-12', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php
new file mode 100644
index 000000000..f712af1d2
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/PercentageTest.php
@@ -0,0 +1,24 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_PercentageTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_Percentage();
+
+ $this->assertDef('10%');
+ $this->assertDef('1.607%');
+ $this->assertDef('-567%');
+
+ $this->assertDef(' 100% ', '100%');
+
+ $this->assertDef('5', false);
+ $this->assertDef('asdf', false);
+ $this->assertDef('%', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php
new file mode 100644
index 000000000..dd714d206
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php
@@ -0,0 +1,27 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_TextDecorationTest extends HTMLPurifier_AttrDefHarness
+{
+
+ function testCaseInsensitive() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_TextDecoration();
+
+ $this->assertDef('none');
+ $this->assertDef('none underline', 'underline');
+
+ $this->assertDef('underline');
+ $this->assertDef('overline');
+ $this->assertDef('line-through overline underline');
+ $this->assertDef('overline line-through');
+ $this->assertDef('UNDERLINE', 'underline');
+ $this->assertDef(' underline line-through ', 'underline line-through');
+
+ $this->assertDef('foobar underline', 'underline');
+ $this->assertDef('blink', false);
+
+ }
+
+}
+
+// vim: et sw=4 sts=4
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/URITest.php b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/URITest.php
new file mode 100644
index 000000000..3d6f5791e
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/URITest.php
@@ -0,0 +1,29 @@
+<?php
+
+class HTMLPurifier_AttrDef_CSS_URITest extends HTMLPurifier_AttrDefHarness
+{
+
+ function test() {
+
+ $this->def = new HTMLPurifier_AttrDef_CSS_URI();
+
+ $this->assertDef('', false);
+
+ // we could be nice but we won't be
+ $this->assertDef('http://www.example.com/', false);
+
+ $this->assertDef('url(', false);
+ $this->assertDef('url("")', true);
+ $result = 'url("http://www.example.com/")';
+ $this->assertDef('url(http://www.example.com/)', $result);
+ $this->assertDef('url("http://www.example.com/")', $result);
+ $this->assertDef("url('http://www.example.com/')", $result);
+ $this->assertDef(
+ ' url( "http://www.example.com/" ) ', $result);
+ $this->assertDef("url(http://www.example.com/foo,bar\)\'\()",
+ 'url("http://www.example.com/foo,bar%29%27%28")');
+ }
+
+}
+
+// vim: et sw=4 sts=4