OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>HTMLMediaElement set session</title> | 2 <title>HTMLMediaElement set session</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script> | 5 <script> |
6 test(function() { | 6 test(function() { |
7 assert_true(!window.internals || window.internals.runtimeFlags.mediaSessio
nEnabled, | 7 assert_true(!window.internals || window.internals.runtimeFlags.mediaSessio
nEnabled, |
8 "Run either manually by passing the MediaSession flag or as part of th
e virtual mediasession testsuite."); | 8 "Run either manually by passing the MediaSession flag or as part of th
e virtual mediasession testsuite."); |
9 console.warn("dummy log entry to avoid an empty -expected.txt in virtual/"
); | 9 console.warn("dummy log entry to avoid an empty -expected.txt in virtual/"
); |
| 10 }, "Setup"); |
10 | 11 |
| 12 test(function() { |
11 var mediaElement = document.createElement('audio'); | 13 var mediaElement = document.createElement('audio'); |
12 assert_true(mediaElement instanceof HTMLMediaElement); | 14 assert_true(mediaElement instanceof HTMLMediaElement); |
13 | 15 |
14 var mediaSession = new MediaSession(); | 16 var mediaSession = new MediaSession(); |
| 17 assert_equals(mediaElement.networkState, HTMLMediaElement.NETWORK_EMPTY); |
15 mediaElement.session = mediaSession; | 18 mediaElement.session = mediaSession; |
16 assert_equals(mediaElement.session, mediaSession); | 19 assert_equals(mediaElement.session, mediaSession); |
17 | 20 |
18 assert_throws(new TypeError, function() { mediaElement.session = document;
}); | 21 assert_throws(new TypeError, function() { mediaElement.session = document;
}); |
19 assert_throws(new TypeError, function() { mediaElement.session = "string";
}); | 22 assert_throws(new TypeError, function() { mediaElement.session = "string";
}); |
20 assert_throws(new TypeError, function() { mediaElement.session = 42; }); | 23 assert_throws(new TypeError, function() { mediaElement.session = 42; }); |
21 assert_equals(mediaElement.session, mediaSession); | 24 assert_equals(mediaElement.session, mediaSession); |
22 | 25 |
23 mediaElement.session = null; | 26 mediaElement.session = null; |
24 assert_equals(mediaElement.session, null); | 27 assert_equals(mediaElement.session, null); |
25 }); | 28 }, "Set HTMLMediaElement session when networkState is NETWORK_EMPTY"); |
| 29 |
| 30 test(function() { |
| 31 var mediaElement = document.createElement('audio'); |
| 32 var mediaSession = new MediaSession(); |
| 33 mediaElement.appendChild(document.createElement('source')); |
| 34 assert_equals(mediaElement.networkState, HTMLMediaElement.NETWORK_NO_SOURC
E); |
| 35 mediaElement.session = mediaSession; |
| 36 assert_equals(mediaElement.session, mediaSession); |
| 37 }, "Set HTMLMediaElement session when networkState is NETWORK_NO_SOURCE"); |
| 38 |
| 39 async_test(function(t) { |
| 40 var mediaElement = document.createElement('audio'); |
| 41 mediaElement.onloadeddata = t.step_func(function () { |
| 42 assert_true(mediaElement.networkState == HTMLMediaElement.NETWORK_IDLE |
| 43 || mediaElement.networkState == HTMLMediaElement.NETWORK_L
OADING); |
| 44 assert_throws("InvalidStateError", function() { mediaElement.session =
new MediaSession(); }); |
| 45 t.done(); |
| 46 }); |
| 47 mediaElement.src = '../resources/test-live.webm'; |
| 48 }, "Set HTMLMediaElement session during or after load"); |
26 </script> | 49 </script> |
OLD | NEW |