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

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

Issue 1273023002: Fix WebLocalFrame leaks in unit tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('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 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 EXPECT_TRUE(webFrameClient.messages.empty()); 7641 EXPECT_TRUE(webFrameClient.messages.empty());
7642 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); 7642 ASSERT_EQ(2u, popupWebFrameClient.messages.size());
7643 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame")); 7643 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame"));
7644 7644
7645 // Manually reset to break WebViewHelpers' dependencies on the stack 7645 // Manually reset to break WebViewHelpers' dependencies on the stack
7646 // allocated WebFrameClients. 7646 // allocated WebFrameClients.
7647 webViewHelper.reset(); 7647 webViewHelper.reset();
7648 popupWebViewHelper.reset(); 7648 popupWebViewHelper.reset();
7649 } 7649 }
7650 7650
7651 class WebLocalFrameScope final {
7652 public:
7653 WebLocalFrameScope(WebLocalFrame* localFrame)
7654 : m_localFrame(localFrame)
7655 {
7656 }
7657
7658 operator WebLocalFrame*() const
7659 {
7660 return m_localFrame;
7661 }
7662
7663 WebLocalFrame* operator->() const
7664 {
7665 return m_localFrame;
7666 }
7667
7668 ~WebLocalFrameScope()
7669 {
7670 m_localFrame->close();
7671 }
7672 private:
7673 WebLocalFrame* m_localFrame;
7674 };
7675
7676
7651 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7677 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7652 { 7678 {
7653 FrameTestHelpers::TestWebViewClient viewClient; 7679 FrameTestHelpers::TestWebViewClient viewClient;
7654 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7680 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7655 WebView* view = WebView::create(&viewClient); 7681 WebView* view = WebView::create(&viewClient);
7656 view->setMainFrame(remoteClient.frame()); 7682 view->setMainFrame(remoteClient.frame());
7657 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7683 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7658 7684
7659 WebLocalFrame* secondFrame = parent->createLocalChild(WebTreeScopeType::Docu ment, "", WebSandboxFlags::None, nullptr, nullptr); 7685 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr);
7660 WebLocalFrame* fourthFrame = parent->createLocalChild(WebTreeScopeType::Docu ment, "", WebSandboxFlags::None, nullptr, secondFrame); 7686 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame);
7661 WebLocalFrame* thirdFrame = parent->createLocalChild(WebTreeScopeType::Docum ent, "", WebSandboxFlags::None, nullptr, secondFrame); 7687 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame);
7662 WebLocalFrame* firstFrame = parent->createLocalChild(WebTreeScopeType::Docum ent, "", WebSandboxFlags::None, nullptr, nullptr); 7688 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr);
7663 7689
7664 EXPECT_EQ(firstFrame, parent->firstChild()); 7690 EXPECT_EQ(firstFrame, parent->firstChild());
7665 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7691 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7666 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7692 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7667 7693
7668 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7694 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7669 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7695 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7670 7696
7671 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7697 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7672 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7698 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
7960 7986
7961 TEST_F(WebFrameTest, MaxFramesDetach) 7987 TEST_F(WebFrameTest, MaxFramesDetach)
7962 { 7988 {
7963 registerMockedHttpURLLoad("max-frames-detach.html"); 7989 registerMockedHttpURLLoad("max-frames-detach.html");
7964 FrameTestHelpers::WebViewHelper webViewHelper; 7990 FrameTestHelpers::WebViewHelper webViewHelper;
7965 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 7991 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
7966 webViewImpl->mainFrameImpl()->collectGarbage(); 7992 webViewImpl->mainFrameImpl()->collectGarbage();
7967 } 7993 }
7968 7994
7969 } // namespace blink 7995 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698