Partial border-radius support.
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / CSSTest.php
blobda2ab6b0aa954aa301b09eb7fea7991fedefd20c
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('color:#F00;');
31 $this->assertDef('border-top-color:#F00;');
32 $this->assertDef('border-color:#F00 #FF0;');
33 $this->assertDef('border-top-width:thin;');
34 $this->assertDef('border-top-width:12px;');
35 $this->assertDef('border-width:5px 1px 4px 2px;');
36 $this->assertDef('border-top-width:-12px;', false);
37 $this->assertDef('letter-spacing:normal;');
38 $this->assertDef('letter-spacing:2px;');
39 $this->assertDef('word-spacing:normal;');
40 $this->assertDef('word-spacing:3em;');
41 $this->assertDef('font-size:200%;');
42 $this->assertDef('font-size:larger;');
43 $this->assertDef('font-size:12pt;');
44 $this->assertDef('line-height:2;');
45 $this->assertDef('line-height:2em;');
46 $this->assertDef('line-height:20%;');
47 $this->assertDef('line-height:normal;');
48 $this->assertDef('line-height:-20%;', false);
49 $this->assertDef('margin-left:5px;');
50 $this->assertDef('margin-right:20%;');
51 $this->assertDef('margin-top:auto;');
52 $this->assertDef('margin:auto 5%;');
53 $this->assertDef('padding-bottom:5px;');
54 $this->assertDef('padding-top:20%;');
55 $this->assertDef('padding:20% 10%;');
56 $this->assertDef('padding-top:-20%;', false);
57 $this->assertDef('text-indent:3em;');
58 $this->assertDef('text-indent:5%;');
59 $this->assertDef('text-indent:-3em;');
60 $this->assertDef('width:50%;');
61 $this->assertDef('width:50px;');
62 $this->assertDef('width:auto;');
63 $this->assertDef('width:-50px;', false);
64 $this->assertDef('text-decoration:underline;');
65 $this->assertDef('font-family:sans-serif;');
66 $this->assertDef("font-family:Gill, 'Times New Roman', sans-serif;");
67 $this->assertDef('font:12px serif;');
68 $this->assertDef('border:1px solid #000;');
69 $this->assertDef('border-bottom:2em double #FF00FA;');
70 $this->assertDef('border-collapse:collapse;');
71 $this->assertDef('border-collapse:separate;');
72 $this->assertDef('caption-side:top;');
73 $this->assertDef('vertical-align:middle;');
74 $this->assertDef('vertical-align:12px;');
75 $this->assertDef('vertical-align:50%;');
76 $this->assertDef('table-layout:fixed;');
77 $this->assertDef('list-style-image:url("nice.jpg");');
78 $this->assertDef('list-style:disc url("nice.jpg") inside;');
79 $this->assertDef('background-image:url("foo.jpg");');
80 $this->assertDef('background-image:none;');
81 $this->assertDef('background-repeat:repeat-y;');
82 $this->assertDef('background-attachment:fixed;');
83 $this->assertDef('background-position:left 90%;');
84 $this->assertDef('border-spacing:1em;');
85 $this->assertDef('border-spacing:1em 2em;');
86 $this->assertDef('border-color: rgb(0, 0, 0) rgb(10,0,10)', 'border-color:rgb(0,0,0) rgb(10,0,10);');
87 $this->assertDef('border: rgb(0, 0, 0)', 'border:rgb(0,0,0);');
89 // duplicates
90 $this->assertDef('text-align:right;text-align:left;',
91 'text-align:left;');
93 // a few composites
94 $this->assertDef('font-variant:small-caps;font-weight:900;');
95 $this->assertDef('float:right;text-align:right;');
97 // selective removal
98 $this->assertDef('text-transform:capitalize;destroy:it;',
99 'text-transform:capitalize;');
101 // inherit works for everything
102 $this->assertDef('text-align:inherit;');
104 // bad props
105 $this->assertDef('nodice:foobar;', false);
106 $this->assertDef('position:absolute;', false);
107 $this->assertDef('background-image:url(\'javascript:alert\(\)\');', false);
109 // airy input
110 $this->assertDef(' font-weight : bold; color : #ff0000',
111 'font-weight:bold;color:#ff0000;');
113 // case-insensitivity
114 $this->assertDef('FLOAT:LEFT;', 'float:left;');
116 // !important stripping
117 $this->assertDef('float:left !important;', 'float:left;');
121 public function testProprietary()
123 $this->config->set('CSS.Proprietary', true);
125 $this->assertDef('scrollbar-arrow-color:#ff0;');
126 $this->assertDef('scrollbar-base-color:#ff6347;');
127 $this->assertDef('scrollbar-darkshadow-color:#ffa500;');
128 $this->assertDef('scrollbar-face-color:#008080;');
129 $this->assertDef('scrollbar-highlight-color:#ff69b4;');
130 $this->assertDef('scrollbar-shadow-color:#f0f;');
132 $this->assertDef('-moz-opacity:.2;');
133 $this->assertDef('-khtml-opacity:.2;');
134 $this->assertDef('filter:alpha(opacity=20);');
136 $this->assertDef('border-top-left-radius:55pt 25pt;');
140 public function testImportant()
142 $this->config->set('CSS.AllowImportant', true);
143 $this->assertDef('float:left !important;');
146 public function testTricky()
148 $this->config->set('CSS.AllowTricky', true);
149 $this->assertDef('display:none;');
150 $this->assertDef('visibility:visible;');
151 $this->assertDef('overflow:scroll;');
152 $this->assertDef('opacity:.2;');
155 public function testForbidden()
157 $this->config->set('CSS.ForbiddenProperties', 'float');
158 $this->assertDef('float:left;', false);
159 $this->assertDef('text-align:right;');
162 public function testTrusted()
164 $this->config->set('CSS.Trusted', true);
165 $this->assertDef('position:relative;');
166 $this->assertDef('left:2px;');
167 $this->assertDef('right:100%;');
168 $this->assertDef('top:auto;');
169 $this->assertDef('z-index:-2;');
172 public function testAllowDuplicates()
174 $this->config->set('CSS.AllowDuplicates', true);
175 $this->assertDef('text-align:right;text-align:left;');
176 $this->assertDef('text-align:right;text-align:left;text-align:right;');
181 // vim: et sw=4 sts=4