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