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

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 and move backForwardHistory to FrameClient. 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
« Source/web/ChromeClientImpl.cpp ('K') | « Source/web/RemoteFrameClientImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 1208021f7abebdf6548dd1789490172c44c63c5e..9082b000bd1dfe235b14072b790061252b3da531 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -7319,6 +7319,52 @@ TEST_F(WebFrameSwapTest, WindowOpenOnRemoteFrame)
reset();
}
+class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient {
+public:
+ RemoteWindowCloseClient()
+ : m_closed(false)
+ {
+ }
+
+ void closeWidgetSoon() override
+ {
+ m_closed = true;
+ }
+
+ bool closed() const { return m_closed; }
+
+private:
+ bool m_closed;
+};
+
+TEST_F(WebFrameSwapTest, WindowOpenRemoteClose)
dcheng 2015/06/17 23:39:50 I don't think there's any need to inherit from the
nasko 2015/06/19 13:23:22 Do you mean inherit just from WebFrameTest instead
+{
+ // Create a remote window that will be closed later in the test.
+ RemoteWindowCloseClient viewClient;
+ FrameTestHelpers::TestWebRemoteFrameClient frameClient;
+ WebRemoteFrame* webRemoteFrame = frameClient.frame();
+
+ WebView* view = WebView::create(&viewClient);
+ view->setMainFrame(webRemoteFrame);
+ view->mainFrame()->setOpener(mainFrame());
+ webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http://127.0.0.1"));
+
+ LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainFrame()));
dcheng 2015/06/17 23:39:50 Let's just use FrameTestHelpers::WebViewHelper dir
nasko 2015/06/19 13:23:22 I'm not sure I follow here. I've changed this test
dcheng 2015/06/20 00:41:32 What you have now is fine.
+ RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame()));
+
+ // Attempt to close the window, which should fail as it isn't opened
+ // by a script.
+ remoteFrame->domWindow()->close(localFrame->document());
+ EXPECT_FALSE(viewClient.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(viewClient.closed());
+
+ reset();
dcheng 2015/06/17 23:39:50 Make sure you call view->close() and whatever else
nasko 2015/06/19 13:23:22 I thought view->close() is equivalent to the above
+}
+
class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
explicit CommitTypeWebFrameClient()
« Source/web/ChromeClientImpl.cpp ('K') | « Source/web/RemoteFrameClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698