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

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

Issue 2631233003: Avoid mutating frame owner when detaching a provisional frame. (Closed)
Patch Set: Fix test to actually test the changed behavior. Created 3 years, 11 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: 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 e280ce94e14f36d2e8dfc195b0808cd36a294bd9..853ab22c8aed5f51e69dd8ae1c5d15021bddde67 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -8729,6 +8729,38 @@ TEST_F(WebFrameSwapTest, SwapLastChild) {
remoteFrame->close();
}
+TEST_F(WebFrameSwapTest, DetachProvisionalFrame) {
+ FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
+ WebRemoteFrameImpl* remoteFrame = WebRemoteFrameImpl::create(
+ WebTreeScopeType::Document, &remoteFrameClient);
+ swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(),
+ remoteFrame);
+
+ FrameTestHelpers::TestWebFrameClient client;
+ WebLocalFrameImpl* provisionalFrame = WebLocalFrameImpl::createProvisional(
+ &client, remoteFrame, WebSandboxFlags::None);
+
+ // The provisional frame should have a local frame owner.
+ FrameOwner* owner = provisionalFrame->frame()->owner();
+ ASSERT_TRUE(owner->isLocal());
+
+ // But the owner should point to |remoteFrame|, since the new frame is still
+ // provisional.
+ EXPECT_EQ(remoteFrame->frame(), owner->contentFrame());
+
+ // After detaching the provisional frame, the frame owner should still point
+ // at |remoteFrame|.
+ provisionalFrame->detach();
+
+ // The owner should not be affected by detaching the provisional frame, so it
+ // should still point to |remoteFrame|.
+ EXPECT_EQ(remoteFrame->frame(), owner->contentFrame());
+
+ // Manually reset to break WebViewHelper's dependency on the stack allocated
+ // TestWebFrameClient.
+ reset();
+}
+
void WebFrameTest::swapAndVerifySubframeConsistency(const char* const message,
WebFrame* oldFrame,
WebFrame* newFrame) {

Powered by Google App Engine
This is Rietveld 408576698