OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test AudioContextOptions</title> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
| 7 <script src="resources/audio-testing.js"></script> |
| 8 </head> |
| 9 |
| 10 <body> |
| 11 <script> |
| 12 var context; |
| 13 var audit = Audit.createTaskRunner(); |
| 14 |
| 15 // Task: test AudioContextOptions (1). |
| 16 audit.defineTask('test-audiocontextoptions-1', function (done) { |
| 17 |
| 18 // Verify that an AudioContext can be created with default options. |
| 19 Should("context = new AudioContext()", function () { |
| 20 context = new AudioContext(); |
| 21 }).notThrow(); |
| 22 |
| 23 var defaultLatency = context.baseLatency; |
| 24 Should("default baseLatency > 0", defaultLatency).beGreaterThan(0); |
| 25 |
| 26 // Verify that an AudioContext can be created with the expected latency ty
pes. |
| 27 Should("context = new AudioContext({'latencyHint': 'interactive'})", funct
ion () { |
| 28 context = new AudioContext({'latencyHint': 'interactive'}); |
| 29 }).notThrow(); |
| 30 |
| 31 var interactiveLatency = context.baseLatency; |
| 32 Should("interactive baseLatency == default baseLatency", interactiveLatenc
y).beEqualTo(defaultLatency); |
| 33 |
| 34 Should("context = new AudioContext({'latencyHint': 'balanced'})", function
() { |
| 35 context = new AudioContext({'latencyHint': 'balanced'}); |
| 36 }).notThrow(); |
| 37 |
| 38 var balancedLatency = context.baseLatency; |
| 39 Should("balanced baseLatency >= interactive baseLatency", balancedLatency)
.beGreaterThanOrEqualTo(interactiveLatency); |
| 40 |
| 41 Should("context = new AudioContext({'latencyHint': 'playback'})", function
() { |
| 42 context = new AudioContext({'latencyHint': 'playback'}); |
| 43 }).notThrow(); |
| 44 |
| 45 var playbackLatency = context.baseLatency; |
| 46 Should("playback baseLatency >= balanced baseLatency", playbackLatency).be
GreaterThanOrEqualTo(balancedLatency); |
| 47 |
| 48 // Verify that invalid latencyHint values are rejected. |
| 49 Should("context = new AudioContext({'latencyHint': 'foo'})", function () { |
| 50 context = new AudioContext({'latencyHint': 'foo'}); |
| 51 }).throw(); |
| 52 |
| 53 // Verify that no extra options can be passed into the AudioContextOptions
. |
| 54 Should("context = new AudioContext('latencyHint')", function () { |
| 55 context = new AudioContext('latencyHint'); |
| 56 }).throw(); |
| 57 |
| 58 done(); |
| 59 }); |
| 60 |
| 61 audit.runTasks(); |
| 62 </script> |
| 63 </body> |
| 64 </html> |
OLD | NEW |