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

Unified Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 1489253002: Plumb document's strict mixed content checking for RemoteFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix transition type for test crashes Created 5 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/frame_host/render_frame_host_manager_unittest.cc
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc
index 8c157958e09a419cd9cc30454cbc74fee1cfe436..209f2b12c75c0469dff7df557e7bd756b2940ec8 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -3143,4 +3143,82 @@ TEST_F(RenderFrameHostManagerTestWithBrowserSideNavigation,
EXPECT_FALSE(manager->GetNavigatingWebUI());
}
+namespace {
+
+// Helper function for strict mixed content checking tests.
+void CheckMixedContentIPC(TestRenderFrameHost* rfh, bool expected_param) {
alexmos 2015/12/11 02:52:27 nit: maybe put this on top in the existing anonymo
estark 2015/12/12 01:35:43 Done.
+ const IPC::Message* message =
+ rfh->GetProcess()->sink().GetUniqueMessageMatching(
+ FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::ID);
+ ASSERT_TRUE(message);
alexmos 2015/12/11 02:52:27 Could we also verify that the message's routing ID
estark 2015/12/12 01:35:43 Done.
+ FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Param params;
+ EXPECT_TRUE(FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Read(
+ message, &params));
+ EXPECT_EQ(expected_param, base::get<0>(params));
+ rfh->GetProcess()->sink().ClearMessages();
+}
+
+} // namespace
+
+// Tests that frame proxies receive updates when a frame's enforcement
+// of strict mixed content checking changes.
+TEST_F(RenderFrameHostManagerTestWithSiteIsolation,
+ ProxiesReceiveShouldEnforceStrictMixedContentChecking) {
+ const GURL kUrl1("http://www.google.test");
+ const GURL kUrl2("http://www.google2.test");
+ const GURL kUrl3("http://www.google2.test/foo");
+
+ contents()->NavigateAndCommit(kUrl1);
+
+ // Create a child frame and navigate it cross-site.
+ main_test_rfh()->OnCreateChildFrame(
+ main_test_rfh()->GetProcess()->GetNextRoutingID(),
+ blink::WebTreeScopeType::Document, "frame1", blink::WebSandboxFlags::None,
+ blink::WebFrameOwnerProperties());
+
+ FrameTreeNode* root = contents()->GetFrameTree()->root();
+ RenderFrameHostManager* child = root->child_at(0)->render_manager();
+
+ // Navigate subframe to kUrl2.
+ NavigationEntryImpl entry1(nullptr /* instance */, -1 /* page_id */, kUrl2,
+ Referrer(kUrl1, blink::WebReferrerPolicyDefault),
+ base::string16() /* title */,
+ ui::PAGE_TRANSITION_LINK,
+ false /* is_renderer_init */);
+ TestRenderFrameHost* child_host =
+ static_cast<TestRenderFrameHost*>(NavigateToEntry(child, entry1));
+ child->DidNavigateFrame(child_host, true);
+
+ // Verify that parent and child are in different processes.
+ EXPECT_NE(child_host->GetProcess(), main_test_rfh()->GetProcess());
+
+ // Change the parent's enforcement of strict mixed content checking,
+ // and check that the correct IPC is sent to the child frame's
+ // process.
+ main_test_rfh()->OnDidEnforceStrictMixedContentChecking();
alexmos 2015/12/11 02:52:27 Can we also check that the bit in the correspondin
estark 2015/12/12 01:35:43 Done.
+ ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(child_host, true));
+
+ // Do the same for the child's enforcement.
+ child_host->OnDidEnforceStrictMixedContentChecking();
+ ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(main_test_rfh(), true));
alexmos 2015/12/11 02:52:27 It might be good to document somewhere (here?) why
estark 2015/12/12 01:35:43 Yeah, that sounds right. Added a comment here.
+
+ // Check that the flag for the parent's proxy to the child is reset
+ // when the child navigates within the same process.
+ main_test_rfh()->GetProcess()->sink().ClearMessages();
alexmos 2015/12/11 02:52:27 nit: CheckMixedContentIPC also clears messages in
estark 2015/12/12 01:35:43 Done.
+ FrameHostMsg_DidCommitProvisionalLoad_Params commit_params;
+ commit_params.page_id = 0;
+ commit_params.nav_entry_id = 0;
+ commit_params.did_create_new_entry = false;
+ commit_params.url = kUrl3;
+ commit_params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
+ commit_params.should_update_history = false;
+ commit_params.gesture = NavigationGestureAuto;
+ commit_params.was_within_same_page = false;
+ commit_params.is_post = false;
+ commit_params.page_state = PageState::CreateFromURL(kUrl3);
+ commit_params.should_enforce_strict_mixed_content_checking = false;
+ child_host->SendNavigateWithParams(&commit_params);
alexmos 2015/12/11 02:52:27 Similarly, can we check that the replication state
estark 2015/12/12 01:35:43 Done.
+ ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(main_test_rfh(), false));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698