OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test AudioContext.close()</title> | 4 <title>Test AudioContext.close()</title> |
5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
6 <script src="resources/compatibility.js"></script> | 6 <script src="resources/compatibility.js"></script> |
7 <script src="resources/audio-testing.js"></script> | 7 <script src="resources/audio-testing.js"></script> |
8 </head> | 8 </head> |
9 | 9 |
10 <body> | 10 <body> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Finally, run GC. The context should be gone, but this seems difficu
lt to verify. | 107 // Finally, run GC. The context should be gone, but this seems difficu
lt to verify. |
108 gc(); | 108 gc(); |
109 shouldBeNull("context.destination"); | 109 shouldBeNull("context.destination"); |
110 } | 110 } |
111 ).then(done); | 111 ).then(done); |
112 }); | 112 }); |
113 | 113 |
114 // Task: test offline context (1). | 114 // Task: test offline context (1). |
115 audit.defineTask('test-offline-context-1', function (done) { | 115 audit.defineTask('test-offline-context-1', function (done) { |
116 | 116 |
117 // For an offline context, just check that if we try to close the context, | 117 // For an offline context, verify that close is not defined. |
118 // nothing happens except that the promise returned by close() is rejected
. | |
119 shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)"); | 118 shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)"); |
120 shouldBeEqualToString("offline.state", "suspended"); | 119 shouldBeEqualToString("offline.state", "suspended"); |
121 offline.close().then( | 120 shouldBeUndefined("offline.close"); |
122 function () { | 121 done(); |
123 testFailed("Closing offline context erroneously resolved"); | |
124 }, | |
125 function (e) { | |
126 if (e.name === "InvalidAccessError") { | |
127 testPassed("Closing offline context correctly rejected: " + e); | |
128 } else { | |
129 testFailed("Closing offline context correctly rejected but expected
InvalidAccessError, not: " + e); | |
130 } | |
131 } | |
132 ).then(done); | |
133 }); | |
134 | |
135 // Task: test offline context (2). | |
136 audit.defineTask('test-offline-context-2', function (done) { | |
137 | |
138 // Try closing again | |
139 offline.close().then( | |
140 function () { | |
141 testFailed("Closing offline context again erroneously resolved"); | |
142 }, | |
143 function () { | |
144 testPassed("Closing offline context again correctly rejected"); | |
145 } | |
146 ).then( | |
147 function () { | |
148 | |
149 // Render the context, and check for a valid state | |
150 offline.oncomplete = function (event) { | |
151 shouldBeEqualToString("event.target.state", "closed"); | |
152 done(); | |
153 }; | |
154 shouldNotThrow("offline.startRendering()"); | |
155 } | |
156 ); | |
157 | |
158 }); | 122 }); |
159 | 123 |
160 audit.defineTask('finish-test', function (done) { | 124 audit.defineTask('finish-test', function (done) { |
161 done(); | 125 done(); |
162 finishJSTest(); | 126 finishJSTest(); |
163 }); | 127 }); |
164 | 128 |
165 audit.runTasks( | 129 audit.runTasks(); |
166 'test-online-context-1', | |
167 'test-online-context-2', | |
168 'test-online-context-3', | |
169 'test-offline-context-1', | |
170 'test-offline-context-2', | |
171 'finish-test' | |
172 ); | |
173 | 130 |
174 successfullyParsed = true; | 131 successfullyParsed = true; |
175 </script> | 132 </script> |
176 </body> | 133 </body> |
177 </html> | 134 </html> |
OLD | NEW |