Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| index 43079ab58290e3addff5e4aa65172b9316a6168e..2fe253c475004a3535a5c33c2d782fb16a03d3dc 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| @@ -156,7 +156,16 @@ bool WorkerOrWorkletScriptController::initializeContextIfNeeded() |
| if (isContextInitialized()) |
| return true; |
| - v8::Local<v8::Context> context = v8::Context::New(m_isolate); |
| + // Create a new v8::Context with the worker/worklet as the global object |
| + // (aka the inner global). |
| + ScriptWrappable* scriptWrappable = m_globalScope->getScriptWrappable(); |
| + const WrapperTypeInfo* wrapperTypeInfo = scriptWrappable->wrapperTypeInfo(); |
| + v8::Local<v8::ObjectTemplate> globalTemplate = wrapperTypeInfo->domTemplate(m_isolate, *m_world)->InstanceTemplate(); |
|
haraken
2016/04/18 08:04:15
Add:
if (globalTemplate.IsEmpty())
return f
Yuki
2016/04/18 09:17:43
Done.
|
| + v8::Local<v8::Context> context; |
| + { |
| + V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolateData::from(m_isolate)); |
| + context = v8::Context::New(m_isolate, nullptr, globalTemplate); |
| + } |
| if (context.IsEmpty()) |
| return false; |
| @@ -172,24 +181,13 @@ bool WorkerOrWorkletScriptController::initializeContextIfNeeded() |
| debugger->contextCreated(context); |
| } |
| - // Create a new JS object and use it as the prototype for the shadow global object. |
| - const WrapperTypeInfo* wrapperTypeInfo = m_globalScope->getScriptWrappable()->wrapperTypeInfo(); |
| + // The global proxy object. Note this is not the global object. |
|
haraken
2016/04/18 08:04:15
Is "global proxy object" a term used in the spec o
Yuki
2016/04/18 08:27:07
I think that V8 team is using the terms of "global
haraken
2016/04/18 09:26:40
Thanks for the clarification! Let's use the same t
|
| + v8::Local<v8::Object> globalProxy = context->Global(); |
| + // The global object, aka worker/worklet wrapper object. |
| + v8::Local<v8::Object> globalObject = globalProxy->GetPrototype().As<v8::Object>(); |
| + globalObject = V8DOMWrapper::associateObjectWithWrapper(m_isolate, scriptWrappable, wrapperTypeInfo, globalObject); |
| - v8::Local<v8::Function> globalScopeConstructor = m_scriptState->perContextData()->constructorForType(wrapperTypeInfo); |
| - if (globalScopeConstructor.IsEmpty()) |
| - return false; |
| - |
| - v8::Local<v8::Object> jsGlobalScope; |
| - if (!V8ObjectConstructor::newInstance(m_isolate, globalScopeConstructor).ToLocal(&jsGlobalScope)) { |
| - disposeContextIfNeeded(); |
| - return false; |
| - } |
| - |
| - jsGlobalScope = V8DOMWrapper::associateObjectWithWrapper(m_isolate, m_globalScope->getScriptWrappable(), wrapperTypeInfo, jsGlobalScope); |
| - |
| - // Insert the object instance as the prototype of the shadow object. |
| - v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptState->context()->Global()->GetPrototype()); |
| - return v8CallBoolean(globalObject->SetPrototype(context, jsGlobalScope)); |
| + return true; |
| } |
| ScriptValue WorkerOrWorkletScriptController::evaluate(const CompressibleString& script, const String& fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cacheHandler, V8CacheOptions v8CacheOptions) |