[V8] Add a "context type" parameter to GetTemplate and ConfigureV8SomethingTemplate...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 12:26:53 +0000 (12:26 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 12:26:53 +0000 (12:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110875

The parameter will later be used for generating specialized V8
bindings for the 3 different world types (main world, isolated
work, worker).

Patch by Marja Hölttä <marja@chromium.org> on 2013-03-04
Reviewed by Kentaro Hara.

No new tests (no changes in behavior yet).

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
(GenerateDomainSafeFunctionGetter):
(GenerateDomainSafeFunctionSetter):
(GenerateNormalAttrGetter):
(GenerateNamedConstructor):
(GenerateImplementation):
* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::DOMDataStore):
* bindings/v8/DOMDataStore.h:
(DOMDataStore):
* bindings/v8/DOMWrapperWorld.cpp:
(WebCore):
(WebCore::DOMWrapperWorld::setInitializingWindow):
(WebCore::DOMWrapperWorld::DOMWrapperWorld):
(WebCore::DOMWrapperWorld::contextHasCorrectPrototype):
* bindings/v8/DOMWrapperWorld.h:
(DOMWrapperWorld):
(WebCore::DOMWrapperWorld::getWorld):
* bindings/v8/Dictionary.cpp:
(WebCore::Dictionary::get):
* bindings/v8/PageScriptDebugServer.cpp:
(WebCore::retrieveFrameWithGlobalObjectCheck):
* bindings/v8/V8AdaptorFunction.cpp:
(WebCore::V8AdaptorFunction::getTemplate):
(WebCore::V8AdaptorFunction::wrap):
* bindings/v8/V8AdaptorFunction.h:
(V8AdaptorFunction):
* bindings/v8/V8Binding.cpp:
(WebCore::toDOMWindow):
(WebCore::toScriptExecutionContext):
(WebCore::worldType):
(WebCore):
(WebCore::worldTypeInMainThread):
* bindings/v8/V8Binding.h:
(WebCore):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::clearForNavigation):
(WebCore::V8DOMWindowShell::installDOMWindow):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::createWrapper):
* bindings/v8/V8Initializer.cpp:
(WebCore::findFrame):
* bindings/v8/V8PerContextData.cpp:
(WebCore::V8PerContextData::constructorForTypeSlowCase):
* bindings/v8/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::WorkerScriptController):
(WebCore::WorkerScriptController::controllerForContext):
* bindings/v8/WrapperTypeInfo.h:
(WebCore::WrapperTypeInfo::getTemplate):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::eventAttrGetterCustom):
(WebCore::V8DOMWindow::eventAttrSetterCustom):
(WebCore::V8DOMWindow::toStringMethodCustom):
(WebCore::V8DOMWindow::namedSecurityCheck):
(WebCore::V8DOMWindow::indexedSecurityCheck):
(WebCore::toV8):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::wrapInShadowObject):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore::V8HTMLImageElementConstructor::GetTemplate):
* bindings/v8/custom/V8HTMLImageElementConstructor.h:
(V8HTMLImageElementConstructor):
* bindings/v8/custom/V8InjectedScriptManager.cpp:
(WebCore::createInjectedScriptHostV8Wrapper):
(WebCore::InjectedScriptManager::canAccessInspectedWindow):
* bindings/v8/custom/V8LocationCustom.cpp:
(WebCore::V8Location::reloadAttrGetterCustom):
(WebCore::V8Location::replaceAttrGetterCustom):
(WebCore::V8Location::assignAttrGetterCustom):
* bindings/v8/custom/V8MessageEventCustom.cpp:
(WebCore::V8MessageEvent::initMessageEventMethodCustom):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144617 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/v8/DOMDataStore.cpp
Source/WebCore/bindings/v8/DOMDataStore.h
Source/WebCore/bindings/v8/DOMWrapperWorld.cpp
Source/WebCore/bindings/v8/DOMWrapperWorld.h
Source/WebCore/bindings/v8/Dictionary.cpp
Source/WebCore/bindings/v8/PageScriptDebugServer.cpp
Source/WebCore/bindings/v8/V8AdaptorFunction.cpp
Source/WebCore/bindings/v8/V8AdaptorFunction.h
Source/WebCore/bindings/v8/V8Binding.cpp
Source/WebCore/bindings/v8/V8Binding.h
Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/bindings/v8/V8Initializer.cpp
Source/WebCore/bindings/v8/V8PerContextData.cpp
Source/WebCore/bindings/v8/WorkerScriptController.cpp
Source/WebCore/bindings/v8/WrapperTypeInfo.h
Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.h
Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp
Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp
Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp

