Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 if (result.IsEmpty() || !result->IsBoolean()) | 184 if (result.IsEmpty() || !result->IsBoolean()) |
| 185 return false; | 185 return false; |
| 186 return result->BooleanValue(); | 186 return result->BooleanValue(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const | 189 v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const |
| 190 { | 190 { |
| 191 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt ernalized(m_isolate, "returnValue")); | 191 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt ernalized(m_isolate, "returnValue")); |
| 192 } | 192 } |
| 193 | 193 |
| 194 v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local <v8::Value> expression, v8::Local<v8::Value> scopeExtension) | 194 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8:: Local<v8::Value> expression) |
|
dgozman
2016/03/17 19:16:12
Rename to evaluate.
kozy
2016/03/17 20:48:56
Done.
| |
| 195 { | 195 { |
| 196 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask s); | 196 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask s); |
| 197 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); | 197 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); |
| 198 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(toV8StringInternalized(m_isolate, "evaluate"))); | 198 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(toV8StringInternalized(m_isolate, "evaluate"))); |
| 199 v8::Local<v8::Value> argv[] = { | 199 v8::Local<v8::Value> argv[] = { |
| 200 expression, | 200 expression |
| 201 scopeExtension | |
| 202 }; | 201 }; |
| 203 v8::TryCatch tryCatch(m_isolate); | 202 return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, WTF_ARR AY_LENGTH(argv), argv); |
|
dgozman
2016/03/17 19:16:12
1, &expression
kozy
2016/03/17 20:48:56
Done.
| |
| 204 v8::Local<v8::Object> wrappedResult = v8::Object::New(m_isolate); | |
| 205 v8::Local<v8::Value> result; | |
| 206 if (evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, WTF_ARRAY_ LENGTH(argv), argv).ToLocal(&result)) { | |
| 207 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result) ; | |
| 208 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), v8::Undefined(m_isolate)); | |
| 209 } else { | |
| 210 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc h.Exception()); | |
| 211 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), createExceptionDetails(m_isolate, tryCatch.Message())); | |
| 212 } | |
| 213 return wrappedResult; | |
| 214 } | 203 } |
| 215 | 204 |
| 216 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() | 205 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() |
| 217 { | 206 { |
| 218 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); | 207 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); |
| 219 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); | 208 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca llFrame); |
| 220 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(toV8StringInternalized(m_isolate, "restart"))); | 209 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(toV8StringInternalized(m_isolate, "restart"))); |
| 221 v8::Debug::SetLiveEditEnabled(m_isolate, true); | 210 v8::Debug::SetLiveEditEnabled(m_isolate, true); |
| 222 v8::MaybeLocal<v8::Value> result = restartFunction->Call(m_isolate->GetCurre ntContext(), callFrame, 0, nullptr); | 211 v8::MaybeLocal<v8::Value> result = restartFunction->Call(m_isolate->GetCurre ntContext(), callFrame, 0, nullptr); |
| 223 v8::Debug::SetLiveEditEnabled(m_isolate, false); | 212 v8::Debug::SetLiveEditEnabled(m_isolate, false); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 246 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer: :New(isolate, message->GetLineNumber())); | 235 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer: :New(isolate, message->GetLineNumber())); |
| 247 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Intege r::New(isolate, message->GetStartColumn())); | 236 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Intege r::New(isolate, message->GetStartColumn())); |
| 248 if (!message->GetStackTrace().IsEmpty()) | 237 if (!message->GetStackTrace().IsEmpty()) |
| 249 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me ssage->GetStackTrace()->AsArray()); | 238 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me ssage->GetStackTrace()->AsArray()); |
| 250 else | 239 else |
| 251 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); | 240 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); |
| 252 return exceptionDetails; | 241 return exceptionDetails; |
| 253 } | 242 } |
| 254 | 243 |
| 255 } // namespace blink | 244 } // namespace blink |
| OLD | NEW |