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 5d73eba912b751c4202c91332a6d521c214e076a..f1060f5f6f011d5be07c52fa0545d8cb479329f8 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp |
| @@ -31,6 +31,7 @@ |
| #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| #include "bindings/core/v8/ScriptCallStack.h" |
| +#include "bindings/core/v8/ScriptController.h" |
| #include "bindings/core/v8/ScriptSourceCode.h" |
| #include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" |
| @@ -165,8 +166,21 @@ bool WorkerOrWorkletScriptController::initializeContextIfNeeded() |
| v8::Local<v8::ObjectTemplate> globalTemplate = globalInterfaceTemplate->InstanceTemplate(); |
| v8::Local<v8::Context> context; |
| { |
| + // Initialize V8 extensions before creating the context. |
| + Vector<const char*> extensionNames; |
| + if (m_globalScope->isServiceWorkerGlobalScope()) { |
| + // TODO(lazyboy): Should we add V8Extensions to all service worker |
| + // contexts, when we actually don't care about them in non extension |
| + // service worker contexts? |
| + const V8Extensions& extensions = ScriptController::registeredExtensions(); |
|
haraken
2016/04/22 18:33:21
Nit: Now it doesn't make sense to put the register
lazyboy
2016/04/22 20:45:19
OK, I'll move it in a separate CL, I've also fixed
|
| + extensionNames.reserveInitialCapacity(extensions.size()); |
| + for (const auto* extension : extensions) |
| + extensionNames.append(extension->name()); |
| + } |
| + v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), extensionNames.data()); |
| + |
| V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolateData::from(m_isolate)); |
| - context = v8::Context::New(m_isolate, nullptr, globalTemplate); |
| + context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate); |
| } |
| if (context.IsEmpty()) |
| return false; |