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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1408073006: Gracefully handle a self-referential opener in frame swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/web/WebFrame.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7599 matching lines...) Expand 10 before | Expand all | Expand 10 after
7610 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7610 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None);
7611 popupRemoteFrame->swap(popupLocalFrame); 7611 popupRemoteFrame->swap(popupLocalFrame);
7612 7612
7613 // The initial document created during the remote-to-local swap should have 7613 // The initial document created during the remote-to-local swap should have
7614 // inherited its opener's SecurityOrigin. 7614 // inherited its opener's SecurityOrigin.
7615 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7615 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7616 7616
7617 popupView->close(); 7617 popupView->close();
7618 } 7618 }
7619 7619
7620 TEST_F(WebFrameTest, SwapWithOpenerCycle)
7621 {
7622 // First, create a remote main frame with itself as the opener.
7623 FrameTestHelpers::TestWebViewClient viewClient;
7624 WebView* view = WebView::create(&viewClient);
7625 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7626 WebRemoteFrame* remoteFrame = remoteClient.frame();
7627 view->setMainFrame(remoteFrame);
7628 remoteFrame->setOpener(remoteFrame);
7629
7630 // Now swap in a local frame. It shouldn't crash.
7631 FrameTestHelpers::TestWebFrameClient localClient;
7632 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &localClient);
7633 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None);
7634 remoteFrame->swap(localFrame);
7635
7636 // And the opener cycle should still be preserved.
7637 EXPECT_EQ(localFrame, localFrame->opener());
7638
7639 view->close();
7640 }
7641
7620 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7642 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7621 public: 7643 public:
7622 explicit CommitTypeWebFrameClient() 7644 explicit CommitTypeWebFrameClient()
7623 : m_historyCommitType(WebHistoryInertCommit) 7645 : m_historyCommitType(WebHistoryInertCommit)
7624 { 7646 {
7625 } 7647 }
7626 7648
7627 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override 7649 void didCommitProvisionalLoad(WebLocalFrame*, const WebHistoryItem&, WebHist oryCommitType historyCommitType) override
7628 { 7650 {
7629 m_historyCommitType = historyCommitType; 7651 m_historyCommitType = historyCommitType;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
8276 EXPECT_TRUE(resource); 8298 EXPECT_TRUE(resource);
8277 EXPECT_NE(0, resource->loadFinishTime()); 8299 EXPECT_NE(0, resource->loadFinishTime());
8278 8300
8279 DocumentLoader* loader = document->loader(); 8301 DocumentLoader* loader = document->loader();
8280 8302
8281 EXPECT_TRUE(loader); 8303 EXPECT_TRUE(loader);
8282 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); 8304 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime());
8283 } 8305 }
8284 8306
8285 } // namespace blink 8307 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebFrame.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698