index 5bf95db..a6c6edb 100644 (file)
@@ -1,3 +1,89 @@
+2013-03-04  Marja Hölttä  <marja@chromium.org>
+
+        [V8] Add a "context type" parameter to GetTemplate and ConfigureV8SomethingTemplate functions
+        https://bugs.webkit.org/show_bug.cgi?id=110875
+
+        The parameter will later be used for generating specialized V8
+        bindings for the 3 different world types (main world, isolated
+        work, worker).
+
+        Reviewed by Kentaro Hara.
+
+        No new tests (no changes in behavior yet).
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (GenerateDomainSafeFunctionGetter):
+        (GenerateDomainSafeFunctionSetter):
+        (GenerateNormalAttrGetter):
+        (GenerateNamedConstructor):
+        (GenerateImplementation):
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::DOMDataStore):
+        * bindings/v8/DOMDataStore.h:
+        (DOMDataStore):
+        * bindings/v8/DOMWrapperWorld.cpp:
+        (WebCore):
+        (WebCore::DOMWrapperWorld::setInitializingWindow):
+        (WebCore::DOMWrapperWorld::DOMWrapperWorld):
+        (WebCore::DOMWrapperWorld::contextHasCorrectPrototype):
+        * bindings/v8/DOMWrapperWorld.h:
+        (DOMWrapperWorld):
+        (WebCore::DOMWrapperWorld::getWorld):
+        * bindings/v8/Dictionary.cpp:
+        (WebCore::Dictionary::get):
+        * bindings/v8/PageScriptDebugServer.cpp:
+        (WebCore::retrieveFrameWithGlobalObjectCheck):
+        * bindings/v8/V8AdaptorFunction.cpp:
+        (WebCore::V8AdaptorFunction::getTemplate):
+        (WebCore::V8AdaptorFunction::wrap):
+        * bindings/v8/V8AdaptorFunction.h:
+        (V8AdaptorFunction):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::toDOMWindow):
+        (WebCore::toScriptExecutionContext):
+        (WebCore::worldType):
+        (WebCore):
+        (WebCore::worldTypeInMainThread):
+        * bindings/v8/V8Binding.h:
+        (WebCore):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::V8DOMWindowShell::clearForNavigation):
+        (WebCore::V8DOMWindowShell::installDOMWindow):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::createWrapper):
+        * bindings/v8/V8Initializer.cpp:
+        (WebCore::findFrame):
+        * bindings/v8/V8PerContextData.cpp:
+        (WebCore::V8PerContextData::constructorForTypeSlowCase):
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::WorkerScriptController):
+        (WebCore::WorkerScriptController::controllerForContext):
+        * bindings/v8/WrapperTypeInfo.h:
+        (WebCore::WrapperTypeInfo::getTemplate):
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::V8DOMWindow::eventAttrGetterCustom):
+        (WebCore::V8DOMWindow::eventAttrSetterCustom):
+        (WebCore::V8DOMWindow::toStringMethodCustom):
+        (WebCore::V8DOMWindow::namedSecurityCheck):
+        (WebCore::V8DOMWindow::indexedSecurityCheck):
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::wrapInShadowObject):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+        (WebCore::V8HTMLImageElementConstructor::GetTemplate):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.h:
+        (V8HTMLImageElementConstructor):
+        * bindings/v8/custom/V8InjectedScriptManager.cpp:
+        (WebCore::createInjectedScriptHostV8Wrapper):
+        (WebCore::InjectedScriptManager::canAccessInspectedWindow):
+        * bindings/v8/custom/V8LocationCustom.cpp:
+        (WebCore::V8Location::reloadAttrGetterCustom):
+        (WebCore::V8Location::replaceAttrGetterCustom):
+        (WebCore::V8Location::assignAttrGetterCustom):
+        * bindings/v8/custom/V8MessageEventCustom.cpp:
+        (WebCore::V8MessageEvent::initMessageEventMethodCustom):
+
 2013-03-04  Andrey Lushnikov  <lushnikov@chromium.org>
 
         Web Inspector: add Ace editor experiment
index 9932a0a..19fb966 100644 (file)
@@ -324,7 +324,7 @@ sub GenerateHeader
         push(@headerContent, <<END);
 class V8${nativeType}Constructor {
 public:
-    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*);
+    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWorldType);
     static WrapperTypeInfo info;
 };
 
