Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html

Issue 1416123005: Implement setSinkId() for media elements without src. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Audio Output Devices</title> 4 <title>Audio Output Devices</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 </head> 7 </head>
8 <body> 8 <body>
9 <audio id="testAudio"></audio>
10 <script> 9 <script>
11 // Tests that the setSinkId() Promise rejects with a NotSupportedError, 10 // TODO(guidou): Add more tests with nonempty src once a MockWebMediaPlaye r
12 // because the functionality has not been implemented yet. 11 // is available int the test runner. See crbug.com/546566.
13 promise_test(function() { 12
14 var audio = document.getElementById('testAudio'); 13 // Tests that the API is available.
14 test(function() {
15 var audio = document.createElement('audio');
15 assert_not_equals(audio, null); 16 assert_not_equals(audio, null);
16
17 assert_idl_attribute(audio, 'setSinkId'); 17 assert_idl_attribute(audio, 'setSinkId');
18 assert_equals(typeof audio.setSinkId, 'function'); 18 assert_equals(typeof audio.setSinkId, 'function');
19 assert_idl_attribute(audio, 'sinkId'); 19 assert_idl_attribute(audio, 'sinkId');
20 assert_equals(audio.sinkId, ''); 20 assert_equals(audio.sinkId, '');
21 }, 'Basic API test');
21 22
22 return audio.setSinkId('').then(function() { 23 // Tests that setting the sink to the default device succeeds.
23 assert_equals(audio.sinkId, ''); 24 promise_test(function() {
24 return audio.setSinkId('xxx'); 25 var audio = document.createElement('audio');
25 }, function(error) { 26 return audio.setSinkId('')
26 assert_unreached('setSinkId() should have succeeded!'); 27 }, 'setSinkId("")');
27 }). then(function() { 28
28 assert_unreached('setSinkId() should have failed!'); 29 // Tests that setting the sink to a valid device succeeds.
29 }, function(error) { 30 // Note: 'valid' is the name of a valid device in the test runner.
30 assert_equals(audio.sinkId, ''); 31 promise_test(function() {
31 return Promise.resolve(); 32 var audio = document.createElement('audio');
32 }) 33 var p = audio.setSinkId('valid')
33 }, 'setSinkId() test'); 34 .then(function() {
35 assert_equals(audio.sinkId, 'valid');
36 });
37 assert_equals(audio.sinkId, ''); // sinkId not updated yet
38 return p;
39 }, 'setSinkId("valid")');
40
41 // Test that changing the src on an element and calling setSinkId() works
42 promise_test(function() {
43 var audio = document.createElement('audio');
44 audio.src = '../content/test.oga';
45 return audio.setSinkId('');
46
47 }, 'change src, then setSinkId("")');
48
49 // Tests that setting the sink to an unauthorized device fails.
50 // Note: 'unauthorized' is the name of an unauthorized device in the test runner.
51 promise_test(function() {
52 var audio = document.createElement('audio');
53 return promise_rejects(this, 'SecurityError', audio.setSinkId('unauthori zed'));
54 }, 'setSinkId("unauthorized")' );
55
56 // Test that setting the sink to a nonexistent device fails
57 promise_test(function() {
58 var audio = document.createElement('audio');
59 return promise_rejects(this, 'NotFoundError', audio.setSinkId('nonexiste nt'));
60 }, 'setSinkId("nonexistent")');
61
62 // Tests that changing the sink twice succeeds
63 promise_test(function() {
64 var audio = document.createElement('audio');
65 return audio.setSinkId('valid')
66 .then(function() {
67 assert_equals(audio.sinkId, 'valid');
68 return audio.setSinkId('')
69 .then(function() {
70 assert_equals(audio.sinkId, '');
71 });
72 });
73 }, 'setSinkId("valid") followed by setSinkId("").');
74
34 </script> 75 </script>
35 </body> 76 </body>
36 </html> 77 </html>
37
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698