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

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 // Tests that the API is available.
12 // because the functionality has not been implemented yet. 11 test(function() {
13 promise_test(function() { 12 var audio = document.createElement('audio');
14 var audio = document.getElementById('testAudio');
15 assert_not_equals(audio, null); 13 assert_not_equals(audio, null);
16
17 assert_idl_attribute(audio, 'setSinkId'); 14 assert_idl_attribute(audio, 'setSinkId');
18 assert_equals(typeof audio.setSinkId, 'function'); 15 assert_equals(typeof audio.setSinkId, 'function');
19 assert_idl_attribute(audio, 'sinkId'); 16 assert_idl_attribute(audio, 'sinkId');
20 assert_equals(audio.sinkId, ''); 17 assert_equals(audio.sinkId, '');
18 }, 'Basic API test');
21 19
22 return audio.setSinkId('').then(function() { 20 // Tests that setting the sink to the default device succeeds.
23 assert_equals(audio.sinkId, ''); 21 promise_test(function() {
24 return audio.setSinkId('xxx'); 22 var audio = document.createElement('audio');
25 }, function(error) { 23 return audio.setSinkId('')
26 assert_unreached('setSinkId() should have succeeded!'); 24 }, 'setSinkId("")');
27 }). then(function() { 25
28 assert_unreached('setSinkId() should have failed!'); 26 // Tests that setting the sink to a valid device succeeds.
29 }, function(error) { 27 // Note: 'valid' is the name of a valid device in the test runner.
30 assert_equals(audio.sinkId, ''); 28 promise_test(function() {
31 return Promise.resolve(); 29 var audio = document.createElement('audio');
32 }) 30 var p = audio.setSinkId('valid')
33 }, 'setSinkId() test'); 31 .then(function() {
32 assert_equals(audio.sinkId, 'valid');
33 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.
34 });
35 assert_equals(audio.sinkId, ''); // sinkId not updated yet
36 return p;
37 }, 'setSinkId("valid")');
38
39 // Test that changing the src on an element and calling setSinkId() works
40 promise_test(function() {
41 var audio = document.createElement('audio');
42 audio.src = '../content/test.oga';
43 return audio.setSinkId('');
44
45 }, 'change src, then setSinkId("")');
46
47 // Tests that setting the sink to an unauthorized device fails.
48 // Note: 'unauthorized' is the name of an unauthorized device in the test runner.
49 promise_test(function() {
50 var audio = document.createElement('audio');
51 return promise_rejects(this, 'SecurityError', audio.setSinkId('unauthori zed'));
52 }, 'setSinkId("unauthorized")' );
53
54 // Test that setting the sink to a nonexistent device fails
55 promise_test(function() {
56 var audio = document.createElement('audio');
57 return promise_rejects(this, 'NotFoundError', audio.setSinkId('nonexiste nt'));
58 }, 'setSinkId("nonexistent")');
59
60 // Tests that changing the sink twice succeeds
61 promise_test(function() {
62 var audio = document.createElement('audio');
63 return audio.setSinkId('valid')
64 .then(function() {
65 assert_equals(audio.sinkId, 'valid');
66 return audio.setSinkId('')
67 .then(function() {
68 assert_equals(audio.sinkId, '');
69 return Promise.resolve();
Peter Beverloo 2015/11/12 16:45:42 dito
Guido Urdaneta 2015/11/12 18:45:44 Done.
70 });
71 });
72 }, '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.
73
34 </script> 74 </script>
35 </body> 75 </body>
36 </html> 76 </html>
37
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698