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

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: fixing android compile 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
« no previous file with comments | « content/browser/security_exploit_browsertest.cc ('k') | content/public/browser/navigation_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..30829bb89cd2cb0b520939e8ea031e10bf70f0ce 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,103 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
}
+// TODO(lfg): Merge the test below with NavigateRemoteFrame test.
+// TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
+// the renderer process crashes, it causes the title watcher to never return.
+// Alternatively, this could also be fixed if we could use NavigateIframeToURL
+// and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or
+// if we waited for DidStopLoading (currently broken -- see comment in
+// NavigateIframeToURL).
+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 frame, so the data URL should be committed in the same SiteInstance
+ // as the parent frame.
+ 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));
+ EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
+ 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());
+}
+
+// TODO(lfg): Merge the test below with NavigateRemoteFrame test.
+// Disabled due to the same reason as NavigateRemoteToDataURL.
+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 about:blank. The navigation happens from a script in the
+ // parent frame, so it should be committed in the same SiteInstance as the
+ // parent frame.
+ GURL about_blank_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);",
+ about_blank_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));
+ EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
+ EXPECT_TRUE(observer.navigation_succeeded());
+ EXPECT_EQ(about_blank_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
« no previous file with comments | « content/browser/security_exploit_browsertest.cc ('k') | content/public/browser/navigation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698