pointer lock should exit when a js alert is shown
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 20:01:00 +0000 (20:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 20:01:00 +0000 (20:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165423
rdar://problem/29430803

Patch by Jeremy Jones <jeremyj@apple.com> on 2016-12-08
Reviewed by Jer Noble.

Source/WebCore:

Test: pointer-lock/lock-lost-on-alert.html

* page/DOMWindow.cpp:
(WebCore::DOMWindow::alert):
(WebCore::DOMWindow::confirm):
(WebCore::DOMWindow::prompt):

LayoutTests:

* platform/mac/TestExpectations:
* pointer-lock/lock-lost-on-alert-expected.txt: Added.
* pointer-lock/lock-lost-on-alert.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209555 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/TestExpectations
LayoutTests/pointer-lock/lock-lost-on-alert-expected.txt [new file with mode: 0644]
LayoutTests/pointer-lock/lock-lost-on-alert.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/DOMWindow.cpp

index fdf9c40..a114d75 100644 (file)
@@ -1,3 +1,15 @@
+2016-12-08  Jeremy Jones  <jeremyj@apple.com>
+
+        pointer lock should exit when a js alert is shown
+        https://bugs.webkit.org/show_bug.cgi?id=165423
+        rdar://problem/29430803
+
+        Reviewed by Jer Noble.
+
+        * platform/mac/TestExpectations:
+        * pointer-lock/lock-lost-on-alert-expected.txt: Added.
+        * pointer-lock/lock-lost-on-alert.html: Added.
+
 2016-12-08  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] WebGLContextAttributes should be a dictionary
index 8ef5574..e73b192 100644 (file)
@@ -291,6 +291,8 @@ pointer-lock/pointerlockelement-null-when-pending.html
 pointer-lock/lock-lost-on-navigation.html [ Pass ]
 http/tests/pointer-lock/
 
+pointer-lock/lock-lost-on-alert.html [ Pass ]
+
 webkit.org/b/82763 fast/forms/textarea-placeholder-set-attribute.html
 
 webkit.org/b/102257 fast/dom/Window/open-window-min-size.html
diff --git a/LayoutTests/pointer-lock/lock-lost-on-alert-expected.txt b/LayoutTests/pointer-lock/lock-lost-on-alert-expected.txt
new file mode 100644 (file)
index 0000000..d3c73a4
--- /dev/null
@@ -0,0 +1,17 @@
+ALERT: Alert text
+Test that pointerlockchange event is dispatched when lock is lost.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.testRunner is defined.
+     Lock targetDiv1.
+PASS onpointerlockchange received after: Lock targetDiv1.
+PASS document.pointerLockElement is targetDiv1
+     Alert cancel targetDiv1 lock.
+PASS document.pointerLockElement is null
+PASS onpointerlockchange received after: Alert cancel targetDiv1 lock.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/pointer-lock/lock-lost-on-alert.html b/LayoutTests/pointer-lock/lock-lost-on-alert.html
new file mode 100644 (file)
index 0000000..5cbbb1c
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../http/tests/resources/js-test-pre.js"></script>
+<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
+</head>
+<body>
+<div>
+  <div id="target1"></div>
+</div>
+<script>
+    description("Test that pointerlockchange event is dispatched when lock is lost.")
+    window.jsTestIsAsync = true;
+    shouldBeDefined("window.testRunner");
+
+    targetDiv1 = document.getElementById("target1");
+
+    todo = [
+        function () {
+            expectOnlyChangeEvent("Lock targetDiv1.");
+            targetDiv1.requestPointerLock();
+            // doNextStep called by event handler.
+        },
+        function () {
+            shouldBe("document.pointerLockElement", "targetDiv1");
+            doNextStepWithUserGesture();
+        },
+        function () {
+            expectOnlyChangeEvent("Alert cancel targetDiv1 lock.");
+            alert('Alert text');
+            shouldBe("document.pointerLockElement", "null");
+        },
+    ];
+    doNextStepWithUserGesture();
+</script>
+<script src="../http/tests/resources/js-test-post.js"></script>
+</body>
+</html>
+
index 30cab56..34e3426 100644 (file)
@@ -1,3 +1,18 @@
+2016-12-08  Jeremy Jones  <jeremyj@apple.com>
+
+        pointer lock should exit when a js alert is shown
+        https://bugs.webkit.org/show_bug.cgi?id=165423
+        rdar://problem/29430803
+
+        Reviewed by Jer Noble.
+
+        Test: pointer-lock/lock-lost-on-alert.html
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::alert):
+        (WebCore::DOMWindow::confirm):
+        (WebCore::DOMWindow::prompt):
+
 2016-12-07  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] WebGLContextAttributes should be a dictionary
index a9c03c4..992ac80 100644 (file)
 #include "GamepadManager.h"
 #endif
 
+#if ENABLE(POINTER_LOCK)
+#include "PointerLockController.h"
+#endif
+
 #if PLATFORM(IOS)
 #if ENABLE(GEOLOCATION)
 #include "NavigatorGeolocation.h"
@@ -1141,6 +1145,9 @@ void DOMWindow::alert(const String& message)
     }
 
     m_frame->document()->updateStyleIfNeeded();
+#if ENABLE(POINTER_LOCK)
+    page->pointerLockController().requestPointerUnlock();
+#endif
 
     page->chrome().runJavaScriptAlert(m_frame, message);
 }
@@ -1160,6 +1167,9 @@ bool DOMWindow::confirm(const String& message)
     }
 
     m_frame->document()->updateStyleIfNeeded();
+#if ENABLE(POINTER_LOCK)
+    page->pointerLockController().requestPointerUnlock();
+#endif
 
     return page->chrome().runJavaScriptConfirm(m_frame, message);
 }
@@ -1179,6 +1189,9 @@ String DOMWindow::prompt(const String& message, const String& defaultValue)
     }
 
     m_frame->document()->updateStyleIfNeeded();
+#if ENABLE(POINTER_LOCK)
+    page->pointerLockController().requestPointerUnlock();
+#endif
 
     String returnValue;
     if (page->chrome().runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))