| 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
|
|
|