@@ -362,7 +362,7 @@ END
     push(@headerContent, <<END);
     static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(v8::Isolate*);
-    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*);
+    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWorldType);
     static ${nativeType}* toNative(v8::Handle<v8::Object> object)
     {
         return reinterpret_cast<${nativeType}*>(${fromFunctionOpening}object${fromFunctionClosing}->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
@@ -793,7 +793,7 @@ sub GenerateDomainSafeFunctionGetter
 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(info.GetIsolate(), $newTemplateString);
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate()));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
     if (holder.IsEmpty()) {
         // can only reach here by 'object.__proto__.func', and it should passed
         // domain security check already
@@ -828,7 +828,7 @@ sub GenerateDomainSafeFunctionSetter
     push(@implContentInternals, <<END);
 static void ${interfaceName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate()));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
     if (holder.IsEmpty())
         return;
     ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder);
@@ -947,7 +947,7 @@ END
         } else {
             # perform lookup first
             push(@implContentInternals, <<END);
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate()));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
     if (holder.IsEmpty())
         return v8Undefined();
 END
@@ -2242,7 +2242,7 @@ END
 
     push(@implContent, <<END);
 
-v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate(v8::Isolate* isolate)
+v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate(v8::Isolate* isolate, WrapperWorldType worldType)
 {
     static v8::Persistent<v8::FunctionTemplate> cachedTemplate;
     if (!cachedTemplate.IsEmpty())
@@ -2254,7 +2254,7 @@ v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}Constructor::GetTemplate(
     v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate();
     instance->SetInternalFieldCount(${v8InterfaceName}::internalFieldCount);
     result->SetClassName(v8::String::NewSymbol("${interfaceName}"));
-    result->Inherit(${v8InterfaceName}::GetTemplate(isolate));
+    result->Inherit(${v8InterfaceName}::GetTemplate(isolate, worldType));
 
     cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result);
     return cachedTemplate;
@@ -2678,7 +2678,7 @@ sub GenerateImplementation
         my $parent = $_;
         AddToImplIncludes("V8${parent}.h");
         $parentClass = "V8" . $parent;
-        $parentClassTemplate = $parentClass . "::GetTemplate(isolate)";
+        $parentClassTemplate = $parentClass . "::GetTemplate(isolate, worldType)";
         last;
     }
 
@@ -2991,7 +2991,7 @@ END
 
     # Generate the template configuration method
     push(@implContent,  <<END);
-static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate)
+static v8::Persistent<v8::FunctionTemplate> Configure${v8InterfaceName}Template(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType worldType)
 {
     desc->ReadOnlyPrototype();
 
@@ -3157,7 +3157,7 @@ v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetRawTemplate(v8::Isol
     return templ;
 }
 
-v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate* isolate)
+v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate* isolate, WrapperWorldType worldType)
 {
     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
     V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info);
@@ -3166,7 +3166,7 @@ v8::Persistent<v8::FunctionTemplate> ${v8InterfaceName}::GetTemplate(v8::Isolate
 
     v8::HandleScope handleScope;
     v8::Persistent<v8::FunctionTemplate> templ =
-        Configure${v8InterfaceName}Template(GetRawTemplate(isolate), isolate);
+        Configure${v8InterfaceName}Template(GetRawTemplate(isolate), isolate, worldType);
     data->templateMap().add(&info, templ);
     return templ;
 }
@@ -3215,7 +3215,7 @@ void ${v8InterfaceName}::installPerContextPrototypeProperties(v8::Handle<v8::Obj
 END
         # Setup the enable-by-settings functions if we have them
         push(@implContent,  <<END);
-    v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(isolate));
+    v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(isolate, worldType(isolate)));
     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
 
     ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationContext());
