Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index 54ab2be7d7b9cd06c5957495d4213e434870a6bb..271bf7a3ca7623eb64fcc6bc1e76f59af02ad4a5 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -5656,6 +5656,12 @@ v8::Local<v8::Object> Document::wrap(v8::Isolate* isolate, v8::Local<v8::Object> |
} |
v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creationContext, wrapperType, this); |
+ // V8DOMWrapper::createWrapper may run an arbitrary script and it may result |
+ // in creating a new wrapper and associating it with |this|. If so, the |
+ // wrapper already created and associated must be used. |
+ v8::Local<v8::Object> associatedWrapper = DOMDataStore::getWrapper(this, isolate); |
+ if (UNLIKELY(!associatedWrapper.IsEmpty())) |
+ return associatedWrapper; |
if (UNLIKELY(wrapper.IsEmpty())) |
return wrapper; |