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

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: Cleanup some leftover changes. 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 7295 matching lines...) Expand 10 before | Expand all | Expand 10 after
7306 ASSERT_TRUE(mainFrame()->isWebLocalFrame()); 7306 ASSERT_TRUE(mainFrame()->isWebLocalFrame());
7307 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); 7307 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame());
7308 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca lDOMWindow(); 7308 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca lDOMWindow();
7309 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow) ; 7309 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow) ;
7310 ASSERT_FALSE(remoteClient.lastRequest().isNull()); 7310 ASSERT_FALSE(remoteClient.lastRequest().isNull());
7311 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); 7311 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination));
7312 7312
7313 reset(); 7313 reset();
7314 } 7314 }
7315 7315
7316 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient {
7317 public:
7318 void closeWidgetSoon() override
7319 {
7320 m_closed = true;
7321 }
7322
7323 bool closed() const { return m_closed; }
7324
7325 private:
7326 bool m_closed;
7327 };
7328
7329 TEST_F(WebFrameSwapTest, WindowOpenRemoteClose)
7330 {
7331 // Create a remote window that will be closed later in the test.
7332 RemoteWindowCloseClient viewClient;
7333 FrameTestHelpers::TestWebRemoteFrameClient frameClient;
7334 WebRemoteFrame* webRemoteFrame = frameClient.frame();
7335
7336 WebView* view = WebView::create(&viewClient);
7337 view->setMainFrame(webRemoteFrame);
7338 view->mainFrame()->setOpener(mainFrame());
7339 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt p://127.0.0.1"));
7340
7341 LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainFrame()));
7342 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame()));
7343
7344 // Attempt to close the window, which should fail as it isn't opened
7345 // by a script.
7346 remoteFrame->domWindow()->close(localFrame->document());
7347 EXPECT_FALSE(viewClient.closed());
7348
7349 // Marking it as opened by a script should now allow it to be closed.
7350 remoteFrame->page()->setOpenedByDOM();
7351 remoteFrame->domWindow()->close(localFrame->document());
7352 EXPECT_TRUE(viewClient.closed());
7353
7354 reset();
7355 }
7356
7316 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7357 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7317 public: 7358 public:
7318 explicit CommitTypeWebFrameClient() 7359 explicit CommitTypeWebFrameClient()
7319 : m_historyCommitType(WebHistoryInertCommit) 7360 : m_historyCommitType(WebHistoryInertCommit)
7320 { 7361 {
7321 } 7362 }
7322 7363
7323 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override 7364 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override
7324 { 7365 {
7325 m_historyCommitType = historyCommitType; 7366 m_historyCommitType = historyCommitType;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
7721 TEST_F(WebFrameTest, OrientationFrameDetach) 7762 TEST_F(WebFrameTest, OrientationFrameDetach)
7722 { 7763 {
7723 RuntimeEnabledFeatures::setOrientationEventEnabled(true); 7764 RuntimeEnabledFeatures::setOrientationEventEnabled(true);
7724 registerMockedHttpURLLoad("orientation-frame-detach.html"); 7765 registerMockedHttpURLLoad("orientation-frame-detach.html");
7725 FrameTestHelpers::WebViewHelper webViewHelper; 7766 FrameTestHelpers::WebViewHelper webViewHelper;
7726 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie ntation-frame-detach.html", true); 7767 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie ntation-frame-detach.html", true);
7727 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent(); 7768 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent();
7728 } 7769 }
7729 7770
7730 } // namespace blink 7771 } // namespace blink
OLDNEW
« Source/web/ChromeClientImpl.cpp ('K') | « Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698