index 60aaf7b..fde384a 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace WebCore {
 
-DOMDataStore::DOMDataStore(Type type)
+DOMDataStore::DOMDataStore(WrapperWorldType type)
     : m_type(type)
     , m_wrapperMap(v8::Isolate::GetCurrent()) // FIXME Don't call GetCurrent twice.
 {
index 0266ed9..c05033f 100644 (file)
@@ -35,6 +35,7 @@
 #include "DOMWrapperWorld.h"
 #include "Node.h"
 #include "V8GCController.h"
+#include "WrapperTypeInfo.h"
 #include <v8.h>
 #include <wtf/HashMap.h>
 #include <wtf/MainThread.h>
@@ -50,13 +51,7 @@ namespace WebCore {
 class DOMDataStore {
     WTF_MAKE_NONCOPYABLE(DOMDataStore);
 public:
-    enum Type {
-        MainWorld,
-        IsolatedWorld,
-        Worker,
-    };
-
-    explicit DOMDataStore(Type);
+    explicit DOMDataStore(WrapperWorldType);
     ~DOMDataStore();
 
     static DOMDataStore* current(v8::Isolate*);
@@ -163,7 +158,7 @@ private:
         object->setWrapper(wrapper, isolate, configuration);
     }
 
-    Type m_type;
+    WrapperWorldType m_type;
     DOMWrapperMap<void> m_wrapperMap;
 };
 
index 975bb49..5b5e3a0 100644 (file)
@@ -36,6 +36,7 @@
 #include "V8DOMActivityLogger.h"
 #include "V8DOMWindow.h"
 #include "V8DOMWrapper.h"
+#include "WrapperTypeInfo.h"
 #include <wtf/HashTraits.h>
 #include <wtf/MainThread.h>
 #include <wtf/StdLibExtras.h>
 namespace WebCore {
 
 int DOMWrapperWorld::isolatedWorldCount = 0;
+static bool initializingWindow = false;
 
 PassRefPtr<DOMWrapperWorld>  DOMWrapperWorld::createUninitializedWorld()
 {
     return adoptRef(new DOMWrapperWorld(uninitializedWorldId, uninitializedExtensionGroup));
 }
 
+void DOMWrapperWorld::setInitializingWindow(bool initializing)
+{
+    initializingWindow = initializing;
+}
+
 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::createMainWorld()
 {
     return adoptRef(new DOMWrapperWorld(mainWorldId, mainWorldExtensionGroup));
@@ -59,7 +66,7 @@ DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup)
     , m_extensionGroup(extensionGroup)
 {
     if (isIsolatedWorld())
-        m_domDataStore = adoptPtr(new DOMDataStore(DOMDataStore::IsolatedWorld));
+        m_domDataStore = adoptPtr(new DOMDataStore(IsolatedWorld));
 }
 
 DOMWrapperWorld* mainThreadNormalWorld()
@@ -69,10 +76,12 @@ DOMWrapperWorld* mainThreadNormalWorld()
     return cachedNormalWorld.get();
 }
 
-void DOMWrapperWorld::assertContextHasCorrectPrototype(v8::Handle<v8::Context> context)
+bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context)
 {
     ASSERT(isMainThread());
-    ASSERT(V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info));
+    if (initializingWindow)
+        return true;
+    return V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info);
 }
 
 static void isolatedWorldWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* parameter)
index 95ccf8e..d7d3add 100644 (file)
@@ -62,10 +62,9 @@ public:
     void makeContextWeak(v8::Handle<v8::Context>);
     void setIsolatedWorldField(v8::Handle<v8::Context>);
 
-    static void assertContextHasCorrectPrototype(v8::Handle<v8::Context>);
     static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context)
     {
-        assertContextHasCorrectPrototype(context);
+        ASSERT(contextHasCorrectPrototype(context));
         return static_cast<DOMWrapperWorld*>(context->GetAlignedPointerFromEmbedderData(v8ContextIsolatedWorld));
     }
 
@@ -109,9 +108,12 @@ public:
         return m_domDataStore.get();
     }
 
+    static void setInitializingWindow(bool);
+
 private:
     static int isolatedWorldCount;
     static PassRefPtr<DOMWrapperWorld> createMainWorld();
+    static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
 
     DOMWrapperWorld(int worldId, int extensionGroup);
 
index 8a9cf1d..b1862fb 100644 (file)
@@ -259,7 +259,7 @@ bool Dictionary::get(const String& key, RefPtr<DOMWindow>& value) const
     value = 0;
     if (v8Value->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
         if (!window.IsEmpty())
             value = V8DOMWindow::toNative(window);
     }
@@ -363,7 +363,7 @@ bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const
 
         // FIXME: this will need to be changed so it can also return an AudioTrack or a VideoTrack once
         // we add them.
-        v8::Handle<v8::Object> track = wrapper->FindInstanceInPrototypeChain(V8TextTrack::GetTemplate(m_isolate));
+        v8::Handle<v8::Object> track = wrapper->FindInstanceInPrototypeChain(V8TextTrack::GetTemplate(m_isolate, worldType(m_isolate)));
         if (!track.IsEmpty())
             source = V8TextTrack::toNative(track);
     }
