Changeset 144522 in webkit
- Timestamp:
- Mar 1, 2013 6:35:53 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r144222 r144522 1 2013-03-01 Elliott Sprehn <esprehn@gmail.com> 2 3 Don't leak Documents when using MutationObserver from extensions 4 https://bugs.webkit.org/show_bug.cgi?id=111234 5 6 Reviewed by Adam Barth. 7 8 * ManualTests/leak-observer-nonmain-world.html: Added. 9 1 10 2013-02-27 Zan Dobersek <zdobersek@igalia.com> 2 11 -
trunk/Source/WebCore/ChangeLog
r144520 r144522 1 2013-03-01 Elliott Sprehn <esprehn@gmail.com> 2 3 Don't leak Documents when using MutationObserver from extensions 4 https://bugs.webkit.org/show_bug.cgi?id=111234 5 6 Reviewed by Adam Barth. 7 8 MutationObserverCallback holds a WorldContextHandle which secretly isn't 9 a handle to anything when it's for the main world. When it's for a non-main 10 world though, like those used in extensions, it becomes a strong reference 11 to the v8::Context which results in leaks by creating cycles: 12 13 MutationObserver -> Callback -> World -> Document -> Node -> MutationObserver. 14 15 Instead we should keep a RefPtr to a DOMWrapperWorld in the callback and then 16 get the v8::Context from that inside handleEvent. 17 18 Tests: ManualTests/leak-observer-nonmain-world.html 19 20 * bindings/v8/V8Binding.cpp: 21 (WebCore::toV8Context): Added overload that takes a DOMWrapperWorld. 22 * bindings/v8/V8Binding.h: 23 * bindings/v8/V8MutationCallback.cpp: 24 (WebCore::V8MutationCallback::V8MutationCallback): 25 (WebCore::V8MutationCallback::handleEvent): 26 * bindings/v8/V8MutationCallback.h: 27 (V8MutationCallback): 28 1 29 2013-03-01 Bear Travis <betravis@adobe.com> 2 30 -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r142810 r144522 267 267 } 268 268 269 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWorld* world) 270 { 271 if (context->isDocument()) { 272 if (Frame* frame = static_cast<Document*>(context)->frame()) { 273 // FIXME: Store the DOMWrapperWorld for the main world in the v8::Context so callers 274 // that are looking up their world with DOMWrapperWorld::getWorld(v8::Context::GetCurrent()) 275 // won't end up passing null here when later trying to get their v8::Context back. 276 if (!world) 277 return frame->script()->mainWorldContext(); 278 return v8::Local<v8::Context>::New(frame->script()->windowShell(world)->context()); 279 } 280 #if ENABLE(WORKERS) 281 } else if (context->isWorkerContext()) { 282 if (WorkerScriptController* script = static_cast<WorkerContext*>(context)->script()) 283 return script->context(); 284 #endif 285 } 286 return v8::Local<v8::Context>(); 287 } 288 269 289 bool handleOutOfMemory() 270 290 { -
trunk/Source/WebCore/bindings/v8/V8Binding.h
r144381 r144522 446 446 // Returns the context associated with a ScriptExecutionContext. 447 447 v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, const WorldContextHandle&); 448 v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, DOMWrapperWorld*); 448 449 449 450 // Returns the frame object of the window object associated with -
trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp
r141771 r144522 39 39 : ActiveDOMCallback(context) 40 40 , m_callback(callback) 41 , m_world Context(UseCurrentWorld)41 , m_world(DOMWrapperWorld::getWorld(v8::Context::GetCurrent())) 42 42 { 43 43 owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback); … … 56 56 v8::HandleScope handleScope; 57 57 58 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world Context);58 v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); 59 59 if (v8Context.IsEmpty()) 60 60 return true; -
trunk/Source/WebCore/bindings/v8/V8MutationCallback.h
r141771 r144522 28 28 29 29 #include "ActiveDOMCallback.h" 30 #include "DOMWrapperWorld.h" 30 31 #include "MutationCallback.h" 31 32 #include "ScopedPersistent.h" 32 #include "WorldContextHandle.h"33 33 #include <v8.h> 34 #include <wtf/RefPtr.h> 34 35 35 36 namespace WebCore { … … 59 60 60 61 ScopedPersistent<v8::Object> m_callback; 61 WorldContextHandle m_worldContext;62 RefPtr<DOMWrapperWorld> m_world; 62 63 }; 63 64
Note: See TracChangeset
for help on using the changeset viewer.