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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(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
7341 {
7342 // Create a remote window that will be closed later in the test.
7343 RemoteWindowCloseClient viewClient;
7344 FrameTestHelpers::TestWebRemoteFrameClient frameClient;
7345 WebRemoteFrame* webRemoteFrame = frameClient.frame();
7346
7347 WebView* view = WebView::create(&viewClient);
7348 view->setMainFrame(webRemoteFrame);
7349 view->mainFrame()->setOpener(mainFrame());
7350 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt p://127.0.0.1"));
7351
7352 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.
7353 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame()));
7354
7355 // Attempt to close the window, which should fail as it isn't opened
7356 // by a script.
7357 remoteFrame->domWindow()->close(localFrame->document());
7358 EXPECT_FALSE(viewClient.closed());
7359
7360 // Marking it as opened by a script should now allow it to be closed.
7361 remoteFrame->page()->setOpenedByDOM();
7362 remoteFrame->domWindow()->close(localFrame->document());
7363 EXPECT_TRUE(viewClient.closed());
7364
7365 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
7366 }
7367
7322 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7368 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7323 public: 7369 public:
7324 explicit CommitTypeWebFrameClient() 7370 explicit CommitTypeWebFrameClient()
7325 : m_historyCommitType(WebHistoryInertCommit) 7371 : m_historyCommitType(WebHistoryInertCommit)
7326 { 7372 {
7327 } 7373 }
7328 7374
7329 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override 7375 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override
7330 { 7376 {
7331 m_historyCommitType = historyCommitType; 7377 m_historyCommitType = historyCommitType;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
7735 7781
7736 TEST_F(WebFrameTest, MaxFramesDetach) 7782 TEST_F(WebFrameTest, MaxFramesDetach)
7737 { 7783 {
7738 registerMockedHttpURLLoad("max-frames-detach.html"); 7784 registerMockedHttpURLLoad("max-frames-detach.html");
7739 FrameTestHelpers::WebViewHelper webViewHelper; 7785 FrameTestHelpers::WebViewHelper webViewHelper;
7740 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 7786 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
7741 webViewImpl->mainFrameImpl()->collectGarbage(); 7787 webViewImpl->mainFrameImpl()->collectGarbage();
7742 } 7788 }
7743 7789
7744 } // namespace blink 7790 } // namespace blink
OLDNEW
« 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