Bug 1945643 - Update to mozilla-nimbus-schemas 2025.1.1 r=chumphreys
[gecko.git] / dom / media / mediasession / test / file_trigger_actionhandler_frame.html
blob4d55db2189f047489f85142a93eb762aead6acb4
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test frame for triggering media session's action handler</title>
5 <script src="MediaSessionTestUtils.js"></script>
6 </head>
7 <body>
8 <video id="testVideo" src="gizmo.mp4" loop></video>
9 <script>
11 const video = document.getElementById("testVideo");
12 const w = window.opener || window.parent;
14 window.onmessage = async event => {
15 if (event.data == "play") {
16 await video.play();
17 // As we can't observe `media-displayed-playback-changed` notification,
18 // that can only be observed in the chrome process. Therefore, we use a
19 // workaround instead which is to wait for a while to ensure that the
20 // controller has already been created in the chrome process.
21 let timeupdatecount = 0;
22 await new Promise(r => video.ontimeupdate = () => {
23 if (++timeupdatecount == 3) {
24 video.ontimeupdate = null;
25 r();
27 });
28 w.postMessage("played", "*");
32 // Setup the action handlers which would post the result back to the main window.
33 for (const action of gMediaSessionActions) {
34 navigator.mediaSession.setActionHandler(action, () => {
35 w.postMessage(action, "*");
36 });
38 </script>
39 </body>
40 </html>