1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.html;
16
17 import org.htmlunit.HttpHeader;
18 import org.htmlunit.WebDriverTestCase;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.junit.jupiter.api.Test;
21
22
23
24
25
26
27
28
29 public class HTMLMetaElementTest extends WebDriverTestCase {
30
31
32
33
34 @Test
35 @Alerts({"undefined", "text/html; charset=utf-8", HttpHeader.CONTENT_TYPE, "", "", "undefined", ""})
36 public void name() throws Exception {
37 final String html = DOCTYPE_HTML
38 + "<html>\n"
39 + " <head>\n"
40 + " <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n"
41 + " <script>\n"
42 + LOG_TITLE_FUNCTION
43 + " function test() {\n"
44 + " var meta = document.getElementsByTagName('meta')[0];\n"
45 + " log(meta.charset);\n"
46 + " log(meta.content);\n"
47 + " log(meta.httpEquiv);\n"
48 + " log(meta.name);\n"
49 + " log(meta.scheme);\n"
50 + " log(meta.url);\n"
51 + " log(meta.media);\n"
52 + " }\n"
53 + " </script>\n"
54 + " </head>\n"
55 + " <body onload='test()'></body>\n"
56 + "</html>";
57
58 loadPageVerifyTitle2(html);
59 }
60
61
62
63
64 @Test
65 @Alerts("only screen and (max-width: 600px)")
66 public void media() throws Exception {
67 final String html = DOCTYPE_HTML
68 + "<html>\n"
69 + " <head>\n"
70 + " <meta http-equiv='Content-Type' media='only screen and (max-width: 600px)'>\n"
71 + " <script>\n"
72 + LOG_TITLE_FUNCTION
73 + " function test() {\n"
74 + " var meta = document.getElementsByTagName('meta')[0];\n"
75 + " log(meta.media);\n"
76 + " }\n"
77 + " </script>\n"
78 + " </head>\n"
79 + " <body onload='test()'></body>\n"
80 + "</html>";
81
82 loadPageVerifyTitle2(html);
83 }
84 }