| OLD | NEW |
| 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/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 10 matching lines...) Expand all Loading... |
| 21 let audit = Audit.createTaskRunner(); | 21 let audit = Audit.createTaskRunner(); |
| 22 | 22 |
| 23 // Task: test online context (1). | 23 // Task: test online context (1). |
| 24 audit.define({ | 24 audit.define({ |
| 25 label: 'test-online-context-1', | 25 label: 'test-online-context-1', |
| 26 description: "Test online context 1" | 26 description: "Test online context 1" |
| 27 }, function (task, should) { | 27 }, function (task, should) { |
| 28 // Create a context and verify that the various states are correct and | 28 // Create a context and verify that the various states are correct and |
| 29 // that close() exists. | 29 // that close() exists. |
| 30 should(() => context = new AudioContext(), | 30 should(() => context = new AudioContext(), |
| 31 "context = new AudioContext()") | 31 "context0 = new AudioContext()") |
| 32 .notThrow(); | 32 .notThrow(); |
| 33 should(context.state, "context.state") | 33 should(context.state, "context0.state") |
| 34 .beEqualTo("running"); | 34 .beEqualTo("running"); |
| 35 | 35 |
| 36 // Create gain and oscillator for testing later. | 36 // Create gain and oscillator for testing later. |
| 37 should(() => osc = context.createOscillator(), | 37 should(() => osc = context.createOscillator(), |
| 38 "osc = context.createOscillator()") | 38 "osc = context.createOscillator()") |
| 39 .notThrow(); | 39 .notThrow(); |
| 40 should(() => gain = context.createGain(), | 40 should(() => gain = context.createGain(), |
| 41 "gain = context.createGain()") | 41 "gain = context0.createGain()") |
| 42 .notThrow(); | 42 .notThrow(); |
| 43 destination = context.destination; | 43 destination = context.destination; |
| 44 should(() => gain.connect(context.destination), | 44 should(() => gain.connect(context.destination), |
| 45 "gain.connect(context.destination)") | 45 "gain.connect(context0.destination)") |
| 46 .notThrow(); | 46 .notThrow(); |
| 47 | 47 |
| 48 // Close the context. When the promise is resolved, continue the next | 48 // Close the context. When the promise is resolved, continue the next |
| 49 // test task. | 49 // test task. |
| 50 let promise = context.close().then(() => { | 50 let promise = context.close().then(() => { |
| 51 should(() => gain.disconnect(destination), | 51 should(() => gain.disconnect(destination), |
| 52 "gain.disconnect(destination) after close") | 52 "gain.disconnect(destination) after close") |
| 53 .notThrow(); | 53 .notThrow(); |
| 54 }); | 54 }); |
| 55 should(promise, "context.close()") | 55 should(promise, "context0.close()") |
| 56 .beResolved() | 56 .beResolved() |
| 57 .then(task.done.bind(this)); | 57 .then(task.done.bind(this)); |
| 58 }); | 58 }); |
| 59 | 59 |
| 60 // Task: test online context (2). | 60 // Task: test online context (2). |
| 61 audit.define({ | 61 audit.define({ |
| 62 label: 'test-online-context-2', | 62 label: 'test-online-context-2', |
| 63 description: "Test closed online context 2" | 63 description: "Test closed online context 2" |
| 64 }, function (task, should) { | 64 }, function (task, should) { |
| 65 // Context is closed, so verify that we cannot create any more nodes, | 65 // Context is closed, so verify that we cannot create any more nodes, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 }); | 144 }); |
| 145 | 145 |
| 146 // Task: test online context (4). | 146 // Task: test online context (4). |
| 147 audit.define({ | 147 audit.define({ |
| 148 label: 'test-online-context-4', | 148 label: 'test-online-context-4', |
| 149 description: "Test closed online context 4" | 149 description: "Test closed online context 4" |
| 150 }, function (task, should) { | 150 }, function (task, should) { |
| 151 // Create a context and verify that its sampleRate and baseLatency return | 151 // Create a context and verify that its sampleRate and baseLatency return |
| 152 // valid values whether it's open or closed. | 152 // valid values whether it's open or closed. |
| 153 should(() => context = new AudioContext(), | 153 should(() => context = new AudioContext(), |
| 154 "context = new AudioContext()") | 154 "context1 = new AudioContext()") |
| 155 .notThrow(); | 155 .notThrow(); |
| 156 should(context.sampleRate, "context.sampleRate") | 156 should(context.sampleRate, "context1.sampleRate") |
| 157 .beGreaterThan("0"); | 157 .beGreaterThan("0"); |
| 158 should(context.sampleRate, "context.baseLatency") | 158 should(context.sampleRate, "context1.baseLatency") |
| 159 .beGreaterThan("0"); | 159 .beGreaterThan("0"); |
| 160 | 160 |
| 161 should(context.close(), "context.close()") | 161 should(context.close(), "context1.close()") |
| 162 .beResolved() | 162 .beResolved() |
| 163 .then(() => { | 163 .then(() => { |
| 164 should(context.sampleRate, "context.sampleRate") | 164 should(context.sampleRate, "After close, context1.sampleRate") |
| 165 .beGreaterThan("0"); | 165 .beGreaterThan("0"); |
| 166 should(context.sampleRate, "context.baseLatency") | 166 should(context.sampleRate, "After close, context1.baseLatency") |
| 167 .beGreaterThan("0"); | 167 .beGreaterThan("0"); |
| 168 }) | 168 }) |
| 169 .then(task.done.bind(task)); | 169 .then(task.done.bind(task)); |
| 170 }); | 170 }); |
| 171 | 171 |
| 172 // Task: test offline context (1). | 172 // Task: test offline context (1). |
| 173 audit.define({ | 173 audit.define({ |
| 174 label: 'test-offline-context-1', | 174 label: 'test-offline-context-1', |
| 175 description: "Test offline context" | 175 description: "Test offline context" |
| 176 }, function (task, should) { | 176 }, function (task, should) { |
| 177 // For an offline context, verify that close is not defined. | 177 // For an offline context, verify that close is not defined. |
| 178 should(() => offline = new OfflineAudioContext(1, 1000, 48000), | 178 should(() => offline = new OfflineAudioContext(1, 1000, 48000), |
| 179 "offline = new OfflineAudioContext(1, 1000, 48000)") | 179 "offline = new OfflineAudioContext(1, 1000, 48000)") |
| 180 .notThrow(); | 180 .notThrow(); |
| 181 should(offline.state, "offline.state") | 181 should(offline.state, "offline.state") |
| 182 .beEqualTo("suspended"); | 182 .beEqualTo("suspended"); |
| 183 should(offline.close, "offline.close") | 183 should(offline.close, "offline.close") |
| 184 .beEqualTo(undefined); | 184 .beEqualTo(undefined); |
| 185 task.done(); | 185 task.done(); |
| 186 }); | 186 }); |
| 187 | 187 |
| 188 audit.run(); | 188 audit.run(); |
| 189 </script> | 189 </script> |
| 190 </body> | 190 </body> |
| 191 </html> | 191 </html> |
| OLD | NEW |