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

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

Issue 1408073006: Gracefully handle a self-referential opener in frame swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 5 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/web/WebFrame.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6b7dc1cb821a62c90cf1536adab0b1cd25e735ca..4bd961be8bcc9040eb44b008b6d492d5c3204bf7 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -7617,6 +7617,28 @@ TEST_F(WebFrameTest, NavigateRemoteToLocalWithOpener)
popupView->close();
}
+TEST_F(WebFrameTest, SwapWithOpenerCycle)
+{
+ // First, create a remote main frame with itself as the opener.
+ FrameTestHelpers::TestWebViewClient viewClient;
+ WebView* view = WebView::create(&viewClient);
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
+ view->setMainFrame(remoteFrame);
+ remoteFrame->setOpener(remoteFrame);
+
+ // Now swap in a local frame. It shouldn't crash.
+ FrameTestHelpers::TestWebFrameClient localClient;
+ WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
+ localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None);
+ remoteFrame->swap(localFrame);
+
+ // And the opener cycle should still be preserved.
+ EXPECT_EQ(localFrame, localFrame->opener());
+
+ view->close();
+}
+
class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
explicit CommitTypeWebFrameClient()
« no previous file with comments | « third_party/WebKit/Source/web/WebFrame.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698