Bug 1323983 part 3 - Add test for closing window while holding pointerlock. r=smaug
MozReview-Commit-ID: 7f1su4afmnd
--- 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>