| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 bool PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(v8::Isolate*
isolate, ExceptionState& exceptionState, v8::Handle<v8::Value> exception) | 179 bool PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(v8::Isolate*
isolate, ExceptionState& exceptionState, v8::Handle<v8::Value> exception) |
| 180 { | 180 { |
| 181 if (exception.IsEmpty() || !exception->IsObject()) | 181 if (exception.IsEmpty() || !exception->IsObject()) |
| 182 return false; | 182 return false; |
| 183 | 183 |
| 184 v8::Handle<v8::Object> exceptionObject = v8::Handle<v8::Object>::Cast(except
ion); | 184 v8::Handle<v8::Object> exceptionObject = v8::Handle<v8::Object>::Cast(except
ion); |
| 185 v8::Handle<v8::Value> name = exceptionObject->Get(v8String(isolate, "name"))
; | 185 v8::Handle<v8::Value> name = exceptionObject->Get(v8String(isolate, "name"))
; |
| 186 if (name.IsEmpty() || !name->IsString()) | 186 if (name.IsEmpty() || !name->IsString()) |
| 187 return false; | 187 return false; |
| 188 String exceptionName = toCoreString(v8::Handle<v8::String>::Cast(name)); | 188 String exceptionName = toCoreString(v8::Handle<v8::String>::Cast(name)); |
| 189 { |
| 190 // FIXME: remove this. |
| 191 // This is a temporal hack to show the error message. |
| 192 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "
message")); |
| 193 String messageStr = toCoreString(v8::Handle<v8::String>::Cast(message)); |
| 194 printf("message: %s\n", messageStr.utf8().data()); |
| 195 } |
| 189 if (exceptionName == "DOMExceptionInPrivateScript") { | 196 if (exceptionName == "DOMExceptionInPrivateScript") { |
| 190 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "
message")); | 197 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "
message")); |
| 191 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); | 198 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); |
| 192 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "cod
e")); | 199 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "cod
e")); |
| 193 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); | 200 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); |
| 194 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<
v8::String>::Cast(message))); | 201 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<
v8::String>::Cast(message))); |
| 195 exceptionState.throwIfNeeded(); | 202 exceptionState.throwIfNeeded(); |
| 196 return true; | 203 return true; |
| 197 } | 204 } |
| 198 if (exceptionName == "Error") { | 205 if (exceptionName == "Error") { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 227 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "
message")); | 234 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "
message")); |
| 228 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); | 235 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); |
| 229 exceptionState.throwDOMException(V8ReferenceError, toCoreString(v8::Hand
le<v8::String>::Cast(message))); | 236 exceptionState.throwDOMException(V8ReferenceError, toCoreString(v8::Hand
le<v8::String>::Cast(message))); |
| 230 exceptionState.throwIfNeeded(); | 237 exceptionState.throwIfNeeded(); |
| 231 return true; | 238 return true; |
| 232 } | 239 } |
| 233 return false; | 240 return false; |
| 234 } | 241 } |
| 235 | 242 |
| 236 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |