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

Side by Side Diff: LayoutTests/webaudio/audiocontext-suspend-resume.html

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Restructured the resolution of suspend promise Created 5 years, 6 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-suspend-resume-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.suspend() and AudioContext.resume()</title> 4 <title>Test AudioContext.suspend() and AudioContext.resume()</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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 osc = offlineContext.createOscillator(); 46 osc = offlineContext.createOscillator();
47 osc.connect(offlineContext.destination); 47 osc.connect(offlineContext.destination);
48 48
49 // Verify the state. 49 // Verify the state.
50 shouldBeEqualToString("offlineContext.state", "suspended"); 50 shouldBeEqualToString("offlineContext.state", "suspended");
51 51
52 // Multiple calls to suspend() should not be a problem. But we can't test 52 // Multiple calls to suspend() should not be a problem. But we can't test
53 // that on an offline context. Thus, check that suspend() on an 53 // that on an offline context. Thus, check that suspend() on an
54 // OfflineAudioContext rejects the promise. 54 // OfflineAudioContext rejects the promise.
55 shouldNotThrow("p1 = offlineContext.suspend()"); 55 shouldNotThrow("p1 = offlineContext.suspend()");
56 shouldBeType("p1", "Promise"); 56 shouldBeType("p1", "Promise");
Raymond Toy 2015/06/09 22:34:59 Oh, this test was always wrong?!?
57 p1.then( 57 p1.then(
58 handlePromise(testFailed, "offlineContext.suspend() should have been rej ected for an offline context"), 58 handlePromise(testFailed, "offlineContext.suspend() should have been rej ected for an offline context"),
59 function (e) { 59 function (e) {
60 if (e.name === "InvalidAccessError") { 60 if (e.name === "TypeError") {
61 testPassed( 61 testPassed(
62 "offlineContext.suspend() was correctly rejected: " + e); 62 "offlineContext.suspend() was correctly rejected: " + e);
63 } else { 63 } else {
64 testFailed( 64 testFailed(
65 "offlineContext.suspend() was correctly rejected but expected Inva lidAccessError, not: " + e); 65 "offlineContext.suspend() was correctly rejected but expected Type Error, not: " + e);
66 } 66 }
67 } 67 }
68 ).then(done); 68 ).then(done);
69 }); 69 });
70 70
71 71
72 // Task: test resume(). 72 // Task: test resume().
73 audit.defineTask('test-resume', function (done) { 73 audit.defineTask('test-resume', function (done) {
74 74
75 // Multiple calls to resume should not be a problem. But we can't test 75 // Multiple calls to resume should not be a problem. But we can't test
76 // that on an offline context. Thus, check that resume() on an 76 // that on an offline context. Thus, check that resume() on an
77 // OfflineAudioContext rejects the promise. 77 // OfflineAudioContext rejects the promise.
78 shouldNotThrow("p2 = offlineContext.resume()"); 78 shouldNotThrow("p2 = offlineContext.resume()");
79 shouldBeType("p2", "Promise"); 79 shouldBeType("p2", "Promise");
80 80
81 // Resume doesn't actually resume an offline context 81 // Resume doesn't actually resume an offline context
82 shouldBeEqualToString("offlineContext.state", "suspended"); 82 shouldBeEqualToString("offlineContext.state", "suspended");
83 p2.then( 83 p2.then(
84 handlePromise(testFailed, "offlineContext.resume() should have been reje cted for an offline context"), 84 handlePromise(testFailed, "offlineContext.resume() should have been reje cted for an offline context"),
85 function (e) { 85 function (e) {
86 if (e.name === "InvalidAccessError") { 86 if (e.name === "InvalidStateError") {
87 testPassed( 87 testPassed(
88 "offlineContext.resume() was correctly rejected: " + e); 88 "offlineContext.resume() was correctly rejected: " + e);
89 } else { 89 } else {
90 testFailed( 90 testFailed(
91 "offlineContext.resume() was correctly rejected but expected Inval idAccessError, not: " + e); 91 "offlineContext.resume() was correctly rejected but expected Inval idStateError, not: " + e);
92 } 92 }
93 } 93 }
94 ).then(done); 94 ).then(done);
95 }); 95 });
96 96
97 // Task: test the state after context closed. 97 // Task: test the state after context closed.
98 audit.defineTask('test-after-close', function (done) { 98 audit.defineTask('test-after-close', function (done) {
99 99
100 // Render the offline context. 100 // Render the offline context.
101 osc.start(); 101 osc.start();
102 102
103 // Test suspend/resume in tested promise pattern. We don't care about the 103 // Test suspend/resume in tested promise pattern. We don't care about the
104 // actual result of the offline rendering. 104 // actual result of the offline rendering.
105 shouldNotThrow("p3 = offlineContext.startRendering()"); 105 shouldNotThrow("p3 = offlineContext.startRendering()");
106 p3.then(function () { 106 p3.then(function () {
107 shouldBeEqualToString("offlineContext.state", "closed"); 107 shouldBeEqualToString("offlineContext.state", "closed");
108 108
109 // suspend() should be rejected on a closed context. 109 // suspend() should be rejected on a closed context.
110 offlineContext.suspend().then( 110 offlineContext.suspend(1.0).then(
111 handlePromise(testFailed, "offlineContext.suspend() on a closed contex t not rejected"), 111 handlePromise(testFailed, "offlineContext.suspend() on a closed contex t not rejected"),
112 function (e) { 112 function (e) {
113 if (e.name === "InvalidAccessError") { 113 if (e.name === "InvalidStateError") {
114 testPassed("offlineContext.suspend() on a closed context rejected: " + e); 114 testPassed("offlineContext.suspend() on a closed context rejected: " + e);
115 } else { 115 } else {
116 testFailed("offlineContext.suspend() on a closed context rejected but expected InvalidAccessError, not: " + e); 116 testFailed("offlineContext.suspend() on a closed context rejected but expected InvalidStateError, not: " + e);
117 } 117 }
118 } 118 }
119 ).then(function () { 119 ).then(function () {
120 // resume() should be rejected on closed context. 120 // resume() should be rejected on closed context.
121 offlineContext.resume().then( 121 offlineContext.resume().then(
122 handlePromise(testFailed, "offlineContext.resume() on a closed conte xt not rejected"), 122 handlePromise(testFailed, "offlineContext.resume() on a closed conte xt not rejected"),
123 function (e) { 123 function (e) {
124 if (e.name === "InvalidAccessError") { 124 if (e.name === "InvalidStateError") {
125 testPassed("offlineContext.resume() on a closed context rejected : " + e); 125 testPassed("offlineContext.resume() on a closed context rejected : " + e);
126 } else { 126 } else {
127 testFailed("offlineContext.resume() on a closed context rejected but expected InvalidAccessError, not: " + e); 127 testFailed("offlineContext.resume() on a closed context rejected but expected InvalidStateError, not: " + e);
128 } 128 }
129 } 129 }
130 ).then(done); 130 ).then(done);
131 }); 131 });
132 132
133 }); 133 });
134 }); 134 });
135 135
136 audit.defineTask('finish-test', function (done) { 136 audit.defineTask('finish-test', function (done) {
137 done(); 137 done();
138 finishJSTest(); 138 finishJSTest();
139 }); 139 });
140 140
141 audit.runTasks( 141 audit.runTasks(
142 'test-suspend', 142 'test-suspend',
143 'test-resume', 143 'test-resume',
144 'test-after-close', 144 'test-after-close',
145 'finish-test' 145 'finish-test'
146 ); 146 );
147 147
148 successfullyParsed = true; 148 successfullyParsed = true;
149 </script> 149 </script>
150 </body> 150 </body>
151 </html> 151 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/webaudio/audiocontext-suspend-resume-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698