1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host;
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 public class FontFaceSetTest extends WebDriverTestCase {
27
28
29
30
31 @Test
32 @Alerts(DEFAULT = "undefined",
33 FF = "function FontFaceSet() { [native code] }",
34 FF_ESR = "function FontFaceSet() { [native code] }")
35 public void window() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html>\n"
38 + "<body>\n"
39 + "<script>\n"
40 + LOG_TITLE_FUNCTION
41 + " log(window.FontFaceSet);\n"
42 + "</script>\n"
43 + "</body></html>";
44
45 loadPageVerifyTitle2(html);
46 }
47
48
49
50
51 @Test
52 @Alerts("[object FontFaceSet]")
53 public void documentFonts() throws Exception {
54 final String html = DOCTYPE_HTML
55 + "<html>\n"
56 + "<body>\n"
57 + "<script>\n"
58 + LOG_TITLE_FUNCTION
59 + " log(document.fonts);\n"
60 + "</script>\n"
61 + "</body></html>";
62
63 loadPageVerifyTitle2(html);
64 }
65
66
67
68
69 @Test
70 @Alerts("then: ")
71 public void load() throws Exception {
72 final String html = DOCTYPE_HTML
73 + "<html>\n"
74 + "<body>\n"
75 + "<script>\n"
76 + LOG_TITLE_FUNCTION
77 + " if (document.fonts) {\n"
78 + " document.fonts.load('12px Arial', 'HtmlUnit').then(function(value) {\n"
79 + " log('then: ' + value);"
80 + " });\n"
81 + " } else {\n"
82 + " log('document.fonts is undefined');\n"
83 + " }"
84 + "</script>\n"
85 + "</body></html>";
86
87 loadPage2(html);
88 verifyTitle2(DEFAULT_WAIT_TIME, getWebDriver(), getExpectedAlerts());
89 }
90
91
92
93
94 @Test
95 @Alerts(DEFAULT = {"false", "undefined", "ReferenceError", "ReferenceError", "ReferenceError",
96 "false", "undefined", "ReferenceError", "ReferenceError", "ReferenceError"},
97 FF = {"false", "undefined", "ReferenceError", "ReferenceError", "ReferenceError",
98 "true", "function FontFaceSet() { [native code] }", "function FontFaceSet() { [native code] }",
99 "[object FontFaceSet]", "function EventTarget() { [native code] }"},
100 FF_ESR = {"false", "undefined", "ReferenceError", "ReferenceError", "ReferenceError",
101 "true", "function FontFaceSet() { [native code] }", "function FontFaceSet() { [native code] }",
102 "[object FontFaceSet]", "function EventTarget() { [native code] }"})
103 public void windowScope() throws Exception {
104 final String html = DOCTYPE_HTML
105 + "<html></body>\n"
106 + "<script>\n"
107 + LOG_TITLE_FUNCTION
108 + " log('fontFaceSet' in window);\n"
109 + " log(window.fontFaceSet);\n"
110 + " try { log(fontFaceSet); } catch(e) { logEx(e); };\n"
111 + " try { log(fontFaceSet.prototype); } catch(e) { logEx(e); };\n"
112 + " try { log(fontFaceSet.__proto__); } catch(e) { logEx(e); };\n"
113
114 + " log('FontFaceSet' in window);\n"
115 + " log(window.FontFaceSet);\n"
116 + " try { log(FontFaceSet); } catch(e) { logEx(e); };\n"
117 + " try { log(FontFaceSet.prototype); } catch(e) { logEx(e); };\n"
118 + " try { log(FontFaceSet.__proto__); } catch(e) { logEx(e); };\n"
119 + "</script>\n"
120 + "</body></html>";
121
122 loadPageVerifyTitle2(html);
123 }
124 }