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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 1459603002: Implement the 'noopener' window feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ugh. Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/test/data/click-noreferrer-links.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 static_cast<WebContentsImpl*>(new_shell->web_contents()); 291 static_cast<WebContentsImpl*>(new_shell->web_contents());
292 EXPECT_FALSE( 292 EXPECT_FALSE(
293 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); 293 web_contents->GetRenderManagerForTesting()->pending_render_view_host());
294 294
295 // Should have a new SiteInstance. 295 // Should have a new SiteInstance.
296 scoped_refptr<SiteInstance> noopener_blank_site_instance( 296 scoped_refptr<SiteInstance> noopener_blank_site_instance(
297 new_shell->web_contents()->GetSiteInstance()); 297 new_shell->web_contents()->GetSiteInstance());
298 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); 298 EXPECT_NE(orig_site_instance, noopener_blank_site_instance);
299 } 299 }
300 300
301 // 'noopener' also works from 'window.open'
302 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
303 SwapProcessWithWindowOpenAndNoopener) {
304 StartEmbeddedServer();
305
306 NavigateToPageWithLinks(shell());
307
308 // Get the original SiteInstance for later comparison.
309 scoped_refptr<SiteInstance> orig_site_instance(
310 shell()->web_contents()->GetSiteInstance());
311 EXPECT_TRUE(orig_site_instance.get() != NULL);
nasko 2015/11/19 15:06:16 nullptr
312
313 // Test opening a window with the 'noopener' feature.
314 ShellAddedObserver new_shell_observer;
315 bool hasWindowReference = true;
316 EXPECT_TRUE(ExecuteScriptAndExtractBool(
317 shell()->web_contents(),
318 "window.domAutomationController.send("
319 " openWindowWithTargetAndFeatures('/title2.html', '', 'noopener')"
320 ");",
321 &hasWindowReference));
322 // We should not get a reference to the opened window.
323 EXPECT_FALSE(hasWindowReference);
324
325 // Wait for the window to open.
326 Shell* new_shell = new_shell_observer.GetShell();
327
328 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
329
330 // Check that `window.opener` is not set.
331 bool success = false;
332 EXPECT_TRUE(ExecuteScriptAndExtractBool(
333 new_shell->web_contents(),
334 "window.domAutomationController.send(window.opener == null);", &success));
335 EXPECT_TRUE(success);
336
337 // 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
338 WaitForLoadStop(new_shell->web_contents());
339 WebContentsImpl* web_contents =
340 static_cast<WebContentsImpl*>(new_shell->web_contents());
341 EXPECT_FALSE(
342 web_contents->GetRenderManagerForTesting()->pending_render_view_host());
343
344 // Should have a new SiteInstance.
345 scoped_refptr<SiteInstance> noopener_blank_site_instance(
346 new_shell->web_contents()->GetSiteInstance());
347 EXPECT_NE(orig_site_instance, noopener_blank_site_instance);
348 }
349
301 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) 350 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance)
302 // for rel=noreferrer links in new windows, even to same site pages and named 351 // for rel=noreferrer links in new windows, even to same site pages and named
303 // targets. 352 // targets.
304 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 353 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
305 SwapProcessWithSameSiteRelNoreferrer) { 354 SwapProcessWithSameSiteRelNoreferrer) {
306 StartEmbeddedServer(); 355 StartEmbeddedServer();
307 356
308 // Load a page with links that open in a new window. 357 // Load a page with links that open in a new window.
309 NavigateToPageWithLinks(shell()); 358 NavigateToPageWithLinks(shell());
310 359
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 popup_root->current_frame_host()->render_view_host()->IsRenderViewLive()); 2403 popup_root->current_frame_host()->render_view_host()->IsRenderViewLive());
2355 2404
2356 // Navigate the main tab to the site of the popup. This will cause the 2405 // Navigate the main tab to the site of the popup. This will cause the
2357 // RenderView for b.com in the main tab to be recreated. If the issue 2406 // RenderView for b.com in the main tab to be recreated. If the issue
2358 // is not fixed, this will result in process crash and failing test. 2407 // is not fixed, this will result in process crash and failing test.
2359 EXPECT_TRUE(NavigateToURL( 2408 EXPECT_TRUE(NavigateToURL(
2360 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); 2409 shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
2361 } 2410 }
2362 2411
2363 } // namespace content 2412 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/click-noreferrer-links.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698