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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
(...skipping 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 3136
3137 // The RenderFrameHost committed. 3137 // The RenderFrameHost committed.
3138 manager->DidNavigateFrame(speculative_host, true); 3138 manager->DidNavigateFrame(speculative_host, true);
3139 EXPECT_EQ(speculative_host, manager->current_frame_host()); 3139 EXPECT_EQ(speculative_host, manager->current_frame_host());
3140 EXPECT_EQ(next_web_ui, manager->current_frame_host()->web_ui()); 3140 EXPECT_EQ(next_web_ui, manager->current_frame_host()->web_ui());
3141 EXPECT_FALSE(GetPendingFrameHost(manager)); 3141 EXPECT_FALSE(GetPendingFrameHost(manager));
3142 EXPECT_FALSE(speculative_host->pending_web_ui()); 3142 EXPECT_FALSE(speculative_host->pending_web_ui());
3143 EXPECT_FALSE(manager->GetNavigatingWebUI()); 3143 EXPECT_FALSE(manager->GetNavigatingWebUI());
3144 } 3144 }
3145 3145
3146 namespace {
3147
3148 // Helper function for strict mixed content checking tests.
3149 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.
3150 const IPC::Message* message =
3151 rfh->GetProcess()->sink().GetUniqueMessageMatching(
3152 FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::ID);
3153 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.
3154 FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Param params;
3155 EXPECT_TRUE(FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Read(
3156 message, &params));
3157 EXPECT_EQ(expected_param, base::get<0>(params));
3158 rfh->GetProcess()->sink().ClearMessages();
3159 }
3160
3161 } // namespace
3162
3163 // Tests that frame proxies receive updates when a frame's enforcement
3164 // of strict mixed content checking changes.
3165 TEST_F(RenderFrameHostManagerTestWithSiteIsolation,
3166 ProxiesReceiveShouldEnforceStrictMixedContentChecking) {
3167 const GURL kUrl1("http://www.google.test");
3168 const GURL kUrl2("http://www.google2.test");
3169 const GURL kUrl3("http://www.google2.test/foo");
3170
3171 contents()->NavigateAndCommit(kUrl1);
3172
3173 // Create a child frame and navigate it cross-site.
3174 main_test_rfh()->OnCreateChildFrame(
3175 main_test_rfh()->GetProcess()->GetNextRoutingID(),
3176 blink::WebTreeScopeType::Document, "frame1", blink::WebSandboxFlags::None,
3177 blink::WebFrameOwnerProperties());
3178
3179 FrameTreeNode* root = contents()->GetFrameTree()->root();
3180 RenderFrameHostManager* child = root->child_at(0)->render_manager();
3181
3182 // Navigate subframe to kUrl2.
3183 NavigationEntryImpl entry1(nullptr /* instance */, -1 /* page_id */, kUrl2,
3184 Referrer(kUrl1, blink::WebReferrerPolicyDefault),
3185 base::string16() /* title */,
3186 ui::PAGE_TRANSITION_LINK,
3187 false /* is_renderer_init */);
3188 TestRenderFrameHost* child_host =
3189 static_cast<TestRenderFrameHost*>(NavigateToEntry(child, entry1));
3190 child->DidNavigateFrame(child_host, true);
3191
3192 // Verify that parent and child are in different processes.
3193 EXPECT_NE(child_host->GetProcess(), main_test_rfh()->GetProcess());
3194
3195 // Change the parent's enforcement of strict mixed content checking,
3196 // and check that the correct IPC is sent to the child frame's
3197 // process.
3198 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.
3199 ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(child_host, true));
3200
3201 // Do the same for the child's enforcement.
3202 child_host->OnDidEnforceStrictMixedContentChecking();
3203 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.
3204
3205 // Check that the flag for the parent's proxy to the child is reset
3206 // when the child navigates within the same process.
3207 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.
3208 FrameHostMsg_DidCommitProvisionalLoad_Params commit_params;
3209 commit_params.page_id = 0;
3210 commit_params.nav_entry_id = 0;
3211 commit_params.did_create_new_entry = false;
3212 commit_params.url = kUrl3;
3213 commit_params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
3214 commit_params.should_update_history = false;
3215 commit_params.gesture = NavigationGestureAuto;
3216 commit_params.was_within_same_page = false;
3217 commit_params.is_post = false;
3218 commit_params.page_state = PageState::CreateFromURL(kUrl3);
3219 commit_params.should_enforce_strict_mixed_content_checking = false;
3220 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.
3221 ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(main_test_rfh(), false));
3222 }
3223
3146 } // namespace content 3224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698