diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/mediasession/test/test_trigger_actionhanlder.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/mediasession/test/test_trigger_actionhanlder.html')
-rw-r--r-- | dom/media/mediasession/test/test_trigger_actionhanlder.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/media/mediasession/test/test_trigger_actionhanlder.html b/dom/media/mediasession/test/test_trigger_actionhanlder.html new file mode 100644 index 0000000000..72e8eaf7b5 --- /dev/null +++ b/dom/media/mediasession/test/test_trigger_actionhanlder.html @@ -0,0 +1,57 @@ +<!DOCTYPE HTML> +<html> + <head> + <title>Test of triggering media session's action handlers</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script src="MediaSessionTestUtils.js"></script> + </head> +<body> +<script> +/** + * This test is used to test if pressing media control keys can trigger media + * session's corresponding action handler under different situations. + */ +const testCases = [ + { + name: "Triggering action handlers for session created in [main-frame]", + shouldCreateFrom: "main-frame", + }, + { + name: "Triggering action handlers for session created in [same-origin] [child-frame]", + shouldCreateFrom: "child-frame", + origin: "same-origin", + }, + { + name: "Triggering action handlers for session created in [cross-origin] [child-frame]", + shouldCreateFrom: "child-frame", + origin: "cross-origin", + }, +]; + +SimpleTest.waitForExplicitFinish(); + +SpecialPowers.pushPrefEnv({"set": [ + ["dom.media.mediasession.enabled", true], + ["media.mediacontrol.testingevents.enabled", true], +]}, startTest()); + +async function startTest() { + for (const testCase of testCases) { + info(`- loading test '${testCase.name}' in a new window -`); + const testURL = "file_trigger_actionhanlder_window.html"; + const testWindow = window.open(testURL, "", "width=500,height=500"); + await new Promise(r => testWindow.onload = r); + + info("- start running test -"); + testWindow.postMessage(testCase, window.origin); + is((await nextWindowMessage()).data, "success", + `- finished test '${testCase.name}' -`); + testWindow.close(); + } + SimpleTest.finish(); +} + +</script> +</body> +</html> |