| 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..7796ebe02e46ff2e1f82435b7df48638f38b1633
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/audio_output_devices/setsinkid.html
|
| @@ -0,0 +1,92 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| + <head>
|
| + <title>Audio Output Devices</title>
|
| + <script src="../../resources/testharness.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| + </head>
|
| + <body>
|
| + <audio id="testAudio" src="../resources/media-source/webm/test-a-128k-44100Hz-1ch.webm"></audio>
|
| + <script>
|
| + var audio = document.getElementById('testAudio');
|
| +
|
| + // Tests that the API is available.
|
| + test(function() {
|
| + 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() {
|
| + return audio.setSinkId('')
|
| + .then(function() {
|
| + // do nothing
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded');
|
| + });
|
| + }, 'setSinkId("")');
|
| +
|
| + // Tests that setting the sink to a valid device without permission fails
|
| + // Note: 'default' is the hashed name Chrome 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() {
|
| + return audio.setSinkId('default')
|
| + .then(function() {
|
| + assert_unreached('setSinkId() should have failed');
|
| + }).catch(function(error) {
|
| + assert_equals(error.name, 'SecurityError');
|
| + return Promise.resolve();
|
| + });
|
| + }, 'setSinkId("default") without permission' );
|
| +
|
| + // Test that setting the sink to an invalid device fails
|
| + promise_test(function() {
|
| + return audio.setSinkId('invalid')
|
| + .then(function() {
|
| + assert_unreached('setSinkId() should have failed');
|
| + }).catch(function(error) {
|
| + assert_equals(error.name, 'NotFoundError');
|
| + return Promise.resolve();
|
| + });
|
| + }, 'setSinkId("invalid")');
|
| +
|
| + // Test that setting the sink on an element without src succeeds
|
| + promise_test(function() {
|
| + audio.src=""
|
| + return audio.setSinkId('')
|
| + .then(function() {
|
| + // do nothing
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded');
|
| + });
|
| + }, 'empty src setSinkId("")');
|
| +
|
| + // Test that setting the src of an element, and then changing the sink
|
| + // both succeed.
|
| + promise_test(function() {
|
| + audio.src="../resources/media-source/webm/test-a-192k-44100Hz-1ch.webm"
|
| + return audio.setSinkId('')
|
| + .then(function() {
|
| + // do nothing
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded');
|
| + });
|
| + }, 'new src setSinkId("")');
|
| +
|
| + // Tests that setting the sink to the default device a second time succeeds
|
| + promise_test(function() {
|
| + return audio.setSinkId('')
|
| + .then(function() {
|
| + // do nothing
|
| + }).catch(function() {
|
| + assert_unreached('setSinkId() should have succeeded');
|
| + });
|
| + }, 'setSinkId("") 2');
|
| + </script>
|
| +</body>
|
| +</html>
|
| +
|
|
|