Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
| diff --git a/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html b/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
| index 204ff8f7ec920364a0030471f7b6bf36d6e571df..8ef8f8ddb0ce72026d36e4d470ef021479ed6e61 100644 |
| --- a/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
| +++ b/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
| @@ -6,32 +6,71 @@ |
| <script src="../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| - <audio id="testAudio"></audio> |
| <script> |
| - // Tests that the setSinkId() Promise rejects with a NotSupportedError, |
| - // because the functionality has not been implemented yet. |
| - promise_test(function() { |
| - var audio = document.getElementById('testAudio'); |
| + // Tests that the API is available. |
| + test(function() { |
| + var audio = document.createElement('audio'); |
| assert_not_equals(audio, null); |
| - |
| assert_idl_attribute(audio, 'setSinkId'); |
| assert_equals(typeof audio.setSinkId, 'function'); |
| assert_idl_attribute(audio, 'sinkId'); |
| assert_equals(audio.sinkId, ''); |
| + }, 'Basic API test'); |
| + |
| + // Tests that setting the sink to the default device succeeds. |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + return audio.setSinkId('') |
| + }, 'setSinkId("")'); |
| + |
| + // Tests that setting the sink to a valid device succeeds. |
| + // Note: 'valid' is the name of a valid device in the test runner. |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + var p = audio.setSinkId('valid') |
| + .then(function() { |
| + assert_equals(audio.sinkId, 'valid'); |
| + return Promise.resolve(); |
|
Peter Beverloo
2015/11/12 16:45:42
nit: no need, that propagates automagically.
Guido Urdaneta
2015/11/12 18:45:44
Done.
|
| + }); |
| + assert_equals(audio.sinkId, ''); // sinkId not updated yet |
| + return p; |
| + }, 'setSinkId("valid")'); |
| + |
| + // Test that changing the src on an element and calling setSinkId() works |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + audio.src = '../content/test.oga'; |
| + return audio.setSinkId(''); |
| + |
| + }, 'change src, then setSinkId("")'); |
| + |
| + // Tests that setting the sink to an unauthorized device fails. |
| + // Note: 'unauthorized' is the name of an unauthorized device in the test runner. |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + return promise_rejects(this, 'SecurityError', audio.setSinkId('unauthorized')); |
| + }, 'setSinkId("unauthorized")' ); |
| + |
| + // Test that setting the sink to a nonexistent device fails |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + return promise_rejects(this, 'NotFoundError', audio.setSinkId('nonexistent')); |
| + }, 'setSinkId("nonexistent")'); |
| + |
| + // Tests that changing the sink twice succeeds |
| + promise_test(function() { |
| + var audio = document.createElement('audio'); |
| + return audio.setSinkId('valid') |
| + .then(function() { |
| + assert_equals(audio.sinkId, 'valid'); |
| + return audio.setSinkId('') |
| + .then(function() { |
| + assert_equals(audio.sinkId, ''); |
| + return Promise.resolve(); |
|
Peter Beverloo
2015/11/12 16:45:42
dito
Guido Urdaneta
2015/11/12 18:45:44
Done.
|
| + }); |
| + }); |
| + }, 'setSinkId("valid") followed by setSinkId("").'); |
|
Peter Beverloo
2015/11/12 16:45:42
q: have you tested the behaviour of:
let element
Guido Urdaneta
2015/11/12 18:45:44
I've tested it manually and it works as expected.
|
| - return audio.setSinkId('').then(function() { |
| - assert_equals(audio.sinkId, ''); |
| - return audio.setSinkId('xxx'); |
| - }, function(error) { |
| - assert_unreached('setSinkId() should have succeeded!'); |
| - }). then(function() { |
| - assert_unreached('setSinkId() should have failed!'); |
| - }, function(error) { |
| - assert_equals(audio.sinkId, ''); |
| - return Promise.resolve(); |
| - }) |
| - }, 'setSinkId() test'); |
| </script> |
| </body> |
| </html> |
| - |