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
27
28 public class NotificationTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts({"function", "true"})
35 public void prototype() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html><body><script>\n"
38 + LOG_TITLE_FUNCTION
39 + "try {\n"
40 + " log(typeof window.Notification);\n"
41 + " log('Notification' in window);\n"
42 + "} catch(e) { logEx(e);}\n"
43 + "</script></body></html>";
44
45 loadPageVerifyTitle2(html);
46 }
47
48
49
50
51 @Test
52 @Alerts("default")
53 public void permission() throws Exception {
54 final String html = DOCTYPE_HTML
55 + "<html><body><script>\n"
56 + LOG_TITLE_FUNCTION
57 + "try {\n"
58 + " log(Notification.permission);\n"
59 + "} catch(e) { logEx(e);}\n"
60 + "</script></body></html>";
61
62 loadPageVerifyTitle2(html);
63 }
64
65
66
67
68 @Test
69 @Alerts({})
70 public void minimalUsage() throws Exception {
71 final String html = DOCTYPE_HTML
72 + "<html><body><script>\n"
73 + LOG_TITLE_FUNCTION
74 + "try {\n"
75 + " new Notification('Hello here');\n"
76 + "} catch(e) { logEx(e);}\n"
77 + "</script></body></html>";
78
79 loadPageVerifyTitle2(html);
80 }
81
82
83
84
85 @Test
86 @Alerts("function")
87 public void requestPermission() throws Exception {
88 final String html = DOCTYPE_HTML
89 + "<html><body><script>\n"
90 + LOG_TITLE_FUNCTION
91 + "try {\n"
92 + " log(typeof Notification.requestPermission);\n"
93 + "} catch(e) { logEx(e);}\n"
94 + "</script></body></html>";
95
96 loadPageVerifyTitle2(html);
97 }
98 }