Sandbox-blocked pointer lock should log to the console.
https://bugs.webkit.org/show_bug.cgi?id=105794
Reviewed by Adrienne Walker.
Source/WebCore:
When pointer lock is requested and is denied due to sandbox restrictions
a helpful message to web developers is sent to the developer console.
Existing test expectations updated.
* page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
LayoutTests:
* http/tests/pointer-lock/iframe-sandboxed-expected.txt:
* http/tests/pointer-lock/iframe-sandboxed-nested-disallow-then-allow-pointer-lock-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/page/PointerLockController.cpp b/Source/WebCore/page/PointerLockController.cpp
index ddbb84f..d652e4f 100644
--- a/Source/WebCore/page/PointerLockController.cpp
+++ b/Source/WebCore/page/PointerLockController.cpp
@@ -48,8 +48,14 @@
void PointerLockController::requestPointerLock(Element* target)
{
- if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaitingForUnlock
- || target->document()->isSandboxed(SandboxPointerLock)) {
+ if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaitingForUnlock) {
+ enqueueEvent(eventNames().webkitpointerlockerrorEvent, target);
+ return;
+ }
+
+ if (target->document()->isSandboxed(SandboxPointerLock)) {
+ // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
+ target->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Blocked pointer lock on an element because the element's frame is sandboxed and the 'allow-pointer-lock' permission is not set.");
enqueueEvent(eventNames().webkitpointerlockerrorEvent, target);
return;
}