OLD | NEW |
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...) Loading... |
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 if (classObject->GetPrototype() != holderObject->GetPrototype()) |
| 103 classObject->SetPrototype(holderObject->GetPrototype()); |
| 104 holderObject->SetPrototype(classObject); |
| 105 |
101 isInitialized = v8Boolean(true, isolate); | 106 isInitialized = v8Boolean(true, isolate); |
102 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv
ateScriptObjectIsInitialized(isolate), isInitialized); | 107 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv
ateScriptObjectIsInitialized(isolate), isInitialized); |
103 } | 108 } |
104 } | 109 } |
105 | 110 |
106 v8::Handle<v8::Value> PrivateScriptRunner::installClassIfNeeded(LocalFrame* fram
e, String className) | 111 v8::Handle<v8::Value> PrivateScriptRunner::installClassIfNeeded(LocalFrame* fram
e, String className) |
107 { | 112 { |
108 if (!frame) | 113 if (!frame) |
109 return v8::Handle<v8::Value>(); | 114 return v8::Handle<v8::Value>(); |
110 v8::HandleScope handleScope(toIsolate(frame)); | 115 v8::HandleScope handleScope(toIsolate(frame)); |
(...skipping 71 matching lines...) Loading... |
182 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); | 187 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); |
183 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code"))
; | 188 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code"))
; |
184 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); | 189 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); |
185 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi
tyError. | 190 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi
tyError. |
186 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8::
String>::Cast(message))); | 191 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8::
String>::Cast(message))); |
187 exceptionState.throwIfNeeded(); | 192 exceptionState.throwIfNeeded(); |
188 return true; | 193 return true; |
189 } | 194 } |
190 | 195 |
191 } // namespace blink | 196 } // namespace blink |
OLD | NEW |