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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp

Issue 2010603002: Use SourceLocation when reporting runtime exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2004243002
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
index fb4d6f3392febe0a30a643f1fa03a903da41c549..d4f80668ae4fdc9d0aed16158aba09d1e0332a07 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
@@ -66,6 +66,40 @@ PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionCo
}
// static
+PassOwnPtr<SourceLocation> SourceLocation::fromMessage(v8::Isolate* isolate, v8::Local<v8::Message> message, ExecutionContext* executionContext)
+{
+ v8::Local<v8::StackTrace> stack = message->GetStackTrace();
+
+ OwnPtr<V8StackTrace> stackTrace = nullptr;
+ V8PerIsolateData* data = V8PerIsolateData::from(isolate);
+ if (data && data->threadDebugger())
+ stackTrace = data->threadDebugger()->debugger()->createStackTrace(stack);
+
+ int scriptId = message->GetScriptOrigin().ScriptID()->Value();
+ if (!stack.IsEmpty() && stack->GetFrameCount() > 0) {
+ int topScriptId = stack->GetFrame(0)->GetScriptId();
+ if (topScriptId == scriptId)
+ scriptId = 0;
+ }
+
+ unsigned lineNumber = message->GetLineNumber(isolate->GetCurrentContext()).FromMaybe(0);
+ unsigned columnNumber = message->GetStartColumn(isolate->GetCurrentContext()).FromMaybe(-1) + 1;
haraken 2016/05/24 19:48:34 Use v8Call macros in V8BindingMacros.h.
dgozman 2016/05/24 23:13:22 Done.
+
+ if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty())
+ return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0));
+
+ v8::Local<v8::Value> resourceName = message->GetScriptOrigin().ResourceName();
+ String url = executionContext->url();
+ bool shouldUseDocumentURL = executionContext->isDocument() && (resourceName.IsEmpty() || !resourceName->IsString());
+ if (!shouldUseDocumentURL) {
+ V8StringResource<> v8ResourceName(resourceName);
haraken 2016/05/24 19:48:34 url = toCoreString(resourceName); will work.
dgozman 2016/05/24 23:13:22 Done. Used toCoreStringWithUndefinedOrNullCheck, s
+ if (v8ResourceName.prepare())
+ url = v8ResourceName;
+ }
+ return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));
+}
+
+// static
PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned lineNumber, unsigned columnNumber, PassOwnPtr<V8StackTrace> stackTrace, int scriptId)
{
return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));

Powered by Google App Engine
This is Rietveld 408576698