Chromium Code Reviews| 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() |