diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js')
-rw-r--r-- | toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js b/toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js new file mode 100644 index 0000000000..14dd3d1b7a --- /dev/null +++ b/toolkit/components/pictureinpicture/tests/browser_keyboardClosePIPwithESC.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * tests that the ESC key would stop the player and close the PiP player floating window + */ +add_task(async () => { + for (let videoID of ["with-controls", "no-controls"]) { + info(`Testing ${videoID} case.`); + + let playVideo = () => { + return SpecialPowers.spawn(browser, [videoID], async videoID => { + return content.document.getElementById(videoID).play(); + }); + }; + + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE); + let browser = tab.linkedBrowser; + + await playVideo(); + + let pipWin = await triggerPictureInPicture(browser, videoID); + ok(pipWin, "The Picture-in-Picture window is not there."); + ok( + !(await isVideoPaused(browser, videoID)), + "The video is paused, but should not." + ); + ok( + !pipWin.document.fullscreenElement, + "PiP should not yet be in fullscreen." + ); + + let controls = pipWin.document.getElementById("controls"); + await promiseFullscreenEntered(pipWin, async () => { + EventUtils.sendMouseEvent({ type: "dblclick" }, controls, pipWin); + }); + + Assert.equal( + pipWin.document.fullscreenElement, + pipWin.document.body, + "Double-click should have caused to enter fullscreen." + ); + + await promiseFullscreenExited(pipWin, async () => { + EventUtils.synthesizeKey("KEY_Escape", {}, pipWin); + }); + + ok( + !pipWin.document.fullscreenElement, + "ESC should have caused to leave fullscreen." + ); + ok( + !(await isVideoPaused(browser, videoID)), + "The video is paused, but should not." + ); + + // Try to close the PiP window via the ESC button, since now it is not in fullscreen anymore. + EventUtils.synthesizeKey("KEY_Escape", {}, pipWin); + + // then the PiP should have been closed + ok(pipWin.closed, "Picture-in-Picture window is not closed, but should."); + // and the video should not be playing anymore + ok( + await isVideoPaused(browser, videoID), + "The video is not paused, but should." + ); + + await BrowserTestUtils.removeTab(tab); + } +}); |