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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1413093007: OOPIF: Use the same uniqueName when swapping between local and remote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Preserve uniqueName Created 5 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: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index b8569141e49de10c9c18dc416b2bf5e9d569d653..3220608786633180ff2225e101ff8720b70e8651 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -7473,6 +7473,58 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
remoteFrame->close();
}
+// The uniqueName should be preserved when swapping to a RemoteFrame and back,
+// whether the frame has a name or not.
+TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap)
+{
+ // Start with a named frame.
+ WebFrame* targetFrame = mainFrame()->firstChild();
+ ASSERT_TRUE(targetFrame);
+ WebString uniqueName = targetFrame->uniqueName();
+ EXPECT_EQ("frame1", uniqueName.utf8());
+
+ // Swap to a RemoteFrame.
+ FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
+ WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
+ targetFrame->swap(remoteFrame);
+ ASSERT_TRUE(mainFrame()->firstChild());
+ ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
+ EXPECT_EQ(uniqueName.utf8(), remoteFrame->uniqueName().utf8());
+
+ // Swap back to a LocalFrame.
+ RemoteToLocalSwapWebFrameClient client(remoteFrame);
+ WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client);
+ localFrame->initializeToReplaceRemoteFrame(remoteFrame, "frame1", WebSandboxFlags::None, WebFrameOwnerProperties());
+ EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
+ FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
+ EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
+
+ // Repeat with no name on the frame.
+ localFrame->setName("");
+ WebString uniqueName2 = localFrame->uniqueName();
+ EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8());
+
+ FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
+ WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient2);
+ localFrame->swap(remoteFrame2);
+ ASSERT_TRUE(mainFrame()->firstChild());
+ ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2);
+ EXPECT_EQ(uniqueName2.utf8(), remoteFrame2->uniqueName().utf8());
+
+ RemoteToLocalSwapWebFrameClient client2(remoteFrame2);
+ WebLocalFrame* localFrame2 = WebLocalFrame::create(WebTreeScopeType::Document, &client2);
+ localFrame2->initializeToReplaceRemoteFrame(remoteFrame2, "", WebSandboxFlags::None, WebFrameOwnerProperties());
+ EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
+ FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html");
+ EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
+
+ // Manually reset to break WebViewHelper's dependency on the stack allocated
+ // TestWebFrameClient.
+ reset();
+ remoteFrame->close();
+ remoteFrame2->close();
+}
+
class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient {
public:
void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) override

Powered by Google App Engine
This is Rietveld 408576698