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)); |