Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: LayoutTests/webaudio/audiocontext-close.html

Issue 950343005: Improve webaudio/audiocontext-close.html stability. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/webaudio/audiocontext-close-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 <script> 11 <script>
12 description("Basic functionality test of closing an AudioContext"); 12 description("Basic functionality test of closing an AudioContext");
13 window.jsTestIsAsync = true; 13 window.jsTestIsAsync = true;
14 14
15 var context; 15 var context;
16 var offline; 16 var offline;
17 var osc; 17 var osc;
18 var gain; 18 var gain;
19 var promise1; 19 var promise1;
20 var promise2; 20 var promise2;
21 var offlinePromise; 21 var offlinePromise;
22 var wave = new Float32Array(1); 22 var wave = new Float32Array(1);
23 23
24 var audit = Audit.createTaskRunner(); 24 var audit = Audit.createTaskRunner();
25 25
26 // Task: test online context (1). 26 // Task: test online context (1).
27 audit.defineTask('test-online-context-1', function (done) { 27 audit.defineTask('test-online-context-1', function (done) {
28 28
29 // Create a context and verify that the various states are correct and 29 // Create a context and verify that the various states are correct and
30 // that close() exists. 30 // that close() exists.
31 shouldNotThrow("context = new AudioContext()"); 31 shouldNotThrow("context = new AudioContext()");
32 shouldBeEqualToString("context.state", "running"); 32 shouldBeEqualToString("context.state", "running");
33 33
34 // Create gain and oscillator for testing later. 34 // Create gain and oscillator for testing later.
35 shouldNotThrow("osc = context.createOscillator()"); 35 shouldNotThrow("osc = context.createOscillator()");
36 shouldNotThrow("gain = context.createGain()"); 36 shouldNotThrow("gain = context.createGain()");
37 shouldNotThrow("gain.connect(context.destination)"); 37 shouldNotThrow("gain.connect(context.destination)");
38 38
39 // Close the context. When the promise is resolved, continue the next 39 // Close the context. When the promise is resolved, continue the next
40 // test task. 40 // test task.
41 context.close().then( 41 context.close().then(
42 function () { 42 function () {
43 testPassed("context.close() was correctly resolved"); 43 testPassed("context.close() was correctly resolved");
44 }, 44 },
45 function () { 45 function () {
46 testFailed("context.close() was erroneously rejected"); 46 testFailed("context.close() was erroneously rejected");
47 } 47 }
48 ).then(done); 48 ).then(done);
49 49
50 }); 50 });
51 51
52 // Task: test online context (2). 52 // Task: test online context (2).
53 audit.defineTask('test-online-context-2', function (done) { 53 audit.defineTask('test-online-context-2', function (done) {
54 54
55 // Context is closed, so verify that we cannot create any more nodes, 55 // Context is closed, so verify that we cannot create any more nodes,
56 // nor connect any. 56 // nor connect any.
57 shouldThrow("context.createAnalyser()"); 57 shouldThrow("context.createAnalyser()");
58 shouldThrow("context.createBiquadFilter()"); 58 shouldThrow("context.createBiquadFilter()");
59 59
60 // createBuffer is an exception because it's not really tied in any way 60 // createBuffer is an exception because it's not really tied in any way
61 // to an audio context. And it's useful to be able to create a buffer 61 // to an audio context. And it's useful to be able to create a buffer
62 // inside the oncomplete event of an offline context to use for testing 62 // inside the oncomplete event of an offline context to use for testing
63 // purposes. 63 // purposes.
64 shouldNotThrow("context.createBuffer(1, 1, 48000)"); 64 shouldNotThrow("context.createBuffer(1, 1, 48000)");
65 65
66 shouldThrow("context.createBufferSource()"); 66 shouldThrow("context.createBufferSource()");
67 shouldThrow("context.createChannelMerger()"); 67 shouldThrow("context.createChannelMerger()");
68 shouldThrow("context.createChannelSplitter()"); 68 shouldThrow("context.createChannelSplitter()");
69 shouldThrow("context.createConvolver()"); 69 shouldThrow("context.createConvolver()");
70 shouldThrow("context.createDelay()"); 70 shouldThrow("context.createDelay()");
71 shouldThrow("context.createDynamicsCompressor()"); 71 shouldThrow("context.createDynamicsCompressor()");
72 shouldThrow("context.createGain()"); 72 shouldThrow("context.createGain()");
(...skipping 13 matching lines...) Expand all
86 testFailed("Attempt to resume a closed context erroneously succeeded") ; 86 testFailed("Attempt to resume a closed context erroneously succeeded") ;
87 }, 87 },
88 function () { 88 function () {
89 testPassed("Attempt to resume a closed context was correctly rejected" ); 89 testPassed("Attempt to resume a closed context was correctly rejected" );
90 } 90 }
91 ).then(done); 91 ).then(done);
92 }); 92 });
93 93
94 // Task: test online context (3). 94 // Task: test online context (3).
95 audit.defineTask('test-online-context-3', function (done) { 95 audit.defineTask('test-online-context-3', function (done) {
96 96
97 // Try closing the context again. The promise should be rejected. 97 // Try closing the context again. The promise should be rejected.
98 context.close().then( 98 context.close().then(
99 function () { 99 function () {
100 testFailed("Closing context again erroneously resolved successfully.") ; 100 testFailed("Closing context again erroneously resolved successfully.") ;
101 }, 101 },
102 function () { 102 function () {
103 testPassed("Closing context again correctly rejected promise."); 103 testPassed("Closing context again correctly rejected promise.");
104 104 // Finally, run GC. The context should be gone, but this seems difficu lt to verify.
105 // Finally, run GC. The context should be gone, but this seems 105 gc();
106 // difficult to verify. 106 shouldBeNull("context.destination");
107 if (window.hasOwnProperty('GCController')) {
108 asyncGC(function () {
109 shouldBeNull("context.destination");
110 });
111 } else {
112 shouldBeNull("context.destination");
113 testFailed("asyncGC test not run");
114 }
115 } 107 }
116 ).then(done); 108 ).then(done);
117 }); 109 });
118 110
119 // Task: test offline context (1). 111 // Task: test offline context (1).
120 audit.defineTask('test-offline-context-1', function (done) { 112 audit.defineTask('test-offline-context-1', function (done) {
121 113
122 // For an offline context, just check that if we try to close the context, 114 // For an offline context, just check that if we try to close the context,
123 // nothing happens except that the promise returned by close() is rejected . 115 // nothing happens except that the promise returned by close() is rejected .
124 shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)"); 116 shouldNotThrow("offline = new OfflineAudioContext(1, 1000, 48000)");
125 shouldBeEqualToString("offline.state", "suspended"); 117 shouldBeEqualToString("offline.state", "suspended");
126 offline.close().then( 118 offline.close().then(
127 function () { 119 function () {
128 testFailed("Closing offline context erroneously resolved"); 120 testFailed("Closing offline context erroneously resolved");
129 }, 121 },
130 function () { 122 function () {
131 testPassed("Closing offline context correctly rejected"); 123 testPassed("Closing offline context correctly rejected");
132 } 124 }
133 ).then(done); 125 ).then(done);
134 }); 126 });
135 127
136 // Task: test offline context (2). 128 // Task: test offline context (2).
137 audit.defineTask('test-offline-context-2', function (done) { 129 audit.defineTask('test-offline-context-2', function (done) {
138 130
139 // Try closing again 131 // Try closing again
140 offline.close().then( 132 offline.close().then(
141 function () { 133 function () {
142 testFailed("Closing offline context again erroneously resolved"); 134 testFailed("Closing offline context again erroneously resolved");
143 }, 135 },
144 function () { 136 function () {
145 testPassed("Closing offline context again correctly rejected"); 137 testPassed("Closing offline context again correctly rejected");
146 } 138 }
147 ).then( 139 ).then(
148 function () { 140 function () {
149 141
150 // Render the context, and check for a valid state 142 // Render the context, and check for a valid state
151 offline.oncomplete = function (event) { 143 offline.oncomplete = function (event) {
152 shouldBeEqualToString("event.target.state", "closed"); 144 shouldBeEqualToString("event.target.state", "closed");
153 done(); 145 done();
154 }; 146 };
155 shouldNotThrow("offline.startRendering()"); 147 shouldNotThrow("offline.startRendering()");
156 } 148 }
157 ); 149 );
158 150
159 }); 151 });
160 152
161 audit.defineTask('finish-test', function (done) { 153 audit.defineTask('finish-test', function (done) {
162 done(); 154 done();
163 finishJSTest(); 155 finishJSTest();
164 }); 156 });
165 157
166 audit.runTasks( 158 audit.runTasks(
167 'test-online-context-1', 159 'test-online-context-1',
168 'test-online-context-2', 160 'test-online-context-2',
169 'test-online-context-3', 161 'test-online-context-3',
170 'test-offline-context-1', 162 'test-offline-context-1',
171 'test-offline-context-2', 163 'test-offline-context-2',
172 'finish-test' 164 'finish-test'
173 ); 165 );
174 166
175 successfullyParsed = true; 167 successfullyParsed = true;
176 </script> 168 </script>
177 </body> 169 </body>
178 </html> 170 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/webaudio/audiocontext-close-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698