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

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

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix lifetime on frame detach Created 7 years, 2 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
« no previous file with comments | « Source/web/tests/LinkHighlightTest.cpp ('k') | Source/web/tests/PageSerializerTest.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 ++count; 81 ++count;
82 } 82 }
83 } 83 }
84 return count; 84 return count;
85 } 85 }
86 86
87 87
88 class ListenerLeakTest : public testing::Test { 88 class ListenerLeakTest : public testing::Test {
89 public: 89 public:
90 ListenerLeakTest() : m_webView(0) { }
91
92 void RunTest(const std::string& filename) 90 void RunTest(const std::string& filename)
93 { 91 {
94 std::string baseURL("http://www.example.com/"); 92 std::string baseURL("http://www.example.com/");
95 std::string fileName(filename); 93 std::string fileName(filename);
96 bool executeScript = true; 94 bool executeScript = true;
97 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL .c_str()), WebString::fromUTF8(fileName.c_str())); 95 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL .c_str()), WebString::fromUTF8(fileName.c_str()));
98 m_webView = FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, e xecuteScript); 96 webViewHelper.initializeAndLoad(baseURL + fileName, executeScript);
99 } 97 }
100 98
101 virtual void TearDown() OVERRIDE 99 virtual void TearDown() OVERRIDE
102 { 100 {
103 if (m_webView)
104 m_webView->close();
105 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 101 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
106 } 102 }
107 103
108 protected: 104 protected:
109 WebView* m_webView; 105 FrameTestHelpers::WebViewHelper webViewHelper;
110 }; 106 };
111 107
112 108
113 // This test tries to create a reference cycle between node and its listener. 109 // This test tries to create a reference cycle between node and its listener.
114 // See http://crbug/17400. 110 // See http://crbug/17400.
115 TEST_F(ListenerLeakTest, ReferenceCycle) 111 TEST_F(ListenerLeakTest, ReferenceCycle)
116 { 112 {
117 RunTest("listener/listener_leak1.html"); 113 RunTest("listener/listener_leak1.html");
118 ASSERT_EQ(0, GetNumObjects("EventListenerLeakTestObject1")); 114 ASSERT_EQ(0, GetNumObjects("EventListenerLeakTestObject1"));
119 } 115 }
120 116
121 // This test sets node onclick many times to expose a possible memory 117 // This test sets node onclick many times to expose a possible memory
122 // leak where all listeners get referenced by the node. 118 // leak where all listeners get referenced by the node.
123 TEST_F(ListenerLeakTest, HiddenReferences) 119 TEST_F(ListenerLeakTest, HiddenReferences)
124 { 120 {
125 RunTest("listener/listener_leak2.html"); 121 RunTest("listener/listener_leak2.html");
126 ASSERT_EQ(1, GetNumObjects("EventListenerLeakTestObject2")); 122 ASSERT_EQ(1, GetNumObjects("EventListenerLeakTestObject2"));
127 } 123 }
128 124
129 } // namespace 125 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/LinkHighlightTest.cpp ('k') | Source/web/tests/PageSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698