1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22
23
24
25
26
27
28
29
30
31 @RunWith(BrowserRunner.class)
32 public class IEConditionalCommentExpressionEvaluatorTest extends WebDriverTestCase {
33
34
35
36
37
38 @Test
39 @Alerts("done")
40 public void IE() throws Exception {
41 doTest("IE");
42 }
43
44
45
46
47
48 @Test
49 @Alerts("done")
50 public void IE_5() throws Exception {
51 doTest("IE 5");
52 }
53
54
55
56
57
58 @Test
59 @Alerts("done")
60 public void IE_6() throws Exception {
61 doTest("IE 6");
62 }
63
64
65
66
67
68 @Test
69 @Alerts("done")
70 public void IE_7() throws Exception {
71 doTest("IE 7");
72 }
73
74
75
76
77
78 @Test
79 @Alerts("done")
80 public void IE_8() throws Exception {
81 doTest("IE 8");
82 }
83
84
85
86
87
88 @Test
89 @Alerts("done")
90 public void notIE() throws Exception {
91 doTest("!IE");
92 }
93
94
95
96
97
98 @Test
99 @Alerts("done")
100 public void lt_IE_5_5() throws Exception {
101 doTest("lt IE 5.5");
102 }
103
104
105
106
107
108 @Test
109 @Alerts("done")
110 public void lt_IE_6() throws Exception {
111 doTest("lt IE 6");
112 }
113
114
115
116
117
118 @Test
119 @Alerts("done")
120 public void lt_IE_7() throws Exception {
121 doTest("lt IE 7");
122 }
123
124
125
126
127
128 @Test
129 @Alerts("done")
130 public void lt_IE_8() throws Exception {
131 doTest("lt IE 8");
132 }
133
134
135
136
137
138 @Test
139 @Alerts("done")
140 public void lt_IE_9() throws Exception {
141 doTest("lt IE 9");
142 }
143
144
145
146
147
148 @Test
149 @Alerts("done")
150 public void gt_IE_5_5() throws Exception {
151 doTest("gt IE 5.5");
152 }
153
154
155
156
157
158 @Test
159 @Alerts("done")
160 public void gt_IE_6() throws Exception {
161 doTest("gt IE 6");
162 }
163
164
165
166
167
168 @Test
169 @Alerts("done")
170 public void gt_IE_7() throws Exception {
171 doTest("gt IE 7");
172 }
173
174
175
176
177
178 @Test
179 @Alerts("done")
180 public void gt_IE_8() throws Exception {
181 doTest("gt IE 8");
182 }
183
184
185
186
187
188 @Test
189 @Alerts("done")
190 public void gte_IE_5_5() throws Exception {
191 doTest("gte IE 5.5");
192 }
193
194
195
196
197
198 @Test
199 @Alerts("done")
200 public void gte_IE_6() throws Exception {
201 doTest("gte IE 6");
202 }
203
204
205
206
207
208 @Test
209 @Alerts("done")
210 public void gte_IE_7() throws Exception {
211 doTest("gte IE 7");
212 }
213
214
215
216
217
218 @Test
219 @Alerts("done")
220 public void gte_IE_8() throws Exception {
221 doTest("gte IE 8");
222 }
223
224
225
226
227
228 @Test
229 @Alerts("done")
230 public void parenthese_5() throws Exception {
231 doTest("!(IE 5)");
232 }
233
234
235
236
237
238 @Test
239 @Alerts("done")
240 public void parenthese_6() throws Exception {
241 doTest("!(IE 6)");
242 }
243
244
245
246
247
248 @Test
249 @Alerts("done")
250 public void parenthese_7() throws Exception {
251 doTest("!(IE 7)");
252 }
253
254
255
256
257
258 @Test
259 @Alerts("done")
260 public void parenthese_8() throws Exception {
261 doTest("!(IE 8)");
262 }
263
264
265
266
267
268 @Test
269 @Alerts("done")
270 public void and() throws Exception {
271 doTest("(gt IE 6)&(lt IE 8)");
272 }
273
274
275
276
277
278 @Test
279 @Alerts("done")
280 public void or() throws Exception {
281 doTest("(IE 6)|(IE 7)");
282 }
283
284
285
286
287
288 @Test
289 @Alerts("done")
290 public void true_() throws Exception {
291 doTest("true");
292 }
293
294
295
296
297
298 @Test
299 @Alerts("done")
300 public void false_() throws Exception {
301 doTest("false");
302 }
303
304
305
306
307
308 @Test
309 @Alerts("done")
310 public void mso_1() throws Exception {
311 doTest("mso 9");
312 }
313
314
315
316
317
318 @Test
319 @Alerts("done")
320 public void mso_2() throws Exception {
321 doTest("gte mso 9");
322 }
323
324
325
326
327
328 @Test
329 @Alerts("done")
330 public void mso_3() throws Exception {
331 doTest("lt mso 9");
332 }
333
334
335
336
337
338 @Test
339 @Alerts("done")
340 public void mso_4() throws Exception {
341 doTest("lt mso 1");
342 }
343
344
345
346
347
348 @Test
349 @Alerts("done")
350 public void unknown_1() throws Exception {
351 doTest("foo 1");
352 }
353
354
355
356
357
358 @Test
359 @Alerts("done")
360 public void unknown_2() throws Exception {
361 doTest("gte foo 1");
362 }
363
364
365
366
367
368 @Test
369 @Alerts("done")
370 public void unknown_3() throws Exception {
371 doTest("gt foo 1");
372 }
373
374
375
376
377
378 @Test
379 @Alerts("done")
380 public void unknown_4() throws Exception {
381 doTest("lt foo 1");
382 }
383
384 private void doTest(final String expression) throws Exception {
385 final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
386 + "<html><head>\n"
387 + "<!--[if " + expression + "]><script>alert('cond');</script><![endif]-->\n"
388 + "<script>alert('done');</script>\n"
389 + "</head><body></body></html>";
390 loadPageWithAlerts2(html);
391 }
392 }