-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 272448.388@safari-7618-branch (7047e8e). https://bugs.web…
…kit.org/show_bug.cgi?id=268198 [macOS] Pointer Lock should disengage when client windows present a sheet https://bugs.webkit.org/show_bug.cgi?id=268198 rdar://121694233 Reviewed by Aditya Keerthi. The Pointer Lock API is susceptible to abuse by nefarious webpages since they can (programmatically or otherwise) make client windows show alerts or permission granting sheets while pointer lock is engaged. Since our current implementation of pointer lock stays engaged even when the client window presents a sheet, it leaves the user in a compromised state where they both don't know the location of the mouse cursor and don't have a way to exit the pointer lock state (since the client window where pointer lock is engaged is no longer focused or the key window). This patch addresses this vulnerability by registering observers for the NSWindowWillBeginSheetNotification notification on the WebView's current window, and then requesting for pointer lock to be disengaged whenever we receive a notification that said window will begin presenting a sheet. Test case added in WebKit.ClientDisplaysAlertSheetWhilePointerLockActive that asserts we successfully exit pointer lock when a client window presents an alert sheet. It also tests that we can successfully re-enter pointer lock afterwards. * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/mac/WebViewImpl.h: * Source/WebKit/UIProcess/mac/WebViewImpl.mm: (-[WKWindowVisibilityObserver startObserving:]): (-[WKWindowVisibilityObserver stopObserving:]): (-[WKWindowVisibilityObserver _windowWillBeginSheet:]): (WebKit::WebViewImpl::windowWillBeginSheet): * Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: (-[PointerLockDelegate resetState]): (-[PointerLockDelegate waitForPointerLockEngaged]): (-[PointerLockDelegate waitForPointerLockLost]): (-[PointerLockDelegate _webViewDidRequestPointerLock:completionHandler:]): (-[PointerLockDelegate _webViewDidLosePointerLock:]): Canonical link: https://commits.webkit.org/272448.388@safari-7618-branch Canonical link: https://commits.webkit.org/274313.80@webkitglib/2.44
- Loading branch information
Showing
4 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters