| Index: third_party/WebKit/Source/bindings/core/v8/PrivateScriptRunner.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/PrivateScriptRunner.cpp b/third_party/WebKit/Source/bindings/core/v8/PrivateScriptRunner.cpp
|
| index 1f50f696ddc93fb454c485b4f85f814f9190c52f..0128c8fb0a92b08fc6f2e2f000c5457327a0944a 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/PrivateScriptRunner.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/PrivateScriptRunner.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "bindings/core/v8/ExceptionState.h"
|
| #include "bindings/core/v8/V8Binding.h"
|
| #include "bindings/core/v8/V8PerContextData.h"
|
| +#include "bindings/core/v8/V8PrivateProperty.h"
|
| #include "bindings/core/v8/V8ScriptRunner.h"
|
| #include "core/PrivateScriptSources.h"
|
| #ifndef NDEBUG
|
| @@ -189,40 +190,40 @@ static void initializeHolderIfNeeded(ScriptState* scriptState, v8::Local<v8::Obj
|
| v8::Local<v8::Object> holderObject = v8::Local<v8::Object>::Cast(holder);
|
| v8::Isolate* isolate = scriptState->isolate();
|
| v8::Local<v8::Context> context = scriptState->context();
|
| - v8::Local<v8::Value> isInitialized = V8HiddenValue::getHiddenValue(scriptState, holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate));
|
| - if (isInitialized.IsEmpty()) {
|
| + auto privateIsInitialized = V8PrivateProperty::getPrivateScriptRunnerIsInitialized(isolate);
|
| + if (privateIsInitialized.hasValue(context, holderObject))
|
| + return; // Already initialized.
|
| +
|
| + v8::TryCatch block(isolate);
|
| + v8::Local<v8::Value> initializeFunction;
|
| + if (classObject->Get(scriptState->context(), v8String(isolate, "initialize")).ToLocal(&initializeFunction) && initializeFunction->IsFunction()) {
|
| v8::TryCatch block(isolate);
|
| - v8::Local<v8::Value> initializeFunction;
|
| - if (classObject->Get(scriptState->context(), v8String(isolate, "initialize")).ToLocal(&initializeFunction) && initializeFunction->IsFunction()) {
|
| - v8::TryCatch block(isolate);
|
| - v8::Local<v8::Value> result;
|
| - if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(initializeFunction), scriptState->getExecutionContext(), holder, 0, 0, isolate).ToLocal(&result)) {
|
| - fprintf(stderr, "Private script error: Object constructor threw an exception.\n");
|
| - dumpV8Message(context, block.Message());
|
| - RELEASE_NOTREACHED();
|
| - }
|
| + v8::Local<v8::Value> result;
|
| + if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(initializeFunction), scriptState->getExecutionContext(), holder, 0, 0, isolate).ToLocal(&result)) {
|
| + fprintf(stderr, "Private script error: Object constructor threw an exception.\n");
|
| + dumpV8Message(context, block.Message());
|
| + RELEASE_NOTREACHED();
|
| }
|
| + }
|
|
|
| - // Inject the prototype object of the private script into the prototype chain of the holder object.
|
| - // This is necessary to let the holder object use properties defined on the prototype object
|
| - // of the private script. (e.g., if the prototype object has |foo|, the holder object should be able
|
| - // to use it with |this.foo|.)
|
| - if (classObject->GetPrototype() != holderObject->GetPrototype()) {
|
| - if (!v8CallBoolean(classObject->SetPrototype(context, holderObject->GetPrototype()))) {
|
| - fprintf(stderr, "Private script error: SetPrototype failed.\n");
|
| - dumpV8Message(context, block.Message());
|
| - RELEASE_NOTREACHED();
|
| - }
|
| - }
|
| - if (!v8CallBoolean(holderObject->SetPrototype(context, classObject))) {
|
| + // Inject the prototype object of the private script into the prototype chain of the holder object.
|
| + // This is necessary to let the holder object use properties defined on the prototype object
|
| + // of the private script. (e.g., if the prototype object has |foo|, the holder object should be able
|
| + // to use it with |this.foo|.)
|
| + if (classObject->GetPrototype() != holderObject->GetPrototype()) {
|
| + if (!v8CallBoolean(classObject->SetPrototype(context, holderObject->GetPrototype()))) {
|
| fprintf(stderr, "Private script error: SetPrototype failed.\n");
|
| dumpV8Message(context, block.Message());
|
| RELEASE_NOTREACHED();
|
| }
|
| -
|
| - isInitialized = v8Boolean(true, isolate);
|
| - V8HiddenValue::setHiddenValue(scriptState, holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate), isInitialized);
|
| }
|
| + if (!v8CallBoolean(holderObject->SetPrototype(context, classObject))) {
|
| + fprintf(stderr, "Private script error: SetPrototype failed.\n");
|
| + dumpV8Message(context, block.Message());
|
| + RELEASE_NOTREACHED();
|
| + }
|
| +
|
| + privateIsInitialized.set(context, holderObject, v8Boolean(true, isolate));
|
| }
|
|
|
| v8::Local<v8::Value> PrivateScriptRunner::installClassIfNeeded(Document* document, String className)
|
|
|