| Index: third_party/WebKit/LayoutTests/http/tests/media/audio_output_devices/setsinkid.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/audio_output_devices/setsinkid.html b/third_party/WebKit/LayoutTests/http/tests/media/audio_output_devices/setsinkid.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f8d5fc564df9a86470464cb2170fc497a01f992e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/audio_output_devices/setsinkid.html
|
| @@ -0,0 +1,74 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| + <head>
|
| + <title>Audio Output Devices</title>
|
| + <script src="../../resources/testharness.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| + </head>
|
| + <body>
|
| + <script>
|
| + // 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 on an element with src succeeds.
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + audio.src = '../resources/media-source/webm/test-a-128k-44100Hz-1ch.webm';
|
| + return audio.setSinkId('')
|
| + }, 'setSinkId("")');
|
| +
|
| + // Test that setting the sink on an element without src succeeds.
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + return audio.setSinkId('');
|
| + }, 'empty src setSinkId("")');
|
| +
|
| + // Tests that setting the sink to a valid device without permission fails.
|
| + // Note: 'default' is the hashed name Chromium always provides for the default device.
|
| + // It is treated like any other hashed device ID, so it is not automatically authorized like ''.
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + return promise_rejects(this, 'SecurityError', audio.setSinkId('default'));
|
| + }, 'setSinkId("default") without permission' );
|
| +
|
| + // Test that setting the sink to an invalid device fails
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + return promise_rejects(this, 'NotFoundError', audio.setSinkId('invalid'));
|
| + }, 'setSinkId("invalid")');
|
| +
|
| + // Tests that setting the sink to the default device a second time succeeds
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + audio.setSinkId('')
|
| + .then(function() {
|
| + return audio.setSinkId('');
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded.');
|
| + });
|
| + }, 'setSinkId("") twice.');
|
| +
|
| + // Test that changing the src of an element with a previous src and setting the sink
|
| + // in both cases succeeds.
|
| + promise_test(function() {
|
| + var audio = document.createElement('audio');
|
| + audio.src = '../resources/media-source/webm/test-a-128k-44100Hz-1ch.webm'
|
| + audio.setSinkId('')
|
| + .then(function() {
|
| + audio.src = '../resources/media-source/webm/test-a-192k-44100Hz-1ch.webm'
|
| + return audio.setSinkId('');
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded.');
|
| + });
|
| + }, 'change src setSinkId("").');
|
| +
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|