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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/core/v8/PrivateScriptRunner.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/PrivateScriptRunner.h" 6 #include "bindings/core/v8/PrivateScriptRunner.h"
7 7
8 #include "bindings/core/v8/DOMWrapperWorld.h" 8 #include "bindings/core/v8/DOMWrapperWorld.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (!initializeFunction.IsEmpty() && initializeFunction->IsFunction()) { 91 if (!initializeFunction.IsEmpty() && initializeFunction->IsFunction()) {
92 v8::TryCatch block; 92 v8::TryCatch block;
93 V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(initiali zeFunction), scriptState->executionContext(), holder, 0, 0, isolate); 93 V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(initiali zeFunction), scriptState->executionContext(), holder, 0, 0, isolate);
94 if (block.HasCaught()) { 94 if (block.HasCaught()) {
95 WTF_LOG_ERROR("Private script error: Object constructor threw an exception.\n"); 95 WTF_LOG_ERROR("Private script error: Object constructor threw an exception.\n");
96 if (!block.Message().IsEmpty()) 96 if (!block.Message().IsEmpty())
97 WTF_LOG_ERROR("%s\n", toCoreString(block.Message()->Get()).u tf8().data()); 97 WTF_LOG_ERROR("%s\n", toCoreString(block.Message()->Get()).u tf8().data());
98 RELEASE_ASSERT_NOT_REACHED(); 98 RELEASE_ASSERT_NOT_REACHED();
99 } 99 }
100 } 100 }
101
102 // Inject the prototype object of the private script into the prototype chain of the holder object.
103 // This is necessary to let the holder object use properties defined on the prototype object
104 // of the private script. (e.g., if the prototype object has |foo|, the holder object should be able
105 // to use it with |this.foo|.)
106 if (classObject->GetPrototype() != holderObject->GetPrototype())
107 classObject->SetPrototype(holderObject->GetPrototype());
108 holderObject->SetPrototype(classObject);
109
101 isInitialized = v8Boolean(true, isolate); 110 isInitialized = v8Boolean(true, isolate);
102 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv ateScriptObjectIsInitialized(isolate), isInitialized); 111 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv ateScriptObjectIsInitialized(isolate), isInitialized);
103 } 112 }
104 } 113 }
105 114
106 v8::Handle<v8::Value> PrivateScriptRunner::installClassIfNeeded(LocalFrame* fram e, String className) 115 v8::Handle<v8::Value> PrivateScriptRunner::installClassIfNeeded(LocalFrame* fram e, String className)
107 { 116 {
108 if (!frame) 117 if (!frame)
109 return v8::Handle<v8::Value>(); 118 return v8::Handle<v8::Value>();
110 v8::HandleScope handleScope(toIsolate(frame)); 119 v8::HandleScope handleScope(toIsolate(frame));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); 191 RELEASE_ASSERT(!message.IsEmpty() && message->IsString());
183 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code")) ; 192 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code")) ;
184 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); 193 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32());
185 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi tyError. 194 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi tyError.
186 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8:: String>::Cast(message))); 195 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8:: String>::Cast(message)));
187 exceptionState.throwIfNeeded(); 196 exceptionState.throwIfNeeded();
188 return true; 197 return true;
189 } 198 }
190 199
191 } // namespace blink 200 } // namespace blink
OLDNEW
« 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