@@ -436,7 +436,7 @@ bool Dictionary::get(const String& key, RefPtr<EventTarget>& value) const
     // exists on a prototype chain of v8Value.
     if (v8Value->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
         if (!window.IsEmpty()) {
             value = toWrapperTypeInfo(window)->toEventTarget(window);
             return true;
index ba6e5f8..f95e2aa 100644 (file)
@@ -56,7 +56,7 @@ static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context
     if (global.IsEmpty())
         return 0;
 
-    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate()));
+    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
     if (global.IsEmpty())
         return 0;
 
index bbc1d32..c72c713 100644 (file)
@@ -40,7 +40,7 @@ namespace WebCore {
 
 WrapperTypeInfo V8AdaptorFunction::info = { V8AdaptorFunction::getTemplate, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype };
 
-v8::Persistent<v8::FunctionTemplate> V8AdaptorFunction::getTemplate(v8::Isolate* isolate)
+v8::Persistent<v8::FunctionTemplate> V8AdaptorFunction::getTemplate(v8::Isolate* isolate, WrapperWorldType worldType)
 {
     ASSERT(isolate);
     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
@@ -76,7 +76,7 @@ v8::Handle<v8::Function> V8AdaptorFunction::wrap(v8::Handle<v8::Object> object,
 {
     if (object.IsEmpty() || !object->IsObject())
         return v8::Handle<v8::Function>();
-    v8::Handle<v8::Function> adaptor = v8::Handle<v8::Function>::Cast(getTemplate(isolate)->GetFunction());
+    v8::Handle<v8::Function> adaptor = v8::Handle<v8::Function>::Cast(getTemplate(isolate, worldType(isolate))->GetFunction());
     if (adaptor.IsEmpty())
         return v8::Handle<v8::Function>();
     adaptor->SetName(v8String(name.string(), isolate));
index e3d6bb5..7836eb4 100644 (file)
@@ -55,7 +55,7 @@ public:
     static v8::Handle<v8::Function> wrap(v8::Handle<v8::Object>, const AtomicString& name, v8::Isolate*);
     static v8::Handle<v8::Function> get(v8::Handle<v8::Object>);
 
-    static v8::Persistent<v8::FunctionTemplate> getTemplate(v8::Isolate* = 0);
+    static v8::Persistent<v8::FunctionTemplate> getTemplate(v8::Isolate*, WrapperWorldType);
     static v8::Persistent<v8::FunctionTemplate> configureTemplate(v8::Persistent<v8::FunctionTemplate>);
     static v8::Handle<v8::Value> invocationCallback(const v8::Arguments&);
 };
index 3d4f635..924c780 100644 (file)
@@ -221,7 +221,10 @@ DOMWindow* toDOMWindow(v8::Handle<v8::Context> context)
 {
     v8::Handle<v8::Object> global = context->Global();
     ASSERT(!global.IsEmpty());
-    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate()));
+    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
+    if (!global.IsEmpty())
+        return V8DOMWindow::toNative(global);
+    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), IsolatedWorld));
     ASSERT(!global.IsEmpty());
     return V8DOMWindow::toNative(global);
 }
@@ -229,11 +232,14 @@ DOMWindow* toDOMWindow(v8::Handle<v8::Context> context)
 ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context> context)
 {
     v8::Handle<v8::Object> global = context->Global();
-    v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate()));
+    v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
+    if (!windowWrapper.IsEmpty())
+        return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext();
+    windowWrapper = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), IsolatedWorld));
     if (!windowWrapper.IsEmpty())
         return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext();
 #if ENABLE(WORKERS)
-    v8::Handle<v8::Object> workerWrapper = global->FindInstanceInPrototypeChain(V8WorkerContext::GetTemplate(context->GetIsolate()));
+    v8::Handle<v8::Object> workerWrapper = global->FindInstanceInPrototypeChain(V8WorkerContext::GetTemplate(context->GetIsolate(), WorkerWorld));
     if (!workerWrapper.IsEmpty())
         return V8WorkerContext::toNative(workerWrapper)->scriptExecutionContext();
 #endif
@@ -325,4 +331,24 @@ void crashIfV8IsDead()
     }
 }
 
