OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>MediaSession Mojo Test</title> |
| 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <script src="../../../resources/mojo-helpers.js"></script> |
| 6 <script src="resources/mediasessionservice-mock.js"></script> |
| 7 <script src="resources/utils.js"></script> |
| 8 <script> |
| 9 |
| 10 var inputStates = ["none", "paused", "playing", "invalid", "none"]; |
| 11 var expectations; |
| 12 var nextExpectation = 0; |
| 13 |
| 14 // Delay the initialization since the initialization of MediaSessionPlaybackStat
e is delayed. |
| 15 function getExpectations() { |
| 16 if (!expectations) { |
| 17 expectations = [ |
| 18 MediaSessionPlaybackState.NONE, |
| 19 MediaSessionPlaybackState.PAUSED, |
| 20 MediaSessionPlaybackState.PLAYING, |
| 21 MediaSessionPlaybackState.NONE, |
| 22 ]; |
| 23 } |
| 24 return expectations; |
| 25 } |
| 26 |
| 27 async_test(function(t) { |
| 28 mediaSessionServiceMock.then(m => { |
| 29 m.setPlaybackStateCallback(t.step_func(function(state) { |
| 30 assert_equals(state, getExpectations()[nextExpectation++]); |
| 31 if (nextExpectation == getExpectations().length) |
| 32 t.done(); |
| 33 })); |
| 34 for (let state of inputStates) |
| 35 window.navigator.mediaSession.playbackState = state; |
| 36 }); |
| 37 }, "test that MediaSession.playbackState is correctly propagated"); |
| 38 |
| 39 </script> |
OLD | NEW |