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