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

Side by Side Diff: LayoutTests/webaudio/offlineaudiocontext-detached-no-crash.html

Issue 1111213002: Treat a stopped AudioContext as closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: startRendering() doesn't (directly) raise an exception Created 5 years, 7 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
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="resources/compatibility.js"></script> 4 <script src="resources/compatibility.js"></script>
5 <script src="resources/audio-testing.js"></script> 5 <script src="resources/audio-testing.js"></script>
6 <script src="../resources/js-test.js"></script> 6 <script src="../resources/js-test.js"></script>
7 </head> 7 </head>
8 <body> 8 <body>
9 <script> 9 <script>
10 description("Tests that ScriptProcessorNode event dispatch doesn't fail when det ached from document."); 10 description("Tests document-detached use of OfflineAudioContext, pass if no cras h.");
11 11
12 window.jsTestIsAsync = true; 12 window.jsTestIsAsync = true;
13 13
14 var sampleRate = 44100.0; 14 function errorCallback(error)
15 var renderLengthInFrames = 512; 15 {
16 var bufferSize = 512; 16 testPassed("OfflineAudioContext.startRendering() on a closed context threw a n exception.");
17 finishJSTest();
18 }
19
20 function successCallback()
21 {
22 testFailed("OfflineAudioContext.startRendering() on a closed context did not throw an exception.");
23 finishJSTest();
24 }
25
17 var context; 26 var context;
18 function runTest() 27 function runTest()
19 { 28 {
20 var node; 29 context.startRendering().then(successCallback, errorCallback);
30 }
21 31
22 try { 32 function createOfflineContext()
23 node = context.createScriptProcessor(bufferSize, 0, 1); 33 {
24 testPassed("Successfully created ScriptProcessorNode."); 34 var sampleRate = 44100.0;
25 } catch (e) { 35 var renderLengthInFrames = 512;
26 testFailed("Failed to create ScriptProcessorNode."); 36 var bufferSize = 512;
27 }
28 37
38 context = new w.OfflineAudioContext(1, renderLengthInFrames, sampleRate);
39 var node = context.createScriptProcessor(bufferSize, 0, 1);
29 var source = context.createBufferSource(); 40 var source = context.createBufferSource();
30 source.buffer = createImpulseBuffer(context, bufferSize); 41 source.buffer = createImpulseBuffer(context, bufferSize);
31
32 node.onaudioprocess = function(e) { }; 42 node.onaudioprocess = function(e) { };
33 source.connect(node); 43 source.connect(node);
34 node.connect(context.destination); 44 node.connect(context.destination);
35 source.start(0); 45 source.start(0);
36
37 context.startRendering();
38 } 46 }
39 47
40 var w; 48 var w;
41 function processMessage(event) { 49 function processMessage(event) {
42 if (event.data == "opened") { 50 if (event.data == "opened") {
43 context = new w.OfflineAudioContext(1, renderLengthInFrames, sampleRate) ; 51 createOfflineContext();
44 w.close(); 52 w.close();
45 } else if (event.data == "closed") { 53 } else if (event.data == "closed") {
46 runTest(); 54 setTimeout(runTest, 100);
47 finishJSTest();
48 } 55 }
49 } 56 }
50 57
51 if (window.testRunner) { 58 if (window.testRunner) {
52 testRunner.dumpAsText(); 59 testRunner.dumpAsText();
53 testRunner.waitUntilDone(); 60 testRunner.waitUntilDone();
54 testRunner.setCanOpenWindows(); 61 testRunner.setCanOpenWindows();
55 } 62 }
56 63
57 w = window.open('../resources/window-postmessage-open-close.html'); 64 w = window.open('../resources/window-postmessage-open-close.html');
58 window.addEventListener("message", processMessage, false); 65 window.addEventListener("message", processMessage, false);
59 </script> 66 </script>
60 </body> 67 </body>
61 </html> 68 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/webaudio/offlineaudiocontext-detached-no-crash-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698