Bug 1547006 - Add a regression test to ensure that the Picture-in-Picture toggle is not displayed in fullscreen mode. r=jaws
authorMike Conley <mconley@mozilla.com>
Fri, 17 May 2019 20:08:01 +0000
changeset 474381 f99a22d1e5a9c4723f558fb2dda3917e742ed5e3
parent 474380 c1e088ef0311bfe7db4ec3e26b86ce389a95277b
child 474382 a18f289abc5d8034c9cdf85992a646fff47966ed
push id113152
push userdluca@mozilla.com
push dateSat, 18 May 2019 10:33:03 +0000
treeherdermozilla-inbound@9b2f851979cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1547006
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547006 - Add a regression test to ensure that the Picture-in-Picture toggle is not displayed in fullscreen mode. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D28561
toolkit/components/pictureinpicture/tests/browser.ini
toolkit/components/pictureinpicture/tests/browser_fullscreen.js
--- a/toolkit/components/pictureinpicture/tests/browser.ini
+++ b/toolkit/components/pictureinpicture/tests/browser.ini
@@ -12,16 +12,17 @@ support-files =
 prefs =
   media.videocontrols.picture-in-picture.enabled=true
   media.videocontrols.picture-in-picture.video-toggle.enabled=true
   media.videocontrols.picture-in-picture.video-toggle.testing=true
 
 [browser_cannotTriggerFromContent.js]
 [browser_contextMenu.js]
 [browser_closeTab.js]
+[browser_fullscreen.js]
 [browser_mouseButtonVariation.js]
 skip-if = debug
 [browser_rerequestPiP.js]
 [browser_showMessage.js]
 [browser_toggleButtonOverlay.js]
 skip-if = true # Bug 1546455
 [browser_toggleOpaqueOverlay.js]
 skip-if = true # Bug 1546455
new file mode 100644
--- /dev/null
+++ b/toolkit/components/pictureinpicture/tests/browser_fullscreen.js
@@ -0,0 +1,98 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const VIDEOS = [
+  "with-controls",
+  "no-controls",
+];
+
+/**
+ * Tests that the Picture-in-Picture toggle is hidden when
+ * a video with or without controls is made fullscreen.
+ */
+add_task(async () => {
+  await BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: TEST_PAGE,
+  }, async browser => {
+    for (let videoID of VIDEOS) {
+      let entered = BrowserTestUtils.waitForEvent(window, "MozDOMFullscreen:Entered");
+      await ContentTask.spawn(browser, videoID, async videoID => {
+        let video = this.content.document.getElementById(videoID);
+        video.requestFullscreen();
+      });
+      await entered;
+
+      await BrowserTestUtils.waitForCondition(() => {
+        return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
+      });
+
+      await BrowserTestUtils.synthesizeMouseAtCenter(`#${videoID}`, {
+        type: "mouseover",
+      }, browser);
+
+      let args = { videoID, TOGGLE_ID };
+      let exited = BrowserTestUtils.waitForEvent(window, "MozDOMFullscreen:Exited");
+      await ContentTask.spawn(browser, args, async args => {
+        let { videoID, TOGGLE_ID } = args;
+        let video = this.content.document.getElementById(videoID);
+        let toggle = video.openOrClosedShadowRoot.getElementById(TOGGLE_ID);
+        ok(ContentTaskUtils.is_hidden(toggle), "Toggle should be hidden in fullscreen mode.");
+        this.content.document.exitFullscreen();
+      });
+      await exited;
+
+      await BrowserTestUtils.waitForCondition(() => {
+        return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
+      });
+    }
+  });
+});
+
+/**
+ * Tests that the Picture-in-Picture toggle is hidden if an
+ * ancestor of a video (in this case, the document body) is made
+ * to be the fullscreen element.
+ */
+add_task(async () => {
+  await BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: TEST_PAGE,
+  }, async browser => {
+    let entered = BrowserTestUtils.waitForEvent(window, "MozDOMFullscreen:Entered");
+    await ContentTask.spawn(browser, null, async () => {
+      this.content.document.body.requestFullscreen();
+    });
+    await entered;
+
+    await BrowserTestUtils.waitForCondition(() => {
+      return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
+    });
+
+    for (let videoID of VIDEOS) {
+      await BrowserTestUtils.synthesizeMouseAtCenter(`#${videoID}`, {
+        type: "mouseover",
+      }, browser);
+
+      let args = { videoID, TOGGLE_ID };
+      await ContentTask.spawn(browser, args, async args => {
+        let { videoID, TOGGLE_ID } = args;
+        let video = this.content.document.getElementById(videoID);
+        let toggle = video.openOrClosedShadowRoot.getElementById(TOGGLE_ID);
+        ok(ContentTaskUtils.is_hidden(toggle), "Toggle should be hidden in fullscreen mode.");
+      });
+    }
+
+    let exited = BrowserTestUtils.waitForEvent(window, "MozDOMFullscreen:Exited");
+    await ContentTask.spawn(browser, null, async () => {
+      this.content.document.exitFullscreen();
+    });
+    await exited;
+
+    await BrowserTestUtils.waitForCondition(() => {
+      return !TelemetryStopwatch.running("FULLSCREEN_CHANGE_MS");
+    });
+  });
+});