Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: Source/bindings/core/v8/PrivateScriptRunner.cpp

Issue 419683003: Inject a prototype object of a private script into the prototype chain of a holder object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/PrivateScriptRunner.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/PrivateScriptRunner.cpp
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.cpp b/Source/bindings/core/v8/PrivateScriptRunner.cpp
index 491578038954b98bb5ccf68ea57d0f01cf68c269..fabaec56be687e628ee5be08631f8e6f5780b92c 100644
--- a/Source/bindings/core/v8/PrivateScriptRunner.cpp
+++ b/Source/bindings/core/v8/PrivateScriptRunner.cpp
@@ -98,6 +98,15 @@ static void initializeHolderIfNeeded(ScriptState* scriptState, v8::Handle<v8::Ob
RELEASE_ASSERT_NOT_REACHED();
}
}
+
+ // 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())
+ classObject->SetPrototype(holderObject->GetPrototype());
+ holderObject->SetPrototype(classObject);
+
isInitialized = v8Boolean(true, isolate);
V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate), isInitialized);
}
« no previous file with comments | « no previous file | Source/bindings/core/v8/PrivateScriptRunner.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698