Whoops, forgot to edit WHATSNEW
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / CSSTest.php
blob2d938cecbc99bffda5b79b896138856166d653dd
1 <?php
3 class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
6 public function setup()
8 parent::setup();
9 $this->def = new HTMLPurifier_AttrDef_CSS();
12 public function test()
14 // regular cases, singular
15 $this->assertDef('text-align:right;');
16 $this->assertDef('border-left-style:solid;');
17 $this->assertDef('border-style:solid dotted;');
18 $this->assertDef('clear:right;');
19 $this->assertDef('float:left;');
20 $this->assertDef('font-style:italic;');
21 $this->assertDef('font-variant:small-caps;');
22 $this->assertDef('font-weight:bold;');
23 $this->assertDef('list-style-position:outside;');
24 $this->assertDef('list-style-type:upper-roman;');
25 $this->assertDef('list-style:upper-roman inside;');
26 $this->assertDef('text-transform:capitalize;');
27 $this->assertDef('background-color:rgb(0,0,255);');
28 $this->assertDef('background-color:transparent;');
29 $this->assertDef('background:#333 url("chess.png") repeat fixed 50% top;');
30 $this->assertDef('background:#333 url("che;ss.png") repeat fixed 50% top;');
31 $this->assertDef('color:#F00;');
32 $this->assertDef('border-top-color:#F00;');
33 $this->assertDef('border-color:#F00 #FF0;');
34 $this->assertDef('border-top-width:thin;');
35 $this->assertDef('border-top-width:12px;');
36 $this->assertDef('border-width:5px 1px 4px 2px;');
37 $this->assertDef('border-top-width:-12px;', false);
38 $this->assertDef('letter-spacing:normal;');
39 $this->assertDef('letter-spacing:2px;');
40 $this->assertDef('word-spacing:normal;');
41 $this->assertDef('word-spacing:3em;');
42 $this->assertDef('font-size:200%;');
43 $this->assertDef('font-size:larger;');
44 $this->assertDef('font-size:12pt;');
45 $this->assertDef('line-height:2;');
46 $this->assertDef('line-height:2em;');
47 $this->assertDef('line-height:20%;');
48 $this->assertDef('line-height:normal;');
49 $this->assertDef('line-height:-20%;', false);
50 $this->assertDef('margin-left:5px;');
51 $this->assertDef('margin-right:20%;');
52 $this->assertDef('margin-top:auto;');
53 $this->assertDef('margin:auto 5%;');
54 $this->assertDef('padding-bottom:5px;');
55 $this->assertDef('padding-top:20%;');
56 $this->assertDef('padding:20% 10%;');
57 $this->assertDef('padding-top:-20%;', false);
58 $this->assertDef('text-indent:3em;');
59 $this->assertDef('text-indent:5%;');
60 $this->assertDef('text-indent:-3em;');
61 $this->assertDef('width:50%;');
62 $this->assertDef('width:50px;');
63 $this->assertDef('width:auto;');
64 $this->assertDef('width:-50px;', false);
65 $this->assertDef('min-width:50%;');
66 $this->assertDef('min-width:50px;');
67 $this->assertDef('min-width:auto;');
68 $this->assertDef('min-width:-50px;', false);
69 $this->assertDef('min-width:50ch;');
70 $this->assertDef('min-width:50rem;');
71 $this->assertDef('min-width:50vw;');
72 $this->assertDef('min-width:-50vw;', false);
73 $this->assertDef('text-decoration:underline;');
74 $this->assertDef('font-family:sans-serif;');
75 $this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;");
76 $this->assertDef('font:12px serif;');
77 $this->assertDef('border:1px solid #000;');
78 $this->assertDef('border-bottom:2em double #FF00FA;');
79 $this->assertDef('border-collapse:collapse;');
80 $this->assertDef('border-collapse:separate;');
81 $this->assertDef('caption-side:top;');
82 $this->assertDef('vertical-align:middle;');
83 $this->assertDef('vertical-align:12px;');
84 $this->assertDef('vertical-align:50%;');
85 $this->assertDef('table-layout:fixed;');
86 $this->assertDef('list-style-image:url("nice.jpg");');
87 $this->assertDef('list-style:disc url("nice.jpg") inside;');
88 $this->assertDef('background-image:url("foo.jpg");');
89 $this->assertDef('background-image:none;');
90 $this->assertDef('background-repeat:repeat-y;');
91 $this->assertDef('background-attachment:fixed;');
92 $this->assertDef('background-position:left 90%;');
93 $this->assertDef('border-spacing:1em;');
94 $this->assertDef('border-spacing:1em 2em;');
95 $this->assertDef('border-color: rgb(0, 0, 0) rgb(10,0,10)', 'border-color:rgb(0,0,0) rgb(10,0,10);');
96 $this->assertDef('border: rgb(0, 0, 0)', 'border:rgb(0,0,0);');
98 // duplicates
99 $this->assertDef('text-align:right;text-align:left;',
100 'text-align:left;');
102 // a few composites
103 $this->assertDef('font-variant:small-caps;font-weight:900;');
104 $this->assertDef('float:right;text-align:right;');
106 // selective removal
107 $this->assertDef('text-transform:capitalize;destroy:it;',
108 'text-transform:capitalize;');
110 // inherit works for everything
111 $this->assertDef('text-align:inherit;');
113 // bad props
114 $this->assertDef('nodice:foobar;', false);
115 $this->assertDef('position:absolute;', false);
116 $this->assertDef('background-image:url(\'javascript:alert\(\)\');', false);
118 // airy input
119 $this->assertDef(' font-weight : bold; color : #ff0000',
120 'font-weight:bold;color:#ff0000;');
122 // case-insensitivity
123 $this->assertDef('FLOAT:LEFT;', 'float:left;');
125 // !important stripping
126 $this->assertDef('float:left !important;', 'float:left;');
130 public function testProprietary()
132 $this->config->set('CSS.Proprietary', true);
134 $this->assertDef('scrollbar-arrow-color:#ff0;');
135 $this->assertDef('scrollbar-base-color:#ff6347;');
136 $this->assertDef('scrollbar-darkshadow-color:#ffa500;');
137 $this->assertDef('scrollbar-face-color:#008080;');
138 $this->assertDef('scrollbar-highlight-color:#ff69b4;');
139 $this->assertDef('scrollbar-shadow-color:#f0f;');
141 $this->assertDef('-moz-opacity:.2;');
142 $this->assertDef('-khtml-opacity:.2;');
143 $this->assertDef('filter:alpha(opacity=20);');
145 $this->assertDef('border-top-left-radius:55pt 25pt;');
149 public function testImportant()
151 $this->config->set('CSS.AllowImportant', true);
152 $this->assertDef('float:left !important;');
155 public function testTricky()
157 $this->config->set('CSS.AllowTricky', true);
158 $this->assertDef('display:none;');
159 $this->assertDef('visibility:visible;');
160 $this->assertDef('overflow:scroll;');
161 $this->assertDef('opacity:.2;');
164 public function testForbidden()
166 $this->config->set('CSS.ForbiddenProperties', 'float');
167 $this->assertDef('float:left;', false);
168 $this->assertDef('text-align:right;');
171 public function testTrusted()
173 $this->config->set('CSS.Trusted', true);
174 $this->assertDef('position:relative;');
175 $this->assertDef('left:2px;');
176 $this->assertDef('right:100%;');
177 $this->assertDef('top:auto;');
178 $this->assertDef('z-index:-2;');
181 public function testAllowDuplicates()
183 $this->config->set('CSS.AllowDuplicates', true);
184 $this->assertDef('text-align:right;text-align:left;');
185 $this->assertDef('text-align:right;text-align:left;text-align:right;');
190 // vim: et sw=4 sts=4