playbackstate.html (911B)
1 <!DOCTYPE html> 2 <title>MediaSession.playbackState attribute</title> 3 <script src=/resources/testharness.js></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script> 6 7 test(function() { 8 assert_equals(window.navigator.mediaSession.playbackState, "none"); 9 }, 'Test that playbackState is initialized as "none"'); 10 11 test(function() { 12 var states = [ "paused", "playing", "none" ]; 13 for (let state of states) { 14 window.navigator.mediaSession.playbackState = state; 15 assert_equals(window.navigator.mediaSession.playbackState, state); 16 } 17 }, 'Test that playbackState is read/write'); 18 19 test(function() { 20 var invalidStates = [ "invalid", "" ]; 21 for (let state of invalidStates) { 22 window.navigator.mediaSession.playbackState = state; 23 assert_equals(window.navigator.mediaSession.playbackState, "none"); 24 } 25 }, 'Test that warning is thrown when setting invalid playbackState'); 26 27 </script>