Use FrameTreeNode::current_origin() in more places.
BUG=426512 TEST=No behavior change Review URL: https://codereview.chromium.org/1467783002 Cr-Commit-Position: refs/heads/master@{#360976}
This commit is contained in:
content/browser
@@ -215,26 +215,25 @@ IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, OriginSetOnNavigation) {
|
||||
// Extra '/' is added because the replicated origin is serialized in RFC 6454
|
||||
// format, which dictates no trailing '/', whereas GURL::GetOrigin does put a
|
||||
// '/' at the end.
|
||||
EXPECT_EQ(root->current_replication_state().origin.Serialize() + '/',
|
||||
EXPECT_EQ(root->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
GURL frame_url(embedded_test_server()->GetURL("/title1.html"));
|
||||
NavigateFrameToURL(root->child_at(0), frame_url);
|
||||
|
||||
EXPECT_EQ(
|
||||
root->child_at(0)->current_replication_state().origin.Serialize() + '/',
|
||||
frame_url.GetOrigin().spec());
|
||||
EXPECT_EQ(root->child_at(0)->current_origin().Serialize() + '/',
|
||||
frame_url.GetOrigin().spec());
|
||||
|
||||
GURL data_url("data:text/html,foo");
|
||||
EXPECT_TRUE(NavigateToURL(shell(), data_url));
|
||||
|
||||
// Navigating to a data URL should set a unique origin. This is represented
|
||||
// as "null" per RFC 6454.
|
||||
EXPECT_EQ(root->current_replication_state().origin.Serialize(), "null");
|
||||
EXPECT_EQ(root->current_origin().Serialize(), "null");
|
||||
|
||||
// Re-navigating to a normal URL should update the origin.
|
||||
EXPECT_TRUE(NavigateToURL(shell(), main_url));
|
||||
EXPECT_EQ(root->current_replication_state().origin.Serialize() + '/',
|
||||
EXPECT_EQ(root->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
}
|
||||
|
||||
@@ -266,13 +265,10 @@ IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SandboxFlagsSetForChildFrames) {
|
||||
|
||||
// Sandboxed frames should set a unique origin unless they have the
|
||||
// "allow-same-origin" directive.
|
||||
EXPECT_EQ(root->child_at(0)->current_replication_state().origin.Serialize(),
|
||||
"null");
|
||||
EXPECT_EQ(root->child_at(1)->current_replication_state().origin.Serialize(),
|
||||
"null");
|
||||
EXPECT_EQ(
|
||||
root->child_at(2)->current_replication_state().origin.Serialize() + "/",
|
||||
main_url.GetOrigin().spec());
|
||||
EXPECT_EQ(root->child_at(0)->current_origin().Serialize(), "null");
|
||||
EXPECT_EQ(root->child_at(1)->current_origin().Serialize(), "null");
|
||||
EXPECT_EQ(root->child_at(2)->current_origin().Serialize() + "/",
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
// Navigating to a different URL should not clear sandbox flags.
|
||||
GURL frame_url(embedded_test_server()->GetURL("/title1.html"));
|
||||
@@ -393,32 +389,29 @@ IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest,
|
||||
FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
|
||||
->GetFrameTree()->root();
|
||||
|
||||
EXPECT_EQ(root->current_replication_state().origin.Serialize() + '/',
|
||||
EXPECT_EQ(root->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
// First frame is an about:blank frame. Check that its origin is correctly
|
||||
// inherited from the parent.
|
||||
EXPECT_EQ(
|
||||
root->child_at(0)->current_replication_state().origin.Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
EXPECT_EQ(root->child_at(0)->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
// Second frame loads a same-site page. Its origin should also be the same
|
||||
// as the parent.
|
||||
EXPECT_EQ(
|
||||
root->child_at(1)->current_replication_state().origin.Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
EXPECT_EQ(root->child_at(1)->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
// Load cross-site page into the first frame.
|
||||
GURL cross_site_url(
|
||||
embedded_test_server()->GetURL("foo.com", "/title2.html"));
|
||||
NavigateFrameToURL(root->child_at(0), cross_site_url);
|
||||
|
||||
EXPECT_EQ(
|
||||
root->child_at(0)->current_replication_state().origin.Serialize() + '/',
|
||||
cross_site_url.GetOrigin().spec());
|
||||
EXPECT_EQ(root->child_at(0)->current_origin().Serialize() + '/',
|
||||
cross_site_url.GetOrigin().spec());
|
||||
|
||||
// The root's origin shouldn't have changed.
|
||||
EXPECT_EQ(root->current_replication_state().origin.Serialize() + '/',
|
||||
EXPECT_EQ(root->current_origin().Serialize() + '/',
|
||||
main_url.GetOrigin().spec());
|
||||
|
||||
GURL data_url("data:text/html,foo");
|
||||
@@ -426,8 +419,7 @@ IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest,
|
||||
|
||||
// Navigating to a data URL should set a unique origin. This is represented
|
||||
// as "null" per RFC 6454.
|
||||
EXPECT_EQ(root->child_at(1)->current_replication_state().origin.Serialize(),
|
||||
"null");
|
||||
EXPECT_EQ(root->child_at(1)->current_origin().Serialize(), "null");
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@@ -2785,8 +2785,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) {
|
||||
" parent.frames['frame2'].location.href = 'data:text/html,foo');"));
|
||||
console_delegate->Wait();
|
||||
|
||||
std::string frame_origin =
|
||||
root->child_at(1)->current_replication_state().origin.Serialize();
|
||||
std::string frame_origin = root->child_at(1)->current_origin().Serialize();
|
||||
EXPECT_EQ(frame_origin + "/", frame_url.GetOrigin().spec());
|
||||
EXPECT_TRUE(
|
||||
base::MatchPattern(console_delegate->message(), "*" + frame_origin + "*"))
|
||||
|
Reference in New Issue
Block a user