4 <title>Test of triggering media session's action handlers
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
7 <script src=
"MediaSessionTestUtils.js"></script>
12 * This test is used to test if pressing media control keys can trigger media
13 * session's corresponding action handler under different situations.
17 name
: "Triggering action handlers for session created in [main-frame]",
18 shouldCreateFrom
: "main-frame",
21 name
: "Triggering action handlers for session created in [same-origin] [child-frame]",
22 shouldCreateFrom
: "child-frame",
23 origin
: "same-origin",
26 name
: "Triggering action handlers for session created in [cross-origin] [child-frame]",
27 shouldCreateFrom
: "child-frame",
28 origin
: "cross-origin",
32 SimpleTest
.waitForExplicitFinish();
34 SpecialPowers
.pushPrefEnv({"set": [
35 ["media.mediacontrol.testingevents.enabled", true],
38 async
function startTest() {
39 for (const testCase
of testCases
) {
40 info(`- loading test '${testCase.name}' in a new window -`);
41 const testURL
= "file_trigger_actionhandler_window.html";
42 const testWindow
= window
.open(testURL
, "", "width=500,height=500");
43 await
new Promise(r
=> testWindow
.onload
= r
);
45 info("- start running test -");
46 testWindow
.postMessage(testCase
, window
.origin
);
47 is((await
nextWindowMessage()).data
, "success",
48 `- finished test '${testCase.name}' -`);