| 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/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 8 <script src="../resources/audit.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Multiple calls to resume should not be a problem. But we can't test | 72 // Multiple calls to resume should not be a problem. But we can't test |
| 73 // that on an offline context. Thus, check that resume() on an | 73 // that on an offline context. Thus, check that resume() on an |
| 74 // OfflineAudioContext rejects the promise. | 74 // OfflineAudioContext rejects the promise. |
| 75 should(() => p2 = offlineContext.resume(), | 75 should(() => p2 = offlineContext.resume(), |
| 76 "p2 = offlineContext.resume()") | 76 "p2 = offlineContext.resume()") |
| 77 .notThrow(); | 77 .notThrow(); |
| 78 should(p2 instanceof Promise, "p2 instanceof Promise") | 78 should(p2 instanceof Promise, "p2 instanceof Promise") |
| 79 .beTrue(); | 79 .beTrue(); |
| 80 | 80 |
| 81 // Resume doesn't actually resume an offline context | 81 // Resume doesn't actually resume an offline context |
| 82 should(offlineContext.state, "offlineContext.state") | 82 should(offlineContext.state, "After resume, offlineContext.state") |
| 83 .beEqualTo("suspended"); | 83 .beEqualTo("suspended"); |
| 84 should(p2, "p2") | 84 should(p2, "p2") |
| 85 .beRejected() | 85 .beRejected() |
| 86 .then(task.done.bind(task)); | 86 .then(task.done.bind(task)); |
| 87 }); | 87 }); |
| 88 | 88 |
| 89 // Task: test the state after context closed. | 89 // Task: test the state after context closed. |
| 90 audit.define({ | 90 audit.define({ |
| 91 label: 'test-after-close', | 91 label: 'test-after-close', |
| 92 description: "Test state after context closed" | 92 description: "Test state after context closed" |
| 93 }, function (task, should) { | 93 }, function (task, should) { |
| 94 // Render the offline context. | 94 // Render the offline context. |
| 95 osc.start(); | 95 osc.start(); |
| 96 | 96 |
| 97 // Test suspend/resume in tested promise pattern. We don't care about the | 97 // Test suspend/resume in tested promise pattern. We don't care about the |
| 98 // actual result of the offline rendering. | 98 // actual result of the offline rendering. |
| 99 should(() => p3 = offlineContext.startRendering(), | 99 should(() => p3 = offlineContext.startRendering(), |
| 100 "p3 = offlineContext.startRendering()") | 100 "p3 = offlineContext.startRendering()") |
| 101 .notThrow(); | 101 .notThrow(); |
| 102 | 102 |
| 103 p3.then(() => { | 103 p3.then(() => { |
| 104 should(offlineContext.state, "offlineContext.state") | 104 should(offlineContext.state, "After close, offlineContext.state") |
| 105 .beEqualTo("closed"); | 105 .beEqualTo("closed"); |
| 106 | 106 |
| 107 // suspend() should be rejected on a closed context. | 107 // suspend() should be rejected on a closed context. |
| 108 should(offlineContext.suspend(), "offlineContext.suspend()") | 108 should(offlineContext.suspend(), "offlineContext.suspend()") |
| 109 .beRejected() | 109 .beRejected() |
| 110 .then(() => { | 110 .then(() => { |
| 111 // resume() should be rejected on closed context. | 111 // resume() should be rejected on closed context. |
| 112 should(offlineContext.resume(), | 112 should(offlineContext.resume(), |
| 113 "offlineContext.resume()") | 113 "offlineContext.resume()") |
| 114 .beRejected() | 114 .beRejected() |
| 115 .then(task.done.bind(task)); | 115 .then(task.done.bind(task)); |
| 116 }) | 116 }) |
| 117 }); | 117 }); |
| 118 }); | 118 }); |
| 119 | 119 |
| 120 audit.run(); | 120 audit.run(); |
| 121 </script> | 121 </script> |
| 122 </body> | 122 </body> |
| 123 </html> | 123 </html> |
| OLD | NEW |