Bug 1357995 - Run the full screen test in a new window so that we can access to fullscreen API after pushing preference. r=masayuki
authorStone Shih <sshih@mozilla.com>
Thu, 20 Apr 2017 13:00:23 +0800
changeset 354570 f7087d394f1e9552d9c2684ccffe8d052470770b
parent 354569 48503ae4cbd60d66d351ccc54267e184a052c7cb
child 354571 c100351d959148fd1f75ff0544ea0a215f8f7c22
push id31706
push userkwierso@gmail.com
push dateMon, 24 Apr 2017 22:45:34 +0000
treeherdermozilla-central@196e7e9e2e44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1357995
milestone55.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 1357995 - Run the full screen test in a new window so that we can access to fullscreen API after pushing preference. r=masayuki MozReview-Commit-ID: KGrOWUl453C
dom/events/test/pointerevents/test_trigger_fullscreen_by_pointer_events.html
--- a/dom/events/test/pointerevents/test_trigger_fullscreen_by_pointer_events.html
+++ b/dom/events/test/pointerevents/test_trigger_fullscreen_by_pointer_events.html
@@ -3,51 +3,54 @@
 <head>
   <meta charset="utf-8">
   <title>Test for triggering Fullscreen by pointer events</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <script src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
-<div id="target" style="width: 50px; height: 50px; background: green"></div>
 <script>
-
 SimpleTest.waitForExplicitFinish();
 
-var target = document.getElementById("target");
-target.addEventListener("pointerdown", () => {
-  target.requestFullscreen();
-  target.addEventListener("pointerdown", () => {
-    document.exitFullscreen();
-  }, {once: true});
-}, {once: true});
+function startTest() {
+  let win = window.open("data:text/html,<body><div id='target' style='width: 50px; height: 50px; background: green'></div></body>", "_blank");
+  win.addEventListener("load", () => {
+    let target = win.document.getElementById("target");
+    target.addEventListener("pointerdown", () => {
+      target.requestFullscreen();
+      target.addEventListener("pointerdown", () => {
+        win.document.exitFullscreen();
+      }, {once: true});
+    }, {once: true});
 
-document.addEventListener("fullscreenchange", () => {
-  if (document.fullscreenElement) {
-    ok(document.fullscreenElement, target, "fullscreenElement should be the div element");
-    // synthesize mouse events to generate pointer events and leave full screen.
-    synthesizeMouseAtCenter(target, { type: "mousedown" });
-    synthesizeMouseAtCenter(target, { type: "mouseup" });
-  } else {
-    SimpleTest.finish();
-  }
-});
-
-function startTest() {
-  // synthesize mouse events to generate pointer events and enter full screen.
-  synthesizeMouseAtCenter(target, { type: "mousedown" });
-  synthesizeMouseAtCenter(target, { type: "mouseup" });
+    win.document.addEventListener("fullscreenchange", () => {
+      if (win.document.fullscreenElement) {
+        ok(win.document.fullscreenElement, target, "fullscreenElement should be the div element");
+        // synthesize mouse events to generate pointer events and leave full screen.
+        synthesizeMouseAtCenter(target, { type: "mousedown" }, win);
+        synthesizeMouseAtCenter(target, { type: "mouseup" }, win);
+      } else {
+        win.close();
+        SimpleTest.finish();
+      }
+    });
+    // Make sure our window is focused before starting the test
+    SimpleTest.waitForFocus(() => {
+      // synthesize mouse events to generate pointer events and enter full screen.
+      synthesizeMouseAtCenter(target, { type: "mousedown" }, win);
+      synthesizeMouseAtCenter(target, { type: "mouseup" }, win);
+    }, win);
+  });
 }
 
 SimpleTest.waitForFocus(() => {
   SpecialPowers.pushPrefEnv({
     "set": [
       ["full-screen-api.unprefix.enabled", true],
       ["full-screen-api.allow-trusted-requests-only", false],
       ["dom.w3c_pointer_events.enabled", true]
     ]
   }, startTest);
 });
-
 </script>
 </body>
 </html>