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

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: alexmos nits 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 int expected_routing_id) { 60 int expected_routing_id) {
61 const IPC::Message* message = 61 const IPC::Message* message =
62 rph->sink().GetUniqueMessageMatching(InputMsg_SetFocus::ID); 62 rph->sink().GetUniqueMessageMatching(InputMsg_SetFocus::ID);
63 EXPECT_TRUE(message); 63 EXPECT_TRUE(message);
64 EXPECT_EQ(expected_routing_id, message->routing_id()); 64 EXPECT_EQ(expected_routing_id, message->routing_id());
65 InputMsg_SetFocus::Param params; 65 InputMsg_SetFocus::Param params;
66 EXPECT_TRUE(InputMsg_SetFocus::Read(message, &params)); 66 EXPECT_TRUE(InputMsg_SetFocus::Read(message, &params));
67 EXPECT_EQ(expected_focus, base::get<0>(params)); 67 EXPECT_EQ(expected_focus, base::get<0>(params));
68 } 68 }
69 69
70 // Helper function for strict mixed content checking tests.
71 void CheckMixedContentIPC(TestRenderFrameHost* rfh,
72 bool expected_param,
73 int expected_routing_id) {
74 const IPC::Message* message =
75 rfh->GetProcess()->sink().GetUniqueMessageMatching(
76 FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::ID);
77 ASSERT_TRUE(message);
78 EXPECT_EQ(expected_routing_id, message->routing_id());
79 FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Param params;
80 EXPECT_TRUE(FrameMsg_DidUpdateShouldEnforceStrictMixedContentChecking::Read(
81 message, &params));
82 EXPECT_EQ(expected_param, base::get<0>(params));
83 }
84
70 class RenderFrameHostManagerTestWebUIControllerFactory 85 class RenderFrameHostManagerTestWebUIControllerFactory
71 : public WebUIControllerFactory { 86 : public WebUIControllerFactory {
72 public: 87 public:
73 RenderFrameHostManagerTestWebUIControllerFactory() 88 RenderFrameHostManagerTestWebUIControllerFactory()
74 : should_create_webui_(false), type_(1) { 89 : should_create_webui_(false), type_(1) {
75 CHECK_NE(reinterpret_cast<WebUI::TypeID>(type_), WebUI::kNoWebUI); 90 CHECK_NE(reinterpret_cast<WebUI::TypeID>(type_), WebUI::kNoWebUI);
76 } 91 }
77 ~RenderFrameHostManagerTestWebUIControllerFactory() override {} 92 ~RenderFrameHostManagerTestWebUIControllerFactory() override {}
78 93
79 void set_should_create_webui(bool should_create_webui) { 94 void set_should_create_webui(bool should_create_webui) {
(...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 3151
3137 // The RenderFrameHost committed. 3152 // The RenderFrameHost committed.
3138 manager->DidNavigateFrame(speculative_host, true); 3153 manager->DidNavigateFrame(speculative_host, true);
3139 EXPECT_EQ(speculative_host, manager->current_frame_host()); 3154 EXPECT_EQ(speculative_host, manager->current_frame_host());
3140 EXPECT_EQ(next_web_ui, manager->current_frame_host()->web_ui()); 3155 EXPECT_EQ(next_web_ui, manager->current_frame_host()->web_ui());
3141 EXPECT_FALSE(GetPendingFrameHost(manager)); 3156 EXPECT_FALSE(GetPendingFrameHost(manager));
3142 EXPECT_FALSE(speculative_host->pending_web_ui()); 3157 EXPECT_FALSE(speculative_host->pending_web_ui());
3143 EXPECT_FALSE(manager->GetNavigatingWebUI()); 3158 EXPECT_FALSE(manager->GetNavigatingWebUI());
3144 } 3159 }
3145 3160
3161 // Tests that frame proxies receive updates when a frame's enforcement
3162 // of strict mixed content checking changes.
3163 TEST_F(RenderFrameHostManagerTestWithSiteIsolation,
3164 ProxiesReceiveShouldEnforceStrictMixedContentChecking) {
3165 const GURL kUrl1("http://www.google.test");
3166 const GURL kUrl2("http://www.google2.test");
3167 const GURL kUrl3("http://www.google2.test/foo");
3168
3169 contents()->NavigateAndCommit(kUrl1);
3170
3171 // Create a child frame and navigate it cross-site.
3172 main_test_rfh()->OnCreateChildFrame(
3173 main_test_rfh()->GetProcess()->GetNextRoutingID(),
3174 blink::WebTreeScopeType::Document, "frame1", blink::WebSandboxFlags::None,
3175 blink::WebFrameOwnerProperties());
3176
3177 FrameTreeNode* root = contents()->GetFrameTree()->root();
3178 RenderFrameHostManager* child = root->child_at(0)->render_manager();
3179
3180 // Navigate subframe to kUrl2.
3181 NavigationEntryImpl entry1(nullptr /* instance */, -1 /* page_id */, kUrl2,
3182 Referrer(kUrl1, blink::WebReferrerPolicyDefault),
3183 base::string16() /* title */,
3184 ui::PAGE_TRANSITION_LINK,
3185 false /* is_renderer_init */);
3186 TestRenderFrameHost* child_host =
3187 static_cast<TestRenderFrameHost*>(NavigateToEntry(child, entry1));
3188 child->DidNavigateFrame(child_host, true);
3189
3190 // Verify that parent and child are in different processes.
3191 EXPECT_NE(child_host->GetProcess(), main_test_rfh()->GetProcess());
3192
3193 // Change the parent's enforcement of strict mixed content checking,
3194 // and check that the correct IPC is sent to the child frame's
3195 // process.
3196 EXPECT_FALSE(root->current_replication_state()
3197 .should_enforce_strict_mixed_content_checking);
3198 main_test_rfh()->DidEnforceStrictMixedContentChecking();
3199 RenderFrameProxyHost* proxy_to_child =
3200 root->render_manager()->GetRenderFrameProxyHost(
3201 child_host->GetSiteInstance());
3202 ASSERT_NO_FATAL_FAILURE(
nasko 2015/12/17 17:16:33 s/ASSERT/EXPECT/
estark 2015/12/17 22:19:11 Done.
3203 CheckMixedContentIPC(child_host, true, proxy_to_child->GetRoutingID()));
3204 EXPECT_TRUE(root->current_replication_state()
3205 .should_enforce_strict_mixed_content_checking);
3206
3207 // Do the same for the child's enforcement. In general, the parent
3208 // needs to know the status of the child's flag in case a grandchild
3209 // is created: if A.com embeds B.com, and B.com enforces strict mixed
3210 // content checking, and B.com adds an iframe to A.com, then the
3211 // A.com process needs to know B.com's flag so that the grandchild
3212 // A.com frame can inherit it.
3213 EXPECT_FALSE(root->child_at(0)
3214 ->current_replication_state()
3215 .should_enforce_strict_mixed_content_checking);
3216 child_host->DidEnforceStrictMixedContentChecking();
3217 RenderFrameProxyHost* proxy_to_parent =
3218 child->GetRenderFrameProxyHost(main_test_rfh()->GetSiteInstance());
3219 ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(
3220 main_test_rfh(), true, proxy_to_parent->GetRoutingID()));
3221 EXPECT_TRUE(root->child_at(0)
3222 ->current_replication_state()
3223 .should_enforce_strict_mixed_content_checking);
3224
3225 // Check that the flag for the parent's proxy to the child is reset
3226 // when the child navigates within the same process.
nasko 2015/12/17 17:16:33 Does it matter whether the navigation is cross-pro
estark 2015/12/17 22:19:11 Hmm, no, I don't think so, not sure why I wrote th
3227 main_test_rfh()->GetProcess()->sink().ClearMessages();
3228 FrameHostMsg_DidCommitProvisionalLoad_Params commit_params;
3229 commit_params.page_id = 0;
3230 commit_params.nav_entry_id = 0;
3231 commit_params.did_create_new_entry = false;
3232 commit_params.url = kUrl3;
3233 commit_params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
3234 commit_params.should_update_history = false;
3235 commit_params.gesture = NavigationGestureAuto;
3236 commit_params.was_within_same_page = false;
3237 commit_params.is_post = false;
3238 commit_params.page_state = PageState::CreateFromURL(kUrl3);
3239 commit_params.should_enforce_strict_mixed_content_checking = false;
3240 child_host->SendNavigateWithParams(&commit_params);
3241 ASSERT_NO_FATAL_FAILURE(CheckMixedContentIPC(
3242 main_test_rfh(), false, proxy_to_parent->GetRoutingID()));
3243 EXPECT_FALSE(root->child_at(0)
3244 ->current_replication_state()
3245 .should_enforce_strict_mixed_content_checking);
3246 }
3247
3146 } // namespace content 3248 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698