Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Unified Diff: content/browser/pointer_lock_browsertest.cc

Issue 2760343002: Only release the pointer lock when the RenderWidgetHost being destroyed (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/pointer_lock_browsertest.cc
diff --git a/content/browser/pointer_lock_browsertest.cc b/content/browser/pointer_lock_browsertest.cc
index 07dd093a4185711d0b5d1c223db18f486658313e..46fde73b719a92cd480fac0f78ab92d58b611237 100644
--- a/content/browser/pointer_lock_browsertest.cc
+++ b/content/browser/pointer_lock_browsertest.cc
@@ -272,4 +272,39 @@ IN_PROC_BROWSER_TEST_F(PointerLockBrowserTest, PointerLockEventRouting) {
EXPECT_EQ(17, movementY);
}
+// Tests that the browser will not unlock the pointer if a RenderWidgetHostView
+// that doesn't hold the pointer lock is destroyed.
+IN_PROC_BROWSER_TEST_F(PointerLockBrowserTest, PointerLockChildFrameDetached) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/cross_site_iframe_factory.html?a(b)"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root();
+
+ // Request a pointer lock on the root frame's body.
+ EXPECT_TRUE(ExecuteScript(root, "document.body.requestPointerLock()"));
+
+ // Root frame should have been granted pointer lock.
+ bool locked = false;
+ EXPECT_TRUE(ExecuteScriptAndExtractBool(root,
+ "window.domAutomationController.send("
+ "document.pointerLockElement == "
+ "document.body);",
+ &locked));
+ EXPECT_TRUE(locked);
+
+ // Root (platform) RenderWidgetHostView should have the pointer locked.
+ EXPECT_TRUE(root->current_frame_host()->GetView()->IsMouseLocked());
+ EXPECT_EQ(root->current_frame_host()->GetRenderWidgetHost(),
+ web_contents()->GetMouseLockWidget());
+
+ // Detach the child frame.
+ EXPECT_TRUE(ExecuteScript(root, "document.querySelector('iframe').remove()"));
+
+ // Root (platform) RenderWidgetHostView should still have the pointer locked.
+ EXPECT_TRUE(root->current_frame_host()->GetView()->IsMouseLocked());
+ EXPECT_EQ(root->current_frame_host()->GetRenderWidgetHost(),
+ web_contents()->GetMouseLockWidget());
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698