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(DEFAULT = "2",
70 FF = "undefined",
71 FF_ESR = "undefined")
72 public void maxActions() throws Exception {
73 final String html = DOCTYPE_HTML
74 + "<html><body><script>\n"
75 + LOG_TITLE_FUNCTION
76 + "try {\n"
77 + " log(Notification.maxActions);\n"
78 + "} catch(e) { logEx(e);}\n"
79 + "</script></body></html>";
80
81 loadPageVerifyTitle2(html);
82 }
83
84
85
86
87 @Test
88 @Alerts({})
89 public void minimalUsage() throws Exception {
90 final String html = DOCTYPE_HTML
91 + "<html><body><script>\n"
92 + LOG_TITLE_FUNCTION
93 + "try {\n"
94 + " new Notification('Hello here');\n"
95 + "} catch(e) { logEx(e);}\n"
96 + "</script></body></html>";
97
98 loadPageVerifyTitle2(html);
99 }
100
101
102
103
104 @Test
105 @Alerts("function")
106 public void requestPermission() throws Exception {
107 final String html = DOCTYPE_HTML
108 + "<html><body><script>\n"
109 + LOG_TITLE_FUNCTION
110 + "try {\n"
111 + " log(typeof Notification.requestPermission);\n"
112 + "} catch(e) { logEx(e);}\n"
113 + "</script></body></html>";
114
115 loadPageVerifyTitle2(html);
116 }
117 }