Bug 1323983 part 3 - Add test for closing window while holding pointerlock. r=smaug draft
authorXidorn Quan <me@upsuper.org>
Mon, 19 Dec 2016 18:18:21 +1100
changeset 452252 473b95205b23b9cf555a333048a1e5c45a9ba92c
parent 451805 4bc50c6f6723114c417471e27b4d5d35bb0e0c75
child 540192 1aea7371f9d009d579bc9e0260bbf4cc025c6896
push id39367
push userxquan@mozilla.com
push dateWed, 21 Dec 2016 13:35:13 +0000
reviewerssmaug
bugs1323983
milestone53.0a1
Bug 1323983 part 3 - Add test for closing window while holding pointerlock. r=smaug MozReview-Commit-ID: 7f1su4afmnd
dom/tests/mochitest/pointerlock/mochitest.ini
dom/tests/mochitest/pointerlock/test_closewindow-with-pointerlock.html
--- a/dom/tests/mochitest/pointerlock/mochitest.ini
+++ b/dom/tests/mochitest/pointerlock/mochitest.ini
@@ -1,9 +1,15 @@
 [DEFAULT]
+skip-if = toolkit == 'android'
+
+[test_closewindow-with-pointerlock.html]
+
+[test_pointerlock-api.html]
+tags = fullscreen
 support-files =
   pointerlock_utils.js
   file_pointerlock-api.html
   file_pointerlockerror.html
   file_escapeKey.html
   file_withoutDOM.html
   file_removedFromDOM.html
   file_pointerLockPref.html
@@ -15,12 +21,8 @@ support-files =
   file_retargetMouseEvents.html
   file_targetOutOfFocus.html
   file_screenClientXYConst.html
   file_suppressSomeMouseEvents.html
   file_locksvgelement.html
   file_allowPointerLockSandboxFlag.html
   file_changeLockElement.html
   iframe_differentDOM.html
-
-[test_pointerlock-api.html]
-tags = fullscreen
-skip-if = toolkit == 'android'
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/pointerlock/test_closewindow-with-pointerlock.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <title>Bug 1323983 - Auto-close window after holding pointerlock</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body style="width: 100vw; height: 100vh; margin: 0;">
+  <script>
+    if (!opener) {
+      SimpleTest.waitForExplicitFinish();
+    }
+
+    var newwin = null;
+    function finish() {
+      newwin.close()
+      setTimeout(function() {
+        SimpleTest.finish();
+      }, 0);
+    }
+
+    addLoadEvent(function() {
+      SimpleTest.waitForFocus(function() {
+        if (!opener) {
+          newwin = window.open(location);
+        } else {
+          document.addEventListener("pointerlockchange", function() {
+            opener.is(document.pointerLockElement, document.body,
+                      "Check we have locked the pointer");
+            opener.finish();
+          }, {once: true});
+          document.addEventListener("pointerlockerror", function() {
+            opener.info("Fail to lock pointer");
+            opener.finish();
+          });
+          document.addEventListener("click", function() {
+            opener.info("Clicked");
+            document.body.requestPointerLock();
+          }, {once: true});
+          setTimeout(function() {
+            opener.info("Clicking");
+            synthesizeMouseAtCenter(document.body, {});
+          }, 0);
+        }
+      });
+    });
+  </script>
+</body>
+</html>