/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; /** * Tests that the PiP toggle button is not flipped * on certain websites (such as whereby.com). */ add_task(async () => { await BrowserTestUtils.withNewTab( { gBrowser, url: TEST_ROOT + "test-reversed.html", }, async browser => { await ensureVideosReady(browser); let videoID = "reversed"; // Test the toggle button await prepareForToggleClick(browser, videoID); // Hover the mouse over the video to reveal the toggle. await BrowserTestUtils.synthesizeMouseAtCenter( `#${videoID}`, { type: "mousemove", }, browser ); await BrowserTestUtils.synthesizeMouseAtCenter( `#${videoID}`, { type: "mouseover", }, browser ); let toggleFlippedAttribute = await SpecialPowers.spawn( browser, [videoID], async videoID => { let video = content.document.getElementById(videoID); let shadowRoot = video.openOrClosedShadowRoot; let controlsOverlay = shadowRoot.querySelector(".controlsOverlay"); await ContentTaskUtils.waitForCondition(() => { return controlsOverlay.classList.contains("hovering"); }, "Waiting for the hovering state to be set on the video."); return shadowRoot.firstChild.getAttribute("flipped"); } ); Assert.equal( toggleFlippedAttribute, "", `The "flipped" attribute should be set on the toggle button (when applicable).` ); } ); }); /** * Tests that the "This video is playing in Picture-in-Picture" message * as well as the video playing in PiP are both not flipped on certain sites * (such as whereby.com) */ add_task(async () => { await BrowserTestUtils.withNewTab( { gBrowser, url: TEST_ROOT + "test-reversed.html", }, async browser => { /** * A helper function used to get the "flipped" attribute of the video's shadowRoot's first child. * @param {Element} browser The hosting the