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.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 FontFaceSetTest extends WebDriverTestCase {
30
31
32
33
34 @Test
35 @Alerts(DEFAULT = "undefined",
36 FF = "function FontFaceSet() { [native code] }",
37 FF_ESR = "function FontFaceSet() { [native code] }")
38 public void window() throws Exception {
39 final String html = DOCTYPE_HTML
40 + "<html>\n"
41 + "<body>\n"
42 + "<script>\n"
43 + LOG_TITLE_FUNCTION
44 + " log(window.FontFaceSet);\n"
45 + "</script>\n"
46 + "</body></html>";
47
48 loadPageVerifyTitle2(html);
49 }
50
51
52
53
54 @Test
55 @Alerts("[object FontFaceSet]")
56 public void documentFonts() throws Exception {
57 final String html = DOCTYPE_HTML
58 + "<html>\n"
59 + "<body>\n"
60 + "<script>\n"
61 + LOG_TITLE_FUNCTION
62 + " log(document.fonts);\n"
63 + "</script>\n"
64 + "</body></html>";
65
66 loadPageVerifyTitle2(html);
67 }
68
69
70
71
72 @Test
73 @Alerts("then: ")
74 public void load() throws Exception {
75 final String html = DOCTYPE_HTML
76 + "<html>\n"
77 + "<body>\n"
78 + "<script>\n"
79 + LOG_TITLE_FUNCTION
80 + " if (document.fonts) {\n"
81 + " document.fonts.load('12px Arial', 'HtmlUnit').then(function(value) {\n"
82 + " log('then: ' + value);"
83 + " });\n"
84 + " } else {\n"
85 + " log('document.fonts is undefined');\n"
86 + " }"
87 + "</script>\n"
88 + "</body></html>";
89
90 loadPage2(html);
91 verifyTitle2(DEFAULT_WAIT_TIME, getWebDriver(), getExpectedAlerts());
92 }
93 }