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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1460983002: Expose GetLastCommitedOrigin() on WebContents and use it in about:blank (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/web_contents/web_contents_impl.cc ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index acdfc42faaaa765feda34a4c57b4579f7707b8a4..a33a6aef01af5b0366a5884342b2dfec7abc0582 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -3382,4 +3382,51 @@ TEST_F(WebContentsImplTest, LoadResourceFromMemoryCacheWithEmptySecurityInfo) {
EXPECT_TRUE(backend->HasAllowException(test_url.host()));
}
+// Test to simulate and validate frame origin properties namely, uniqueness and
+// inheritance.
+TEST_F(WebContentsImplTest, WebContentsOriginInfo) {
+ // WebContent with non-standard URL has a unique origin.
+ const GURL url_ab(url::kAboutBlankURL);
+ const url::Origin origin_ab(url_ab);
+ controller().LoadURL(url_ab, Referrer(), ui::PAGE_TRANSITION_TYPED,
+ std::string());
+
+ FrameHostMsg_DidCommitProvisionalLoad_Params params1;
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
+ InitNavigateParams(&params1, 1, entry_id, true, url_ab,
+ ui::PAGE_TRANSITION_TYPED);
+ params1.origin = origin_ab;
+ contents()->GetMainFrame()->SendNavigateWithParams(&params1);
+ EXPECT_TRUE(contents()->GetLastCommittedOrigin().unique());
+
+ // An usual case where URL matches the Origin.
+ const GURL url("http://www.google.com");
+ const url::Origin origin(url);
+ controller().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED,
+ std::string());
+
+ FrameHostMsg_DidCommitProvisionalLoad_Params params2;
+ entry_id = controller().GetPendingEntry()->GetUniqueID();
+ InitNavigateParams(&params2, 1, entry_id, true, url,
+ ui::PAGE_TRANSITION_TYPED);
+ params2.origin = origin;
+ contents()->GetMainFrame()->SendNavigateWithParams(&params2);
+ EXPECT_TRUE(contents()->GetLastCommittedOrigin().IsSameOriginWith(origin));
+
+ // An 'about:blank' content inheriting origin from another content.
+ // (Not sure if this test is correct/required)
+ scoped_ptr<TestWebContents> contents2(
+ static_cast<TestWebContents*>(CreateTestWebContents()));
+ contents2->GetController().LoadURL(url_ab, Referrer(),
+ ui::PAGE_TRANSITION_LINK, std::string());
+
+ FrameHostMsg_DidCommitProvisionalLoad_Params params3;
+ entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID();
+ InitNavigateParams(&params3, -1, 0, false, url_ab, ui::PAGE_TRANSITION_LINK);
+ params3.origin = origin;
+ contents2->GetMainFrame()->SendNavigateWithParams(&params3);
+ EXPECT_TRUE(contents2->GetLastCommittedOrigin().IsSameOriginWith(
+ contents()->GetLastCommittedOrigin()));
+}
+
} // namespace content
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698