1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.event;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.htmlunit.junit.annotation.HtmlUnitNYI;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24
25
26
27
28
29
30
31 @RunWith(BrowserRunner.class)
32 public class AudioProcessingEventTest extends WebDriverTestCase {
33
34 private static final String DUMP_EVENT_FUNCTION = " function dump(event) {\n"
35 + " log(event);\n"
36 + " log(event.type);\n"
37 + " log(event.bubbles);\n"
38 + " log(event.cancelable);\n"
39 + " log(event.composed);\n"
40 + " }\n";
41
42
43
44
45 @Test
46 @Alerts("TypeError")
47 public void create_ctor() throws Exception {
48 final String html = DOCTYPE_HTML
49 + "<html><head><script>\n"
50 + LOG_TITLE_FUNCTION
51 + " function test() {\n"
52 + " try {\n"
53 + " var event = new AudioProcessingEvent('audioprocessing');\n"
54 + " } catch(e) { logEx(e) }\n"
55 + " }\n"
56 + "</script></head><body onload='test()'>\n"
57 + "</body></html>";
58
59 loadPageVerifyTitle2(html);
60 }
61
62
63
64
65 @Test
66 @Alerts(DEFAULT = {"[object AudioProcessingEvent]", "audioprocessing", "false", "false", "false"},
67 FF = "TypeError",
68 FF_ESR = "TypeError")
69
70 @HtmlUnitNYI(CHROME = "TypeError",
71 EDGE = "TypeError")
72 public void create_ctorAllDetails() throws Exception {
73 final String html = DOCTYPE_HTML
74 + "<html><head><script>\n"
75 + LOG_TITLE_FUNCTION
76 + " function test() {\n"
77 + " try {\n"
78 + " var audioCtx = new AudioContext();\n"
79 + " var inputBuffer = audioCtx.createBuffer(2, audioCtx.sampleRate * 3, audioCtx.sampleRate);\n"
80 + " var outputBuffer = audioCtx.createBuffer(2, audioCtx.sampleRate * 3, audioCtx.sampleRate);\n"
81 + " var event = new AudioProcessingEvent('audioprocessing', {"
82 + " 'inputBuffer': inputBuffer,\n"
83 + " 'outputBuffer': outputBuffer,\n"
84 + " 'playbackTime': 4,\n"
85 + " });\n"
86 + " dump(event);\n"
87 + " } catch(e) { logEx(e) }\n"
88 + DUMP_EVENT_FUNCTION
89 + " }\n"
90 + "</script></head><body onload='test()'>\n"
91 + "</body></html>";
92
93 loadPageVerifyTitle2(html);
94 }
95
96
97
98
99 @Test
100 @Alerts("TypeError")
101 public void create_ctorMissingDetails() throws Exception {
102 final String html = DOCTYPE_HTML
103 + "<html><head><script>\n"
104 + LOG_TITLE_FUNCTION
105 + " function test() {\n"
106 + " try {\n"
107 + " var event = new AudioProcessingEvent('audioprocessing');\n"
108 + " dump(event);\n"
109 + " } catch(e) { logEx(e) }\n"
110 + DUMP_EVENT_FUNCTION
111 + " }\n"
112 + "</script></head><body onload='test()'>\n"
113 + "</body></html>";
114
115 loadPageVerifyTitle2(html);
116 }
117
118
119
120
121 @Test
122 @Alerts("NotSupportedError/DOMException")
123 public void create_createEvent() throws Exception {
124 final String html = DOCTYPE_HTML
125 + "<html><head><script>\n"
126 + LOG_TITLE_FUNCTION
127 + " function test() {\n"
128 + " try {\n"
129 + " var event = document.createEvent('AudioProcessingEvent');\n"
130 + " dump(event);\n"
131 + " } catch(e) { logEx(e); }\n"
132 + " }\n"
133 + DUMP_EVENT_FUNCTION
134 + "</script></head><body onload='test()'>\n"
135 + "</body></html>";
136
137 loadPageVerifyTitle2(html);
138 }
139
140
141
142
143 @Test
144 @Alerts("true")
145 public void inWindow() throws Exception {
146 final String html = DOCTYPE_HTML
147 + "<html>\n"
148 + "<head>\n"
149 + " <script>\n"
150 + LOG_TITLE_FUNCTION
151 + " function test() {\n"
152 + " log('AudioProcessingEvent' in window);\n"
153 + " }\n"
154 + " </script>\n"
155 + "</head>\n"
156 + "<body onload='test()'>\n"
157 + "</body>\n"
158 + "</html>";
159
160 loadPageVerifyTitle2(html);
161 }
162 }