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 /browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js | |
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 'browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js')
-rw-r--r-- | browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js b/browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js new file mode 100644 index 0000000000..0babb8b35e --- /dev/null +++ b/browser/base/content/test/fullscreen/browser_fullscreen_cross_origin.js @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const ORIGIN = + "https://example.com/browser/browser/base/content/test/fullscreen/fullscreen_frame.html"; + +add_task(async function test_fullscreen_cross_origin() { + async function requestFullscreen(aAllow, aExpect) { + await BrowserTestUtils.withNewTab(ORIGIN, async function (browser) { + const iframeId = aExpect == "allowed" ? "frameAllowed" : "frameDenied"; + + info("Start fullscreen on iframe " + iframeId); + await SpecialPowers.spawn( + browser, + [{ aExpect, iframeId }], + async function (args) { + let frame = content.document.getElementById(args.iframeId); + frame.focus(); + await SpecialPowers.spawn(frame, [args.aExpect], async expect => { + let frameDoc = content.document; + const waitForFullscreen = new Promise(resolve => { + const message = + expect == "allowed" ? "fullscreenchange" : "fullscreenerror"; + function handler(evt) { + frameDoc.removeEventListener(message, handler); + Assert.equal(evt.type, message, `Request should be ${expect}`); + frameDoc.exitFullscreen(); + resolve(); + } + frameDoc.addEventListener(message, handler); + }); + frameDoc.getElementById("request").click(); + await waitForFullscreen; + }); + } + ); + + if (aExpect == "allowed") { + waitForFullScreenState(browser, false); + } + }); + } + + await new Promise(r => { + SpecialPowers.pushPrefEnv( + { + set: [ + ["full-screen-api.enabled", true], + ["full-screen-api.allow-trusted-requests-only", false], + ["full-screen-api.transition-duration.enter", "0 0"], + ["full-screen-api.transition-duration.leave", "0 0"], + ["dom.security.featurePolicy.header.enabled", true], + ["dom.security.featurePolicy.webidl.enabled", true], + ], + }, + r + ); + }); + + await requestFullscreen(undefined, "denied"); + await requestFullscreen("fullscreen", "allowed"); +}); |