Changeset 181631 in webkit
- Timestamp:
- Mar 17, 2015 4:10:13 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181629 r181631 1 2015-03-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] WebKitDOM objects leaking 4 https://bugs.webkit.org/show_bug.cgi?id=118788 5 6 Reviewed by Darin Adler and Sergio Villar Senin. 7 8 Use a DOMwindowObserver class, derived from DOMWindowProperty to 9 be notified when the window object is detached from the frame to 10 clear the DOM objects associated to that frame in that case too. 11 12 * bindings/gobject/DOMObjectCache.cpp: 13 1 14 2015-03-17 Zan Dobersek <zdobersek@igalia.com> 2 15 -
trunk/Source/WebCore/bindings/gobject/DOMObjectCache.cpp
r180216 r181631 20 20 #include "DOMObjectCache.h" 21 21 22 #include "DOMWindowProperty.h" 22 23 #include "Document.h" 24 #include "Frame.h" 23 25 #include "FrameDestructionObserver.h" 24 26 #include "Node.h" … … 95 97 ASSERT(!m_objects.contains(&data)); 96 98 99 if (!m_domWindowObserver && m_frame->document()->domWindow()) 100 m_domWindowObserver = std::make_unique<DOMWindowObserver>(*m_frame, *this); 101 97 102 m_objects.append(&data); 98 103 g_object_weak_ref(data.object, DOMObjectCacheFrameObserver::objectFinalizedCallback, this); … … 100 105 101 106 private: 107 class DOMWindowObserver final: public WebCore::DOMWindowProperty { 108 WTF_MAKE_FAST_ALLOCATED; 109 public: 110 DOMWindowObserver(WebCore::Frame& frame, DOMObjectCacheFrameObserver& frameObserver) 111 : DOMWindowProperty(&frame) 112 , m_frameObserver(frameObserver) 113 { 114 } 115 116 virtual ~DOMWindowObserver() 117 { 118 } 119 120 private: 121 virtual void willDetachGlobalObjectFromFrame() override 122 { 123 // Clear the DOMWindowProperty first, and then notify the Frame observer. 124 DOMWindowProperty::willDetachGlobalObjectFromFrame(); 125 m_frameObserver.willDetachGlobalObjectFromFrame(); 126 } 127 128 DOMObjectCacheFrameObserver& m_frameObserver; 129 }; 130 102 131 static void objectFinalizedCallback(gpointer userData, GObject* finalizedObject) 103 132 { … … 133 162 } 134 163 164 void willDetachGlobalObjectFromFrame() 165 { 166 clear(); 167 m_domWindowObserver = nullptr; 168 } 169 135 170 Vector<DOMObjectCacheData*, 8> m_objects; 171 std::unique_ptr<DOMWindowObserver> m_domWindowObserver; 136 172 }; 137 173 -
trunk/Tools/ChangeLog
r181627 r181631 1 2015-03-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] WebKitDOM objects leaking 4 https://bugs.webkit.org/show_bug.cgi?id=118788 5 6 Reviewed by Darin Adler and Sergio Villar Senin. 7 8 Update DOMObjectCache unit test to check that DOM objects are also 9 released when new contents are loaded in the web view, and the old 10 document is detached from the frame. 11 12 * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp: 13 (testWebKitDOMObjectCache): 14 * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp: 15 (runTest): 16 1 17 2015-03-17 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp
r180214 r181631 63 63 { 64 64 static const char* testHTML = "<html><body><div id='container'><p>DOM Cache test</p><a id='link href='#'>link</a></div></body></html>"; 65 test->loadHtml(testHTML, nullptr);66 test->waitUntilLoadFinished();67 65 68 g_assert(test->runWebProcessTest("WebKitDOMNode", "dom-cache")); 66 // Run the test 3 times to make sure the DOM objects are correctly released when the 67 // document is detached from the frame for every new document created. 68 for (unsigned i = 0; i < 3; ++i) { 69 test->loadHtml(testHTML, nullptr); 70 test->waitUntilLoadFinished(); 71 72 g_assert(test->runWebProcessTest("WebKitDOMNode", "dom-cache")); 73 } 69 74 } 70 75 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp
r180211 r181631 65 65 WebKitWebPage* webPage = WEBKIT_WEB_PAGE(JSObjectGetPrivate(thisObject)); 66 66 g_assert(WEBKIT_IS_WEB_PAGE(webPage)); 67 WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage)); 67 // Test /WebKitDOMNode/dom-cache is an exception, because it's called 3 times, so 68 // the WebPage is destroyed after the third time. 69 if (g_str_equal(testPath.get(), "WebKitDOMNode/dom-cache")) { 70 static unsigned domCacheTestRunCount = 0; 71 if (++domCacheTestRunCount == 3) 72 WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage)); 73 } else 74 WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage)); 68 75 69 76 std::unique_ptr<WebProcessTest> test = WebProcessTest::create(String::fromUTF8(testPath.get()));
Note: See TracChangeset
for help on using the changeset viewer.