Release 2.0.1, merged in 1181 to HEAD.
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / CSSTest.php
blob2d1b4c60775afa0883b30cafc3aff2cf65770bdc
1 <?php
3 require_once 'HTMLPurifier/AttrDef/CSS.php';
4 require_once 'HTMLPurifier/AttrDefHarness.php';
6 class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
9 function test() {
11 $this->def = new HTMLPurifier_AttrDef_CSS();
13 // regular cases, singular
14 $this->assertDef('text-align:right;');
15 $this->assertDef('border-left-style:solid;');
16 $this->assertDef('border-style:solid dotted;');
17 $this->assertDef('clear:right;');
18 $this->assertDef('float:left;');
19 $this->assertDef('font-style:italic;');
20 $this->assertDef('font-variant:small-caps;');
21 $this->assertDef('font-weight:bold;');
22 $this->assertDef('list-style-position:outside;');
23 $this->assertDef('list-style-type:upper-roman;');
24 $this->assertDef('list-style:upper-roman inside;');
25 $this->assertDef('text-transform:capitalize;');
26 $this->assertDef('background-color:rgb(0,0,255);');
27 $this->assertDef('background-color:transparent;');
28 $this->assertDef('background:#333 url(chess.png) repeat fixed 50% top;');
29 $this->assertDef('color:#F00;');
30 $this->assertDef('border-top-color:#F00;');
31 $this->assertDef('border-color:#F00 #FF0;');
32 $this->assertDef('border-top-width:thin;');
33 $this->assertDef('border-top-width:12px;');
34 $this->assertDef('border-width:5px 1px 4px 2px;');
35 $this->assertDef('border-top-width:-12px;', false);
36 $this->assertDef('letter-spacing:normal;');
37 $this->assertDef('letter-spacing:2px;');
38 $this->assertDef('word-spacing:normal;');
39 $this->assertDef('word-spacing:3em;');
40 $this->assertDef('font-size:200%;');
41 $this->assertDef('font-size:larger;');
42 $this->assertDef('font-size:12pt;');
43 $this->assertDef('line-height:2;');
44 $this->assertDef('line-height:2em;');
45 $this->assertDef('line-height:20%;');
46 $this->assertDef('line-height:normal;');
47 $this->assertDef('line-height:-20%;', false);
48 $this->assertDef('margin-left:5px;');
49 $this->assertDef('margin-right:20%;');
50 $this->assertDef('margin-top:auto;');
51 $this->assertDef('margin:auto 5%;');
52 $this->assertDef('padding-bottom:5px;');
53 $this->assertDef('padding-top:20%;');
54 $this->assertDef('padding:20% 10%;');
55 $this->assertDef('padding-top:-20%;', false);
56 $this->assertDef('text-indent:3em;');
57 $this->assertDef('text-indent:5%;');
58 $this->assertDef('text-indent:-3em;');
59 $this->assertDef('width:50%;');
60 $this->assertDef('width:50px;');
61 $this->assertDef('width:auto;');
62 $this->assertDef('width:-50px;', false);
63 $this->assertDef('text-decoration:underline;');
64 $this->assertDef('font-family:sans-serif;');
65 $this->assertDef('font-family:Gill, \'Times New Roman\', sans-serif;');
66 $this->assertDef('font:12px serif;');
67 $this->assertDef('border:1px solid #000;');
68 $this->assertDef('border-bottom:2em double #FF00FA;');
69 $this->assertDef('border-collapse:collapse;');
70 $this->assertDef('caption-side:top;');
71 $this->assertDef('vertical-align:middle;');
72 $this->assertDef('vertical-align:12px;');
73 $this->assertDef('vertical-align:50%;');
74 $this->assertDef('table-layout:fixed;');
75 $this->assertDef('list-style-image:url(nice.jpg);');
76 $this->assertDef('list-style:disc url(nice.jpg) inside;');
77 $this->assertDef('background-image:url(foo.jpg);');
78 $this->assertDef('background-image:none;');
79 $this->assertDef('background-repeat:repeat-y;');
80 $this->assertDef('background-attachment:fixed;');
81 $this->assertDef('background-position:left 90%;');
83 // duplicates
84 $this->assertDef('text-align:right;text-align:left;',
85 'text-align:left;');
87 // a few composites
88 $this->assertDef('font-variant:small-caps;font-weight:900;');
89 $this->assertDef('float:right;text-align:right;');
91 // selective removal
92 $this->assertDef('text-transform:capitalize;destroy:it;',
93 'text-transform:capitalize;');
95 // inherit works for everything
96 $this->assertDef('text-align:inherit;');
98 // bad props
99 $this->assertDef('nodice:foobar;', false);
100 $this->assertDef('position:absolute;', false);
101 $this->assertDef('background-image:url(javascript:alert\(\));', false);
103 // airy input
104 $this->assertDef(' font-weight : bold; color : #ff0000',
105 'font-weight:bold;color:#ff0000;');