Chromium Code Reviews| Index: content/browser/site_per_process_browsertest.cc |
| diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
| index 92628471cf7048d46e46597fc0340557251288f1..8960bb1f8474800bfe93fba0c9d504ec3242ea11 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -41,6 +41,7 @@ |
| #include "content/common/renderer.mojom.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/interstitial_page_delegate.h" |
| +#include "content/public/browser/navigation_handle.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_types.h" |
| @@ -8346,4 +8347,33 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| transfer_manager.WaitForNavigationFinished(); |
| } |
| +class NavigatigationHandleWatcher : public WebContentsObserver { |
|
alexmos
2016/10/13 00:46:27
nit: s/Navigatigation/Navigation/
jam
2016/10/13 03:12:28
Done.
|
| + public: |
| + NavigatigationHandleWatcher(WebContents* web_contents) |
| + : WebContentsObserver(web_contents) {} |
| + void DidStartNavigation(NavigationHandle* navigation_handle) override { |
| + DCHECK_EQ("http://b.com/", |
| + navigation_handle->GetCreatorSiteInstance()->GetSiteURL().spec()); |
|
alexmos
2016/10/13 00:46:27
GetStartingSiteInstance (should fix compile)
|
| + } |
| +}; |
| + |
| +// Verifies that the SiteInstance of a NavigationHandle correctly identifies the |
| +// RenderFrameHost that started the navigation (and not the destination RFH). |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + NavigationHandleSiteInstance) { |
| + // Navigate to a page with a cross-site iframe. |
| + GURL main_url(embedded_test_server()->GetURL( |
| + "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| + EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| + |
| + // Navigate the iframe cross-site. |
| + NavigatigationHandleWatcher watcher(shell()->web_contents()); |
| + TestNavigationObserver load_observer(shell()->web_contents()); |
| + GURL frame_url = embedded_test_server()->GetURL("c.com", "/title1.html"); |
| + EXPECT_TRUE(ExecuteScript( |
| + shell()->web_contents(), |
| + "window.frames[0].location = \"" + frame_url.spec() + "\";")); |
| + load_observer.Wait(); |
| +} |
| + |
| } // namespace content |