Bug 1665941 - expand cross-origin requestFullscreen mochitest to test ESC exit. r=smaug
authorSteven MacLeod <steven@smacleod.ca>
Wed, 23 Sep 2020 20:59:15 +0000
changeset 550148 6d45a17995e220d26df280d6af6c3bf81b69b348
parent 550147 fae2017a1aa778906319e9122213e92e3ae0f367
child 550149 67acd8531789a0294b99b616e51c64273d29052b
push id37808
push userapavel@mozilla.com
push dateThu, 24 Sep 2020 21:53:48 +0000
treeherdermozilla-central@6d45a17995e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1665941
milestone83.0a1
first release with
nightly linux32
6d45a17995e2 / 83.0a1 / 20200924215348 / files
nightly linux64
6d45a17995e2 / 83.0a1 / 20200924215348 / files
nightly mac
6d45a17995e2 / 83.0a1 / 20200924215348 / files
nightly win32
6d45a17995e2 / 83.0a1 / 20200924215348 / files
nightly win64
6d45a17995e2 / 83.0a1 / 20200924215348 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1665941 - expand cross-origin requestFullscreen mochitest to test ESC exit. r=smaug This expands the current `requestFullscreen()` mochitest to check the result of exiting fullscreen using the ESC key, since it follows a separate code path from `document.exitFullscreen()`. Depends on D90928 Differential Revision: https://phabricator.services.mozilla.com/D90940
browser/base/content/test/fullscreen/FullscreenFrame.jsm
browser/base/content/test/fullscreen/browser_fullscreen_api_fission.js
--- a/browser/base/content/test/fullscreen/FullscreenFrame.jsm
+++ b/browser/base/content/test/fullscreen/FullscreenFrame.jsm
@@ -7,33 +7,39 @@
 
 var EXPORTED_SYMBOLS = ["FullscreenFrameChild"];
 
 class FullscreenFrameChild extends JSWindowActorChild {
   actorCreated() {
     this.fullscreen_events = [];
   }
 
+  changed() {
+    return new Promise(resolve => {
+      this.contentWindow.document.addEventListener(
+        "fullscreenchange",
+        () => resolve(),
+        {
+          once: true,
+        }
+      );
+    });
+  }
+
   receiveMessage(msg) {
     switch (msg.name) {
+      case "WaitForChange":
+        return this.changed();
       case "ExitFullscreen":
         return this.contentWindow.document.exitFullscreen();
       case "RequestFullscreen":
-        let changed = new Promise(resolve => {
-          this.contentWindow.document.addEventListener(
-            "fullscreenchange",
-            () => resolve(),
-            {
-              once: true,
-            }
-          );
-        });
+        let finished_fullscreen = this.changed();
         this.docShell.isActive = true;
         this.contentWindow.document.getElementById("request").click();
-        return changed;
+        return finished_fullscreen;
       case "CreateChild":
         let child = msg.data;
         let iframe = this.contentWindow.document.createElement("iframe");
         iframe.allow = child.allow_fullscreen ? "fullscreen" : "";
         iframe.name = child.name;
 
         let loaded = new Promise(resolve => {
           iframe.addEventListener(
--- a/browser/base/content/test/fullscreen/browser_fullscreen_api_fission.js
+++ b/browser/base/content/test/fullscreen/browser_fullscreen_api_fission.js
@@ -187,12 +187,45 @@ add_task(async function test_fullscreen_
       ["A", "null"],
       ["B", "null"],
       ["C", "null"],
       ["D", "null"],
       ["E", "null"],
     ])
   );
 
+  // Clear previous events before testing exiting fullscreen with ESC.
+  for (const frame of frames.values()) {
+    frame.actor.sendQuery("ClearEvents");
+  }
+  await target.actor.sendQuery("RequestFullscreen");
+
+  // Escape should cause the proper events to fire and
+  // document.fullscreenElement should be cleared.
+  let finished_exiting = target.actor.sendQuery("WaitForChange");
+  EventUtils.sendKey("ESCAPE");
+  await finished_exiting;
+  // true is fullscreenchange and false is fullscreenerror.
+  await check_events(
+    new Map([
+      ["TOP", [true, true]],
+      ["A", [true, true]],
+      ["B", []],
+      ["C", [true, true]],
+      ["D", [true, true]],
+      ["E", []],
+    ])
+  );
+  await check_fullscreenElement(
+    new Map([
+      ["TOP", "null"],
+      ["A", "null"],
+      ["B", "null"],
+      ["C", "null"],
+      ["D", "null"],
+      ["E", "null"],
+    ])
+  );
+
   // Remove the tests custom window actor.
   ChromeUtils.unregisterWindowActor("FullscreenFrame");
   BrowserTestUtils.removeTab(tab);
 });