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

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. 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::TestWebRemoteFrameClien t {
7317 public:
7318 void close() 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 another window that will be closed later in the test.
7332 FrameTestHelpers::WebViewHelper newWebViewHelper;
7333 WebView* newView = newWebViewHelper.initialize(true);
7334 newView->mainFrame()->setOpener(mainFrame());
7335 newView->mainFrame()->setName("foo");
7336 runPendingTasks();
dcheng 2015/06/11 02:00:06 Is this necessary? If so, it'd be nice to document
7337
7338 // Swap the new window to be remote.
7339 RemoteWindowCloseClient remoteClient;
7340 WebRemoteFrame* webRemoteFrame = remoteClient.frame();
7341 newView->mainFrame()->swap(webRemoteFrame);
7342 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt p://127.0.0.1"));
7343
7344 LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainFrame()));
7345 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(webRemoteFrame));
7346
7347 // Attempt to close the window, which should fail as it isn't opened
7348 // by a script.
7349 remoteFrame->domWindow()->close(localFrame->document());
7350 EXPECT_FALSE(remoteClient.closed());
7351
7352 // Marking it as opened by a script should now allow it to be closed.
7353 remoteFrame->page()->setOpenedByDOM();
7354 remoteFrame->domWindow()->close(localFrame->document());
7355 EXPECT_TRUE(remoteClient.closed());
7356
7357 reset();
7358 }
7359
7360
7316 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7361 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7317 public: 7362 public:
7318 explicit CommitTypeWebFrameClient() 7363 explicit CommitTypeWebFrameClient()
7319 : m_historyCommitType(WebHistoryInertCommit) 7364 : m_historyCommitType(WebHistoryInertCommit)
7320 { 7365 {
7321 } 7366 }
7322 7367
7323 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override 7368 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override
7324 { 7369 {
7325 m_historyCommitType = historyCommitType; 7370 m_historyCommitType = historyCommitType;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
7721 TEST_F(WebFrameTest, OrientationFrameDetach) 7766 TEST_F(WebFrameTest, OrientationFrameDetach)
7722 { 7767 {
7723 RuntimeEnabledFeatures::setOrientationEventEnabled(true); 7768 RuntimeEnabledFeatures::setOrientationEventEnabled(true);
7724 registerMockedHttpURLLoad("orientation-frame-detach.html"); 7769 registerMockedHttpURLLoad("orientation-frame-detach.html");
7725 FrameTestHelpers::WebViewHelper webViewHelper; 7770 FrameTestHelpers::WebViewHelper webViewHelper;
7726 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie ntation-frame-detach.html", true); 7771 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie ntation-frame-detach.html", true);
7727 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent(); 7772 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent();
7728 } 7773 }
7729 7774
7730 } // namespace blink 7775 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698