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

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

Issue 544443002: Detach all subframes before swapping a frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove ASSERT in detachChildren, since FrameLoader::commitProvisionalLoad can hit it with ref count… Created 6 years, 3 months 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: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 264c4f204e40c854e67ce2b38e4f3701ae980905..734e65840ed9b1e983fe7940028eae1e7ef7e54a 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -6069,6 +6069,49 @@ TEST_F(WebFrameSwapTest, SwapLastChild)
remoteFrame->close();
}
+void swapAndVerifySubframeConsistency(const char* const message, WebFrame* oldFrame, WebFrame* newFrame)
+{
+ SCOPED_TRACE(message);
+
+ EXPECT_TRUE(oldFrame->firstChild());
+ oldFrame->swap(newFrame);
+
+ EXPECT_FALSE(newFrame->firstChild());
+ EXPECT_FALSE(newFrame->lastChild());
+}
+
+TEST_F(WebFrameSwapTest, SwapParentShouldDetachChildren)
+{
+ WebRemoteFrame* remoteFrame = WebRemoteFrame::create(0);
+ WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
+ EXPECT_TRUE(targetFrame);
+ swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
+
+ targetFrame = mainFrame()->firstChild()->nextSibling();
+ EXPECT_TRUE(targetFrame);
+
+ // Create child frames in the target frame before testing the swap.
+ FrameTestHelpers::TestWebFrameClient remoteFrameClient;
+ remoteFrame->createRemoteChild("", &remoteFrameClient);
+
+ FrameTestHelpers::TestWebFrameClient client;
+ WebFrame* localFrame = WebLocalFrame::create(&client);
+ swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
+
+ // FIXME: This almost certainly fires more load events on the iframe element
+ // than it should.
+ // Finally, make sure an embedder triggered load in the local frame swapped
+ // back in works.
+ FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
+ std::string content = localFrame->contentAsText(1024).utf8();
+ EXPECT_EQ("hello", content);
+
+ // Manually reset to break WebViewHelper's dependency on the stack allocated
+ // TestWebFrameClient.
+ reset();
+ remoteFrame->close();
+}
+
class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
public:
MockDocumentThreadableLoaderClient() : m_failed(false) { }

Powered by Google App Engine
This is Rietveld 408576698