Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| index e558f3898d973d35ed24de6a098316eedfe945ed..5725247f7d09222806c44b782291e4e28966ebc7 100644 |
| --- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| +++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| @@ -298,6 +298,55 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| EXPECT_NE(orig_site_instance, noopener_blank_site_instance); |
| } |
| +// 'noopener' also works from 'window.open' |
| +IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| + SwapProcessWithWindowOpenAndNoopener) { |
| + StartEmbeddedServer(); |
| + |
| + NavigateToPageWithLinks(shell()); |
| + |
| + // Get the original SiteInstance for later comparison. |
| + scoped_refptr<SiteInstance> orig_site_instance( |
| + shell()->web_contents()->GetSiteInstance()); |
| + EXPECT_TRUE(orig_site_instance.get() != NULL); |
|
nasko
2015/11/19 15:06:16
nullptr
|
| + |
| + // Test opening a window with the 'noopener' feature. |
| + ShellAddedObserver new_shell_observer; |
| + bool hasWindowReference = true; |
| + EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| + shell()->web_contents(), |
| + "window.domAutomationController.send(" |
| + " openWindowWithTargetAndFeatures('/title2.html', '', 'noopener')" |
| + ");", |
| + &hasWindowReference)); |
| + // We should not get a reference to the opened window. |
| + EXPECT_FALSE(hasWindowReference); |
| + |
| + // Wait for the window to open. |
| + Shell* new_shell = new_shell_observer.GetShell(); |
| + |
| + EXPECT_EQ("/title2.html", new_shell->web_contents()->GetVisibleURL().path()); |
|
nasko
2015/11/19 15:06:16
If you move the code around to wait for the naviga
|
| + |
| + // Check that `window.opener` is not set. |
| + bool success = false; |
| + EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| + new_shell->web_contents(), |
| + "window.domAutomationController.send(window.opener == null);", &success)); |
| + EXPECT_TRUE(success); |
| + |
| + // Wait for the cross-site transition in the new tab to finish. |
|
nasko
2015/11/19 15:06:16
I'd suggest waiting for the navigation to complete
|
| + WaitForLoadStop(new_shell->web_contents()); |
| + WebContentsImpl* web_contents = |
| + static_cast<WebContentsImpl*>(new_shell->web_contents()); |
| + EXPECT_FALSE( |
| + web_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
| + |
| + // Should have a new SiteInstance. |
| + scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| + new_shell->web_contents()->GetSiteInstance()); |
| + EXPECT_NE(orig_site_instance, noopener_blank_site_instance); |
| +} |
| + |
| // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) |
| // for rel=noreferrer links in new windows, even to same site pages and named |
| // targets. |