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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 692973005: Pass origin information for remote frame creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback; send origins with DidCommitProvisionalLoad Created 6 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
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 7dc2da83b5084b2b94c45ab91cd003b9bcd31beb..8c74129b9a859217ce5a581f094bbe55682f1577 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/bindings_policy.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
@@ -546,7 +547,8 @@ TEST_F(RenderViewImplTest, SendSwapOutACK) {
RenderProcess::current()->AddRefProcess();
// Respond to a swap out request.
- view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId,
+ content::FrameReplicationState());
// Ensure the swap out commits synchronously.
EXPECT_NE(initial_page_id, view_page_id());
@@ -559,7 +561,8 @@ TEST_F(RenderViewImplTest, SendSwapOutACK) {
// It is possible to get another swap out request. Ensure that we send
// an ACK, even if we don't have to do anything else.
render_thread_->sink().ClearMessages();
- view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId,
+ content::FrameReplicationState());
const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_SwapOut_ACK::ID);
ASSERT_TRUE(msg2);
@@ -619,7 +622,8 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
ProcessPendingMessages();
// Respond to a swap out request.
- view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId,
+ content::FrameReplicationState());
// Check for a OnSwapOutACK.
const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
@@ -658,6 +662,33 @@ TEST_F(RenderViewImplTest, ReloadWhileSwappedOut) {
EXPECT_NE(GURL("swappedout://"), commit_params.a.url);
}
+// Verify that security origins are replicated properly to RenderFrameProxies
+// when swapping out.
+TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) {
+ // This test should only run with --site-per-process, since origin
+ // replication only happens in that mode.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess))
+ return;
+
+ LoadHTML("Hello <iframe src='data:text/html,world' name='frame'></iframe>");
+ RenderFrameImpl* child_frame = static_cast<RenderFrameImpl*>(
+ RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild()));
+
+ // Swap the child frame out and pass a serialized origin to be set for
+ // WebRemoteFrame.
+ content::FrameReplicationState replication_state;
+ replication_state.origin = url::Origin("http://foo.com");
+ child_frame->OnSwapOut(kProxyRoutingId, replication_state);
+
+ // The child frame should now be a WebRemoteFrame.
+ EXPECT_TRUE(frame()->GetWebFrame()->firstChild()->isWebRemoteFrame());
+
+ // Expect the origin to be updated properly.
+ blink::WebSecurityOrigin origin =
+ frame()->GetWebFrame()->firstChild()->securityOrigin();
Charlie Reis 2014/11/19 00:46:18 Great. Thanks for adding this test.
+ EXPECT_EQ(origin.toString(),
+ WebString::fromUTF8(replication_state.origin.string()));
+}
// Test that we get the correct UpdateState message when we go back twice
// quickly without committing. Regression test for http://crbug.com/58082.

Powered by Google App Engine
This is Rietveld 408576698