OLD | NEW |
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 Loading... |
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"); |
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 === "InvalidAccessError") { |
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 Inva
lidAccessError, 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 === "InvalidAccessError") { |
87 testPassed( | 87 testPassed( |
88 "offlineContext.resume() was correctly rejected: " + e); | 88 "offlineContext.resume() was correctly rejected: " + e); |
89 } else { | 89 } else { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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> |
OLD | NEW |