+WrapperWorldType worldType(v8::Isolate* isolate)
+{
+    V8PerIsolateData* data = V8PerIsolateData::from(isolate);
+    // FIXME: Rename domDataStore() to workerDataStore().
+    if (!data->domDataStore())
+        return worldTypeInMainThread(isolate);
+    return WorkerWorld;
+}
+
+WrapperWorldType worldTypeInMainThread(v8::Isolate* isolate)
+{
+    if (!DOMWrapperWorld::isolatedWorldsExist())
+        return MainWorld;
+    ASSERT(!v8::Context::GetEntered().IsEmpty());
+    DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context::GetEntered());
+    if (isolatedWorld)
+        return IsolatedWorld;
+    return MainWorld;
+}
+
 } // namespace WebCore
index b75c400..bc1125e 100644 (file)
@@ -467,6 +467,9 @@ namespace WebCore {
 
     void crashIfV8IsDead();
 
+    WrapperWorldType worldType(v8::Isolate*);
+    WrapperWorldType worldTypeInMainThread(v8::Isolate*);
+
 } // namespace WebCore
 
 #endif // V8Binding_h
index 7ea46ee..34481ae 100644 (file)
@@ -32,6 +32,7 @@
 #include "V8DOMWindowShell.h"
 
 #include "ContentSecurityPolicy.h"
+#include "DOMWrapperWorld.h"
 #include "DateExtension.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
@@ -157,7 +158,7 @@ void V8DOMWindowShell::clearForNavigation()
     // will be protected by the security checks on the DOMWindow wrapper.
     clearDocumentProperty();
 
-    v8::Handle<v8::Object> windowWrapper = m_global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate));
+    v8::Handle<v8::Object> windowWrapper = m_global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
     ASSERT(!windowWrapper.IsEmpty());
     windowWrapper->TurnOnAccessCheck();
     m_context->DetachGlobal();
@@ -314,6 +315,7 @@ void V8DOMWindowShell::createContext()
 
 bool V8DOMWindowShell::installDOMWindow()
 {
+    DOMWrapperWorld::setInitializingWindow(true);
     DOMWindow* window = m_frame->document()->domWindow();
     v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.get())->constructorForType(&V8DOMWindow::info));
     if (windowWrapper.IsEmpty())
@@ -340,6 +342,7 @@ bool V8DOMWindowShell::installDOMWindow()
     V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8DOMWindow::info, window);
     innerGlobalObject->SetPrototype(windowWrapper);
     V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
+    DOMWrapperWorld::setInitializingWindow(false);
     return true;
 }
 
index 4d8c226..c585aa1 100644 (file)
@@ -79,7 +79,7 @@ v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Handle<v8::Object> creatio
     V8WrapperInstantiationScope scope(creationContext);
 
     V8PerContextData* perContextData = V8PerContextData::from(scope.context());
-    v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate(isolate)->GetFunction());
+    v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate(isolate, worldTypeInMainThread(isolate))->GetFunction());
 
     if (type == &V8HTMLDocument::info && !wrapper.IsEmpty())
         wrapper = V8HTMLDocument::wrapInShadowObject(wrapper, static_cast<Node*>(impl), isolate);
