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 cc7e1fa3948a836a8c42f627173aa4f04ed8ba6c..769bcd006b1ef5aab200fbfcfb949901bf8af93e 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/command_line.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "content/browser/frame_host/cross_process_frame_connector.h" |
| #include "content/browser/frame_host/frame_tree.h" |
| #include "content/browser/frame_host/navigator.h" |
| @@ -231,9 +232,11 @@ bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window, |
| NOTIFICATION_NAV_ENTRY_COMMITTED, |
| Source<NavigationController>( |
| &window->web_contents()->GetController())); |
| - bool result = ExecuteScript(window->web_contents(), script); |
| + if (!ExecuteScript(window->web_contents(), script)) |
| + return false; |
| load_observer.Wait(); |
| - return result; |
| + |
| + return true; |
| } |
| void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
| @@ -868,4 +871,94 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
| EXPECT_EQ(result + "/", main_url.GetOrigin().spec()); |
| } |
| +// Disabled because of http://crbug.com/433012 . |
|
Charlie Reis
2014/12/11 00:43:39
nit: No space before period.
Let's also rephrase,
lfg
2014/12/11 23:55:24
Done.
|
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + DISABLED_NavigateRemoteToDataURL) { |
| + GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| + NavigateToURL(shell(), main_url); |
| + |
| + // It is safe to obtain the root frame tree node here, as it doesn't change. |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetFrameTree() |
| + ->root(); |
| + |
| + SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
| + |
| + // Load cross-site page into iframe. |
| + GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
| + NavigateFrameToURL(root->child_at(0), url); |
| + EXPECT_TRUE(observer.navigation_succeeded()); |
| + EXPECT_EQ(url, observer.navigation_url()); |
| + |
| + // Ensure that we have created a new process for the subframe. |
| + EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| + root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| + |
| + // Navigate iframe to a data URL. The navigation happens from a script in the |
| + // parent renderer, so the data URL should be rendered in the parent renderer. |
|
nasko
2014/12/11 01:14:44
I'd rephrase it a bit to be more specific.
The na
lfg
2014/12/11 23:55:24
Done.
|
| + GURL data_url("data:text/html,dataurl"); |
| + std::string script = base::StringPrintf( |
| + "setTimeout(function() {" |
| + "var iframe = document.getElementById('test');" |
| + "iframe.onload = function() { document.title = 'LOADED'; };" |
| + "iframe.src=\"%s\";" |
| + "},0);", |
| + data_url.spec().c_str()); |
| + base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
| + TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
| + EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| + (void)title_watcher.WaitAndGetTitle(); |
| + EXPECT_TRUE(observer.navigation_succeeded()); |
| + EXPECT_EQ(data_url, observer.navigation_url()); |
| + |
| + // Ensure that we have navigated using the top level process. |
| + EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| + root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| +} |
| + |
| +// Disabled because of http://crbug.com/433012 . |
|
Charlie Reis
2014/12/11 00:43:39
Same as above.
lfg
2014/12/11 23:55:24
Done.
|
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + DISABLED_NavigateRemoteToBlankURL) { |
| + GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
|
nasko
2014/12/11 01:14:44
Both this method and the above differ only in the
lfg
2014/12/11 23:55:24
I think those two should be in the same test. The
|
| + NavigateToURL(shell(), main_url); |
| + |
| + // It is safe to obtain the root frame tree node here, as it doesn't change. |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetFrameTree() |
| + ->root(); |
| + |
| + SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
| + |
| + // Load cross-site page into iframe. |
| + GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html"); |
| + NavigateFrameToURL(root->child_at(0), url); |
| + EXPECT_TRUE(observer.navigation_succeeded()); |
| + EXPECT_EQ(url, observer.navigation_url()); |
| + |
| + // Ensure that we have created a new process for the subframe. |
| + EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| + root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| + |
| + // Navigate iframe to a data URL. The navigation happens from a script in the |
| + // parent renderer, so the data URL should be rendered in the parent renderer. |
| + GURL data_url("about:blank"); |
|
nasko
2014/12/11 01:14:44
nit: this is no longer data_url
lfg
2014/12/11 23:55:24
Done.
|
| + std::string script = base::StringPrintf( |
| + "setTimeout(function() {" |
| + "var iframe = document.getElementById('test');" |
| + "iframe.onload = function() { document.title = 'LOADED'; };" |
| + "iframe.src=\"%s\";" |
| + "},0);", |
| + data_url.spec().c_str()); |
| + base::string16 passed_string(base::UTF8ToUTF16("LOADED")); |
| + TitleWatcher title_watcher(shell()->web_contents(), passed_string); |
| + EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| + (void)title_watcher.WaitAndGetTitle(); |
| + EXPECT_TRUE(observer.navigation_succeeded()); |
| + EXPECT_EQ(data_url, observer.navigation_url()); |
| + |
| + // Ensure that we have navigated using the top level process. |
| + EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| + root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| +} |
| + |
| } // namespace content |