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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 743773003: OOPIF: Data URLs are now rendered in the renderer that initiated the navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
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 af10e3eecb5356c00b344c734801224d8a3c860c..c030d9faecaf2458b73d09a76c8af03391bcf8a1 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"
@@ -214,7 +215,7 @@ void SitePerProcessBrowserTest::StartFrameAtDataURL() {
ASSERT_TRUE(ExecuteScript(shell()->web_contents(), data_url_script));
}
-bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window,
+void SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window,
const GURL& url,
std::string iframe_id) {
// TODO(creis): This should wait for LOAD_STOP, but cross-site subframe
@@ -231,9 +232,8 @@ bool SitePerProcessBrowserTest::NavigateIframeToURL(Shell* window,
NOTIFICATION_NAV_ENTRY_COMMITTED,
Source<NavigationController>(
&window->web_contents()->GetController()));
- bool result = ExecuteScript(window->web_contents(), script);
+ EXPECT_TRUE(ExecuteScript(window->web_contents(), script));
load_observer.Wait();
- return result;
}
void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) {
@@ -410,10 +410,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) {
std::string foo_com("foo.com");
// Load cross-site page into iframe.
- EXPECT_TRUE(NavigateIframeToURL(
- shell(),
- embedded_test_server()->GetURL("/cross-site/foo.com/title2.html"),
- "test"));
+ NavigateIframeToURL(shell(), embedded_test_server()->GetURL(
+ "/cross-site/foo.com/title2.html"),
+ "test");
// Check the subframe process.
FrameTreeNode* root =
@@ -487,8 +486,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// Should be blocked.
GURL client_redirect_https_url(https_server.GetURL(
"client-redirect?files/title1.html"));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- client_redirect_https_url, "test"));
+ NavigateIframeToURL(shell(), client_redirect_https_url, "test");
// DidFailProvisionalLoad when navigating to client_redirect_https_url.
EXPECT_EQ(observer.navigation_url(), client_redirect_https_url);
EXPECT_FALSE(observer.navigation_succeeded());
@@ -499,8 +497,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// which redirects to same-site page.
GURL server_redirect_http_url(https_server.GetURL(
"server-redirect?" + http_url.spec()));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
EXPECT_EQ(observer.navigation_url(), http_url);
EXPECT_TRUE(observer.navigation_succeeded());
}
@@ -510,8 +507,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// which redirects to cross-site page.
GURL server_redirect_http_url(https_server.GetURL(
"server-redirect?files/title1.html"));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
// DidFailProvisionalLoad when navigating to https_url.
EXPECT_EQ(observer.navigation_url(), https_url);
EXPECT_FALSE(observer.navigation_succeeded());
@@ -522,8 +518,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// which redirects to cross-site page.
GURL server_redirect_http_url(test_server()->GetURL(
"server-redirect?" + https_url.spec()));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
EXPECT_EQ(observer.navigation_url(), https_url);
EXPECT_FALSE(observer.navigation_succeeded());
@@ -540,8 +535,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
Source<NavigationController>(
&shell()->web_contents()->GetController()));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- client_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), client_redirect_http_url, "test");
// Same-site Client-Redirect Page should be loaded successfully.
EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
@@ -556,10 +550,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
{
// Load same-site server-redirect page into Iframe,
// which redirects to same-site page.
- GURL server_redirect_http_url(test_server()->GetURL(
- "server-redirect?files/title1.html"));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- server_redirect_http_url, "test"));
+ GURL server_redirect_http_url(
+ test_server()->GetURL("server-redirect?files/title1.html"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
EXPECT_EQ(observer.navigation_url(), http_url);
EXPECT_TRUE(observer.navigation_succeeded());
}
@@ -574,8 +567,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
Source<NavigationController>(
&shell()->web_contents()->GetController()));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- client_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), client_redirect_http_url, "test");
// Same-site Client-Redirect Page should be loaded successfully.
EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
@@ -622,7 +614,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
Source<NavigationController>(
&shell()->web_contents()->GetController()));
- EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), client_redirect_http_url, "test");
// DidFailProvisionalLoad when navigating to client_redirect_https_url.
load_observer2.Wait();
@@ -637,8 +629,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
"server-redirect?" + http_url.spec()));
GURL server_redirect_http_url(test_server()->GetURL(
"server-redirect?" + server_redirect_https_url.spec()));
- EXPECT_TRUE(NavigateIframeToURL(shell(),
- server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
EXPECT_EQ(observer.navigation_url(), http_url);
EXPECT_TRUE(observer.navigation_succeeded());
}
@@ -650,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
"server-redirect?" + https_url.spec()));
GURL server_redirect_http_url(test_server()->GetURL(
"server-redirect?" + server_redirect_https_url.spec()));
- EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
// DidFailProvisionalLoad when navigating to https_url.
EXPECT_EQ(observer.navigation_url(), https_url);
@@ -664,7 +655,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
"client-redirect?" + http_url.spec()));
GURL server_redirect_http_url(test_server()->GetURL(
"server-redirect?" + client_redirect_http_url.spec()));
- EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
+ NavigateIframeToURL(shell(), server_redirect_http_url, "test");
// DidFailProvisionalLoad when navigating to client_redirect_http_url.
EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
@@ -831,4 +822,94 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteTwoLevelNesting) {
bottom_child->current_frame_host()->GetSiteInstance());
}
+// Disabled because of http://crbug.com/433012 .
+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.
+ 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 .
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
+ DISABLED_NavigateRemoteToBlankURL) {
+ 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.
+ GURL data_url("about:blank");
+ 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

Powered by Google App Engine
This is Rietveld 408576698