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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2655463006: PlzNavigate: Enforce 'frame-src' CSP on the browser. (Closed)
Patch Set: Rebase. Created 3 years, 9 months 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 0042ab2fb141afe2c5ec62ad31017642cda66968..8067488dd7c255d192deea444136fb149b9c7531 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -2407,7 +2407,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) {
// of the API), but the frame's last_successful_url shouldn't change and the
// origin should be empty.
// PlzNavigate: We have switched RenderFrameHosts for the subframe, so the
- // last succesful url should be empty (since the frame only loaded an error
+ // last successful url should be empty (since the frame only loaded an error
// page).
if (IsBrowserSideNavigationEnabled())
EXPECT_EQ(GURL(), child->current_frame_host()->last_successful_url());
@@ -7424,15 +7424,33 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
load_observer.Wait();
}
- // The blocked frame should stay at the old location.
- EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url());
+ // The last successful url shouldn't be the blocked url.
+ EXPECT_EQ(old_subframe_url,
+ root->child_at(0)->current_frame_host()->last_successful_url());
- // The blocked frame should keep the old title.
- std::string frame_title;
- EXPECT_TRUE(ExecuteScriptAndExtractString(
- root->child_at(0), "domAutomationController.send(document.title)",
- &frame_title));
- EXPECT_EQ("Title Of Awesomeness", frame_title);
+ if (IsBrowserSideNavigationEnabled()) {
+ // The blocked frame should go to an error page. Errors currently commit
+ // with the URL of the blocked page.
+ EXPECT_EQ(blocked_url, root->child_at(0)->current_url());
+
+ // The page should get the title of an error page (i.e "") and not the
+ // title of the blocked page.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0), "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("", frame_title);
+ } else {
+ // The blocked frame should stay at the old location.
+ EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url());
+
+ // The blocked frame should keep the old title.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0), "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("Title Of Awesomeness", frame_title);
+ }
// Navigate to a URL without CSP.
EXPECT_TRUE(NavigateToURL(
@@ -7500,15 +7518,33 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
load_observer2.Wait();
}
- // The blocked frame should stay at the old location.
- EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url());
+ // The last successful url shouldn't be the blocked url.
+ EXPECT_EQ(old_subframe_url,
+ root->child_at(0)->current_frame_host()->last_successful_url());
- // The blocked frame should keep the old title.
- std::string frame_title;
- EXPECT_TRUE(ExecuteScriptAndExtractString(
- root->child_at(0), "domAutomationController.send(document.title)",
- &frame_title));
- EXPECT_EQ("Title Of Awesomeness", frame_title);
+ if (IsBrowserSideNavigationEnabled()) {
+ // The blocked frame should go to an error page. Errors currently commit
+ // with the URL of the blocked page.
+ EXPECT_EQ(blocked_url, root->child_at(0)->current_url());
+
+ // The page should get the title of an error page (i.e "") and not the
+ // title of the blocked page.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0), "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("", frame_title);
+ } else {
+ // The blocked frame should stay at the old location.
+ EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url());
+
+ // The blocked frame should keep the old title.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root->child_at(0), "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("Title Of Awesomeness", frame_title);
+ }
}
// Test that a cross-origin frame's navigation can be blocked by CSP frame-src.
@@ -7570,15 +7606,33 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
load_observer2.Wait();
}
- // The blocked frame should stay at the old location.
- EXPECT_EQ(old_subframe_url, navigating_frame->current_url());
+ // The last successful url shouldn't be the blocked url.
+ EXPECT_EQ(old_subframe_url,
+ navigating_frame->current_frame_host()->last_successful_url());
- // The blocked frame should keep the old title.
- std::string frame_title;
- EXPECT_TRUE(ExecuteScriptAndExtractString(
- navigating_frame, "domAutomationController.send(document.title)",
- &frame_title));
- EXPECT_EQ("Title Of Awesomeness", frame_title);
+ if (IsBrowserSideNavigationEnabled()) {
+ // The blocked frame should go to an error page. Errors currently commit
+ // with the URL of the blocked page.
+ EXPECT_EQ(blocked_url, navigating_frame->current_url());
+
+ // The page should get the title of an error page (i.e "") and not the
+ // title of the blocked page.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ navigating_frame, "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("", frame_title);
+ } else {
+ // The blocked frame should stay at the old location.
+ EXPECT_EQ(old_subframe_url, navigating_frame->current_url());
+
+ // The blocked frame should keep the old title.
+ std::string frame_title;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ navigating_frame, "domAutomationController.send(document.title)",
+ &frame_title));
+ EXPECT_EQ("Title Of Awesomeness", frame_title);
+ }
// Navigate the subframe to a URL without CSP.
NavigateFrameToURL(srcdoc_frame,

Powered by Google App Engine
This is Rietveld 408576698