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

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

Issue 1176843006: Move window.close implementation to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 6 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 4ba5c6abac73a93313e60c7177fdb4f04f4f4ab2..85e06f14f916fa21ac91b01b01ee7b93d3ca05b3 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -7313,6 +7313,51 @@ TEST_F(WebFrameSwapTest, WindowOpenOnRemoteFrame)
reset();
}
+class RemoteWindowCloseClient : public FrameTestHelpers::TestWebRemoteFrameClient {
+public:
+ void close() override
+ {
+ m_closed = true;
+ }
+
+ bool closed() const { return m_closed; }
+
+private:
+ bool m_closed;
+};
+
+TEST_F(WebFrameSwapTest, WindowOpenRemoteClose)
+{
+ // Create another window that will be closed later in the test.
+ FrameTestHelpers::WebViewHelper newWebViewHelper;
+ WebView* newView = newWebViewHelper.initialize(true);
+ newView->mainFrame()->setOpener(mainFrame());
+ newView->mainFrame()->setName("foo");
+ runPendingTasks();
dcheng 2015/06/11 02:00:06 Is this necessary? If so, it'd be nice to document
+
+ // Swap the new window to be remote.
+ RemoteWindowCloseClient remoteClient;
+ WebRemoteFrame* webRemoteFrame = remoteClient.frame();
+ newView->mainFrame()->swap(webRemoteFrame);
+ webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http://127.0.0.1"));
+
+ LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainFrame()));
+ RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(webRemoteFrame));
+
+ // Attempt to close the window, which should fail as it isn't opened
+ // by a script.
+ remoteFrame->domWindow()->close(localFrame->document());
+ EXPECT_FALSE(remoteClient.closed());
+
+ // Marking it as opened by a script should now allow it to be closed.
+ remoteFrame->page()->setOpenedByDOM();
+ remoteFrame->domWindow()->close(localFrame->document());
+ EXPECT_TRUE(remoteClient.closed());
+
+ reset();
+}
+
+
class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
explicit CommitTypeWebFrameClient()

Powered by Google App Engine
This is Rietveld 408576698