Index: Source/web/tests/WebFrameTest.cpp |
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
index 13ac82a2d3e4a6277c71f68531d02cfa5aa62091..6fddb1476c9cbfe8acf99383fa8250fca2c6992b 100644 |
--- a/Source/web/tests/WebFrameTest.cpp |
+++ b/Source/web/tests/WebFrameTest.cpp |
@@ -6914,6 +6914,35 @@ TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) |
remoteFrame->close(); |
} |
+TEST_F(WebFrameSwapTest, SwapInitializesGlobal) |
+{ |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ |
+ v8::Local<v8::Value> windowTop = mainFrame()->executeScriptAndReturnValue(WebScriptSource("window")); |
+ ASSERT_TRUE(windowTop->IsObject()); |
+ |
+ v8::Local<v8::Value> lastChild = mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved = window[2]")); |
+ ASSERT_TRUE(lastChild->IsObject()); |
+ |
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
+ WebRemoteFrame* remoteFrame = remoteClient.frame(); |
+ mainFrame()->lastChild()->swap(remoteFrame); |
+ remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
+ v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top")); |
+ EXPECT_TRUE(remoteWindowTop->IsObject()); |
+ EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
+ |
+ FrameTestHelpers::TestWebFrameClient client; |
+ WebLocalFrame* localFrame = WebLocalFrame::create(&client); |
+ localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
+ remoteFrame->swap(localFrame); |
+ v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top")); |
+ EXPECT_TRUE(localWindowTop->IsObject()); |
+ EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
+ |
+ reset(); |
+} |
+ |
TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) |
{ |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |