1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.css;
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 @RunWith(BrowserRunner.class)
29 public class StyleMediaTest extends WebDriverTestCase {
30
31
32
33
34 @Test
35 @Alerts(DEFAULT = {"[object StyleMedia]", "screen"},
36 FF = "undefined",
37 FF_ESR = "undefined")
38 public void type() throws Exception {
39 final String html = DOCTYPE_HTML
40 + "<html><head>\n"
41 + "<script>\n"
42 + LOG_TITLE_FUNCTION
43 + " function test() {\n"
44 + " log(window.styleMedia);\n"
45 + " if (window.styleMedia) {\n"
46 + " log(window.styleMedia.type);\n"
47 + " }\n"
48 + " }\n"
49 + "</script></head><body onload='test()'>\n"
50 + "</body></html>";
51
52 loadPageVerifyTitle2(html);
53 }
54
55
56
57
58 @Test
59 @Alerts(DEFAULT = {"true", "true", "true", "false"},
60 FF = {},
61 FF_ESR = {})
62 public void matchMedium() throws Exception {
63 final String html = DOCTYPE_HTML
64 + "<html><head>\n"
65 + "<script>\n"
66 + LOG_TITLE_FUNCTION
67 + " function test() {\n"
68 + " if (window.styleMedia) {\n"
69 + " log(window.styleMedia.matchMedium('screen'));\n"
70 + " log(window.styleMedia.matchMedium('SCREEN'));\n"
71 + " log(window.styleMedia.matchMedium('screen, handheld'));\n"
72 + " log(window.styleMedia.matchMedium('handheld'));\n"
73 + " }\n"
74 + " }\n"
75 + "</script></head><body onload='test()'>\n"
76 + "</body></html>";
77
78 loadPageVerifyTitle2(html);
79 }
80 }