| 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 7356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7367 ASSERT_TRUE(mainFrame()->isWebLocalFrame()); | 7367 ASSERT_TRUE(mainFrame()->isWebLocalFrame()); |
| 7368 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); | 7368 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); |
| 7369 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca
lDOMWindow(); | 7369 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca
lDOMWindow(); |
| 7370 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow)
; | 7370 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow)
; |
| 7371 ASSERT_FALSE(remoteClient.lastRequest().isNull()); | 7371 ASSERT_FALSE(remoteClient.lastRequest().isNull()); |
| 7372 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7372 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
| 7373 | 7373 |
| 7374 reset(); | 7374 reset(); |
| 7375 } | 7375 } |
| 7376 | 7376 |
| 7377 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { |
| 7378 public: |
| 7379 RemoteWindowCloseClient() |
| 7380 : m_closed(false) |
| 7381 { |
| 7382 } |
| 7383 |
| 7384 void closeWidgetSoon() override |
| 7385 { |
| 7386 m_closed = true; |
| 7387 } |
| 7388 |
| 7389 bool closed() const { return m_closed; } |
| 7390 |
| 7391 private: |
| 7392 bool m_closed; |
| 7393 }; |
| 7394 |
| 7395 TEST_F(WebFrameTest, WindowOpenRemoteClose) |
| 7396 { |
| 7397 FrameTestHelpers::WebViewHelper mainWebView; |
| 7398 mainWebView.initialize(true); |
| 7399 |
| 7400 // Create a remote window that will be closed later in the test. |
| 7401 RemoteWindowCloseClient viewClient; |
| 7402 FrameTestHelpers::TestWebRemoteFrameClient frameClient; |
| 7403 WebRemoteFrame* webRemoteFrame = frameClient.frame(); |
| 7404 |
| 7405 WebView* view = WebView::create(&viewClient); |
| 7406 view->setMainFrame(webRemoteFrame); |
| 7407 view->mainFrame()->setOpener(mainWebView.webView()->mainFrame()); |
| 7408 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt
p://127.0.0.1")); |
| 7409 |
| 7410 LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainWebView.webView()->mai
nFrame())); |
| 7411 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame())); |
| 7412 |
| 7413 // Attempt to close the window, which should fail as it isn't opened |
| 7414 // by a script. |
| 7415 remoteFrame->domWindow()->close(localFrame->document()); |
| 7416 EXPECT_FALSE(viewClient.closed()); |
| 7417 |
| 7418 // Marking it as opened by a script should now allow it to be closed. |
| 7419 remoteFrame->page()->setOpenedByDOM(); |
| 7420 remoteFrame->domWindow()->close(localFrame->document()); |
| 7421 EXPECT_TRUE(viewClient.closed()); |
| 7422 |
| 7423 view->close(); |
| 7424 } |
| 7425 |
| 7377 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7426 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 7378 public: | 7427 public: |
| 7379 explicit CommitTypeWebFrameClient() | 7428 explicit CommitTypeWebFrameClient() |
| 7380 : m_historyCommitType(WebHistoryInertCommit) | 7429 : m_historyCommitType(WebHistoryInertCommit) |
| 7381 { | 7430 { |
| 7382 } | 7431 } |
| 7383 | 7432 |
| 7384 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist
oryCommitType historyCommitType) override | 7433 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist
oryCommitType historyCommitType) override |
| 7385 { | 7434 { |
| 7386 m_historyCommitType = historyCommitType; | 7435 m_historyCommitType = historyCommitType; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7790 | 7839 |
| 7791 TEST_F(WebFrameTest, MaxFramesDetach) | 7840 TEST_F(WebFrameTest, MaxFramesDetach) |
| 7792 { | 7841 { |
| 7793 registerMockedHttpURLLoad("max-frames-detach.html"); | 7842 registerMockedHttpURLLoad("max-frames-detach.html"); |
| 7794 FrameTestHelpers::WebViewHelper webViewHelper; | 7843 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7795 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); | 7844 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); |
| 7796 webViewImpl->mainFrameImpl()->collectGarbage(); | 7845 webViewImpl->mainFrameImpl()->collectGarbage(); |
| 7797 } | 7846 } |
| 7798 | 7847 |
| 7799 } // namespace blink | 7848 } // namespace blink |
| OLD | NEW |