Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 7301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7312 ASSERT_TRUE(mainFrame()->isWebLocalFrame()); | 7312 ASSERT_TRUE(mainFrame()->isWebLocalFrame()); |
| 7313 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); | 7313 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); |
| 7314 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca lDOMWindow(); | 7314 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca lDOMWindow(); |
| 7315 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow) ; | 7315 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow) ; |
| 7316 ASSERT_FALSE(remoteClient.lastRequest().isNull()); | 7316 ASSERT_FALSE(remoteClient.lastRequest().isNull()); |
| 7317 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7317 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
| 7318 | 7318 |
| 7319 reset(); | 7319 reset(); |
| 7320 } | 7320 } |
| 7321 | 7321 |
| 7322 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { | |
| 7323 public: | |
| 7324 RemoteWindowCloseClient() | |
| 7325 : m_closed(false) | |
| 7326 { | |
| 7327 } | |
| 7328 | |
| 7329 void closeWidgetSoon() override | |
| 7330 { | |
| 7331 m_closed = true; | |
| 7332 } | |
| 7333 | |
| 7334 bool closed() const { return m_closed; } | |
| 7335 | |
| 7336 private: | |
| 7337 bool m_closed; | |
| 7338 }; | |
| 7339 | |
| 7340 TEST_F(WebFrameTest, WindowOpenRemoteClose) | |
| 7341 { | |
| 7342 FrameTestHelpers::WebViewHelper mainWebView; | |
| 7343 mainWebView.initialize(true); | |
| 7344 | |
| 7345 // Create a remote window that will be closed later in the test. | |
| 7346 RemoteWindowCloseClient viewClient; | |
| 7347 FrameTestHelpers::TestWebRemoteFrameClient frameClient; | |
| 7348 WebRemoteFrame* webRemoteFrame = frameClient.frame(); | |
| 7349 | |
| 7350 WebView* view = WebView::create(&viewClient); | |
| 7351 view->setMainFrame(webRemoteFrame); | |
| 7352 view->mainFrame()->setOpener(mainWebView.webView()->mainFrame()); | |
| 7353 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt p://127.0.0.1")); | |
| 7354 | |
| 7355 LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainWebView.webView()->mai nFrame())); | |
| 7356 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame())); | |
| 7357 | |
| 7358 // Attempt to close the window, which should fail as it isn't opened | |
| 7359 // by a script. | |
| 7360 remoteFrame->domWindow()->close(localFrame->document()); | |
| 7361 EXPECT_FALSE(viewClient.closed()); | |
| 7362 | |
| 7363 // Marking it as opened by a script should now allow it to be closed. | |
| 7364 remoteFrame->page()->setOpenedByDOM(); | |
| 7365 remoteFrame->domWindow()->close(localFrame->document()); | |
| 7366 EXPECT_TRUE(viewClient.closed()); | |
| 7367 | |
| 7368 mainWebView.reset(); | |
|
dcheng
2015/06/20 00:41:32
Nit: probably not needed, since WebViewHelper shou
nasko
2015/06/22 12:47:44
There is indeed a use-after-free happening in Open
dcheng
2015/06/23 21:40:55
That's unexpected. Can you see if setOpener() is g
| |
| 7369 view->close(); | |
| 7370 } | |
| 7371 | |
| 7322 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7372 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 7323 public: | 7373 public: |
| 7324 explicit CommitTypeWebFrameClient() | 7374 explicit CommitTypeWebFrameClient() |
| 7325 : m_historyCommitType(WebHistoryInertCommit) | 7375 : m_historyCommitType(WebHistoryInertCommit) |
| 7326 { | 7376 { |
| 7327 } | 7377 } |
| 7328 | 7378 |
| 7329 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override | 7379 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override |
| 7330 { | 7380 { |
| 7331 m_historyCommitType = historyCommitType; | 7381 m_historyCommitType = historyCommitType; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7735 | 7785 |
| 7736 TEST_F(WebFrameTest, MaxFramesDetach) | 7786 TEST_F(WebFrameTest, MaxFramesDetach) |
| 7737 { | 7787 { |
| 7738 registerMockedHttpURLLoad("max-frames-detach.html"); | 7788 registerMockedHttpURLLoad("max-frames-detach.html"); |
| 7739 FrameTestHelpers::WebViewHelper webViewHelper; | 7789 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7740 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); | 7790 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); |
| 7741 webViewImpl->mainFrameImpl()->collectGarbage(); | 7791 webViewImpl->mainFrameImpl()->collectGarbage(); |
| 7742 } | 7792 } |
| 7743 | 7793 |
| 7744 } // namespace blink | 7794 } // namespace blink |
| OLD | NEW |