setactionhandler.html (971B)
1 <!DOCTYPE html> 2 <title>Test that setting MediaSession event handler should notify the service</title> 3 <link rel="help" href="https://w3c.github.io/mediasession/#media-session-action" /> 4 <script src=/resources/testharness.js></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script> 7 8 [ 9 "play", 10 "pause", 11 "previoustrack", 12 "nexttrack", 13 "seekbackward", 14 "seekforward", 15 "stop", 16 "seekto", 17 "skipad", 18 "togglemicrophone", 19 "togglecamera", 20 "togglescreenshare", 21 "hangup", 22 "previousslide", 23 "nextslide", 24 "enterpictureinpicture", 25 "voiceactivity" 26 ].forEach((action) => 27 test((t) => { 28 window.navigator.mediaSession.setActionHandler(action, null); 29 }, `Test that setActionHandler("${action}") succeeds`) 30 ); 31 32 test(function(t) { 33 assert_throws_js( 34 TypeError, 35 _ => { window.navigator.mediaSession.setActionHandler("invalid", null); }); 36 }, "Test that setActionHandler() throws exception for unsupported actions"); 37 38 </script>