| OLD | NEW |
| 1 <!doctype html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title> |
| 5 Test Neutering by decodeAudioData |
| 6 </title> |
| 4 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit.js"></script> | 9 <script src="../resources/audit.js"></script> |
| 7 <title>Test Neutering by decodeAudioData </title> | |
| 8 </head> | 10 </head> |
| 9 | |
| 10 <body> | 11 <body> |
| 11 <script> | 12 <script id="layout-test-code"> |
| 12 // Any valid rate will do. Just need something to create an offline | 13 // Any valid rate will do. Just need something to create an offline |
| 13 // context. | 14 // context. |
| 14 let sampleRate = 44100; | 15 let sampleRate = 44100; |
| 15 | 16 |
| 16 let audit = Audit.createTaskRunner(); | 17 let audit = Audit.createTaskRunner(); |
| 17 | 18 |
| 18 // Context to use for decodeAudioData | 19 // Context to use for decodeAudioData |
| 19 let context; | 20 let context; |
| 20 // The encoded audio file that we want to decode. | 21 // The encoded audio file that we want to decode. |
| 21 let encodedAudio; | 22 let encodedAudio; |
| 22 | 23 |
| 23 audit.define('initialize', (task, should) => { | 24 audit.define('initialize', (task, should) => { |
| 24 // Create the context and load up any valid encoded audio file. | 25 // Create the context and load up any valid encoded audio file. |
| 25 should(() => { | 26 should(() => { |
| 26 context = new OfflineAudioContext(1, 1, sampleRate); | 27 context = new OfflineAudioContext(1, 1, sampleRate); |
| 27 }, 'Context creation').notThrow(); | 28 }, 'Context creation').notThrow(); |
| 28 | 29 |
| 29 Audit.loadFileFromUrl( | 30 Audit.loadFileFromUrl('../resources/hyper-reality/laughter.wav') |
| 30 '../resources/hyper-reality/laughter.wav') | |
| 31 .then(response => { | 31 .then(response => { |
| 32 encodedAudio = response; | 32 encodedAudio = response; |
| 33 should(true, 'Loading of encoded audio file') | 33 should(true, 'Loading of encoded audio file') |
| 34 .message('succeeded', 'failed'); | 34 .message('succeeded', 'failed'); |
| 35 }) | 35 }) |
| 36 .then(() => task.done()); | 36 .then(() => task.done()); |
| 37 }); | 37 }); |
| 38 | 38 |
| 39 audit.define('decode-audio-neuters', (task, should) => { | 39 audit.define('decode-audio-neuters', (task, should) => { |
| 40 // Decode the audio file and verify that it neuters the array, so that | 40 // Decode the audio file and verify that it neuters the array, so that |
| 41 // it can't be transfered somewhere else. | 41 // it can't be transfered somewhere else. |
| 42 p = context.decodeAudioData(encodedAudio); | 42 p = context.decodeAudioData(encodedAudio); |
| 43 should(() => { | 43 should(() => { |
| 44 postMessage('', '*', [encodedAudio]); | 44 postMessage('', '*', [encodedAudio]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 // Now buffer and view should be neutered. | 72 // Now buffer and view should be neutered. |
| 73 should(buffer.byteLength, 'buffer.byteLength').beEqualTo(0); | 73 should(buffer.byteLength, 'buffer.byteLength').beEqualTo(0); |
| 74 should(view.length, 'view.length').beEqualTo(0); | 74 should(view.length, 'view.length').beEqualTo(0); |
| 75 task.done(); | 75 task.done(); |
| 76 }); | 76 }); |
| 77 | 77 |
| 78 audit.run(); | 78 audit.run(); |
| 79 </script> | 79 </script> |
| 80 </body> | 80 </body> |
| 81 </html> | 81 </html> |
| OLD | NEW |