index cb3bc6d..e21c0d5 100644 (file)
@@ -51,7 +51,7 @@ static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v
     WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
 
     if (V8DOMWindow::info.equals(type)) {
-        v8::Handle<v8::Object> windowWrapper = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
+        v8::Handle<v8::Object> windowWrapper = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
         if (windowWrapper.IsEmpty())
             return 0;
         return V8DOMWindow::toNative(windowWrapper)->frame();
index b392323..86eeb12 100644 (file)
@@ -115,7 +115,7 @@ v8::Local<v8::Function> V8PerContextData::constructorForTypeSlowCase(WrapperType
     ASSERT(!m_objectPrototype.isEmpty());
 
     v8::Context::Scope scope(m_context);
-    v8::Handle<v8::FunctionTemplate> functionTemplate = type->getTemplate(m_context->GetIsolate());
+    v8::Handle<v8::FunctionTemplate> functionTemplate = type->getTemplate(m_context->GetIsolate(), worldType(m_context->GetIsolate()));
     // Getting the function might fail if we're running out of stack or memory.
     v8::TryCatch tryCatch;
     v8::Local<v8::Function> function = functionTemplate->GetFunction();
index bc46093..b438353 100644 (file)
@@ -46,6 +46,7 @@
 #include "WorkerContext.h"
 #include "WorkerObjectProxy.h"
 #include "WorkerThread.h"
+#include "WrapperTypeInfo.h"
 #include <v8.h>
 
 #if PLATFORM(CHROMIUM)
@@ -63,7 +64,7 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
 {
     m_isolate->Enter();
     V8PerIsolateData* data = V8PerIsolateData::create(m_isolate);
-    m_domDataStore = adoptPtr(new DOMDataStore(DOMDataStore::Worker));
+    m_domDataStore = adoptPtr(new DOMDataStore(WorkerWorld));
     data->setDOMDataStore(m_domDataStore.get());
 
     V8Initializer::initializeWorker(m_isolate);
@@ -249,7 +250,7 @@ WorkerScriptController* WorkerScriptController::controllerForContext()
         return 0;
     v8::Handle<v8::Context> context = v8::Context::GetCurrent();
     v8::Handle<v8::Object> global = context->Global();
-    global = global->FindInstanceInPrototypeChain(V8WorkerContext::GetTemplate(context->GetIsolate()));
+    global = global->FindInstanceInPrototypeChain(V8WorkerContext::GetTemplate(context->GetIsolate(), WorkerWorld));
     // Return 0 if the current executing context is not the worker context.
     if (global.IsEmpty())
         return 0;
index b310af9..dc2a5ee 100644 (file)
@@ -47,7 +47,13 @@ namespace WebCore {
     static const uint16_t v8DOMNodeClassId = 1;
     static const uint16_t v8DOMObjectClassId = 2;
 
-    typedef v8::Persistent<v8::FunctionTemplate> (*GetTemplateFunction)(v8::Isolate*);
+    enum WrapperWorldType {
+        MainWorld,
+        IsolatedWorld,
+        WorkerWorld
+    };
+
+    typedef v8::Persistent<v8::FunctionTemplate> (*GetTemplateFunction)(v8::Isolate*, WrapperWorldType);
     typedef void (*DerefObjectFunction)(void*);
     typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
     typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>);
@@ -85,7 +91,7 @@ namespace WebCore {
             return false;
         }
         
-        v8::Persistent<v8::FunctionTemplate> getTemplate(v8::Isolate* isolate) { return getTemplateFunction(isolate); }
+        v8::Persistent<v8::FunctionTemplate> getTemplate(v8::Isolate* isolate, WrapperWorldType worldType) { return getTemplateFunction(isolate, worldType); }
         
         void derefObject(void* object)
         {
index b1312be..6cef2e5 100644 (file)
@@ -147,7 +147,7 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl
 
 v8::Handle<v8::Value> V8DOMWindow::eventAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate()));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
     if (holder.IsEmpty())
         return v8::Undefined();
 
@@ -169,7 +169,7 @@ v8::Handle<v8::Value> V8DOMWindow::eventAttrGetterCustom(v8::Local<v8::String> n
 
 void V8DOMWindow::eventAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate()));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
     if (holder.IsEmpty())
         return;
 
@@ -345,7 +345,7 @@ v8::Handle<v8::Value> V8DOMWindow::postMessageMethodCustom(const v8::Arguments&
 // switching context of receiver. I consider it is dangerous.
 v8::Handle<v8::Value> V8DOMWindow::toStringMethodCustom(const v8::Arguments& args)
 {
-    v8::Handle<v8::Object> domWrapper = args.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate()));
+    v8::Handle<v8::Object> domWrapper = args.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
     if (domWrapper.IsEmpty())
         return args.This()->ObjectProtoToString();
     return domWrapper->ObjectProtoToString();
@@ -511,7 +511,7 @@ v8::Handle<v8::Value> V8DOMWindow::setIntervalMethodCustom(const v8::Arguments&
 bool V8DOMWindow::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
 {
     v8::Isolate* isolate = v8::Isolate::GetCurrent();
-    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
+    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (window.IsEmpty())
         return false;  // the frame is gone.
 
@@ -545,7 +545,7 @@ bool V8DOMWindow::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local
 bool V8DOMWindow::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
 {
     v8::Isolate* isolate = v8::Isolate::GetCurrent();
-    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
+    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (window.IsEmpty())
         return false;
 
@@ -587,7 +587,7 @@ v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationCon
     // necessarily the first global object associated with that DOMWindow.
     v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
     v8::Handle<v8::Object> currentGlobal = currentContext->Global();
-    v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
+    v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (!windowWrapper.IsEmpty()) {
         if (V8DOMWindow::toNative(windowWrapper) == window)
             return currentGlobal;
index 1b58f4a..68b0bab 100644 (file)
@@ -60,7 +60,7 @@ v8::Local<v8::Object> V8HTMLDocument::wrapInShadowObject(v8::Local<v8::Object> w
         if (shadowTemplate.IsEmpty())
             return v8::Local<v8::Object>();
         shadowTemplate->SetClassName(v8::String::NewSymbol("HTMLDocument"));
-        shadowTemplate->Inherit(V8HTMLDocument::GetTemplate(isolate));
+        shadowTemplate->Inherit(V8HTMLDocument::GetTemplate(isolate, worldTypeInMainThread(isolate)));
         shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount);
     }
 
index 9355ee3..9e78abf 100644 (file)
@@ -81,7 +81,7 @@ static v8::Handle<v8::Value> v8HTMLImageElementConstructorMethodCustom(const v8:
     return wrapper;
 }
 
-v8::Persistent<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate(v8::Isolate* isolate)
+v8::Persistent<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate(v8::Isolate* isolate, WrapperWorldType worldType)
 {
     static v8::Persistent<v8::FunctionTemplate> cachedTemplate;
     if (!cachedTemplate.IsEmpty())
@@ -93,7 +93,7 @@ v8::Persistent<v8::FunctionTemplate> V8HTMLImageElementConstructor::GetTemplate(
     v8::Local<v8::ObjectTemplate> instance = result->InstanceTemplate();
     instance->SetInternalFieldCount(V8HTMLImageElement::internalFieldCount);
     result->SetClassName(v8::String::NewSymbol("HTMLImageElement"));
-    result->Inherit(V8HTMLImageElement::GetTemplate(isolate));
+    result->Inherit(V8HTMLImageElement::GetTemplate(isolate, worldType));
 
     cachedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, result);
     return cachedTemplate;
index 956bc8d..97b38e5 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 class V8HTMLImageElementConstructor {
 public:
-    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate* = 0);
+    static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWorldType);
     static WrapperTypeInfo info;
 };
 
index b2961e3..7339139 100644 (file)
@@ -55,7 +55,7 @@ static void WeakReferenceCallback(v8::Isolate* isolate, v8::Persistent<v8::Value
 
 static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHost* host, v8::Isolate* isolate)
 {
-    v8::Local<v8::Function> function = V8InjectedScriptHost::GetTemplate(isolate)->GetFunction();
+    v8::Local<v8::Function> function = V8InjectedScriptHost::GetTemplate(isolate, MainWorld)->GetFunction();
     if (function.IsEmpty()) {
         // Return if allocation failed.
         return v8::Local<v8::Object>();
@@ -118,7 +118,7 @@ bool InjectedScriptManager::canAccessInspectedWindow(ScriptState* scriptState)
     v8::Local<v8::Object> global = context->Global();
     if (global.IsEmpty())
         return false;
-    v8::Handle<v8::Object> holder = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate()));
+    v8::Handle<v8::Object> holder = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
     if (holder.IsEmpty())
         return false;
     Frame* frame = V8DOMWindow::toNative(holder)->frame();
index 190aa69..6b6fe6f 100644 (file)
@@ -140,7 +140,7 @@ v8::Handle<v8::Value> V8Location::reloadAttrGetterCustom(v8::Local<v8::String> n
 {
     v8::Isolate* isolate = info.GetIsolate();
     static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::reloadMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))));
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate)));
     if (holder.IsEmpty()) {
         // can only reach here by 'object.__proto__.func', and it should passed
         // domain security check already
@@ -158,7 +158,7 @@ v8::Handle<v8::Value> V8Location::replaceAttrGetterCustom(v8::Local<v8::String>
 {
     v8::Isolate* isolate = info.GetIsolate();
     static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::replaceMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))));
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate)));
     if (holder.IsEmpty()) {
         // can only reach here by 'object.__proto__.func', and it should passed
         // domain security check already
@@ -177,7 +177,7 @@ v8::Handle<v8::Value> V8Location::assignAttrGetterCustom(v8::Local<v8::String> n
     v8::Isolate* isolate = info.GetIsolate();
     static v8::Persistent<v8::FunctionTemplate> privateTemplate =
         v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::assignMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))));
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate)));
     if (holder.IsEmpty()) {
         // can only reach here by 'object.__proto__.func', and it should passed
         // domain security check already
index 5bdeda9..0da8bfa 100644 (file)
@@ -116,7 +116,7 @@ v8::Handle<v8::Value> V8MessageEvent::initMessageEventMethodCustom(const v8::Arg
     DOMWindow* sourceArg = 0;
     if (args[6]->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[6]);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate()));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
         if (!window.IsEmpty())
             sourceArg = V8DOMWindow::toNative(window);
     }