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

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: test fixes 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 e821aa35329654789104ee6d79b5e3ef3e1d255b..f7e4197f4b94008753555589c481ea87de5ecacc 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp
@@ -4,6 +4,7 @@
#include "bindings/core/v8/SourceLocation.h"
+#include "bindings/core/v8/V8BindingMacros.h"
#include "bindings/core/v8/V8PerIsolateData.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
@@ -66,6 +67,37 @@ 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();
+ std::unique_ptr<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;
+ }
+
+ int lineNumber = 0;
+ int columnNumber = 0;
+ if (v8Call(message->GetLineNumber(isolate->GetCurrentContext()), lineNumber)
+ && v8Call(message->GetStartColumn(isolate->GetCurrentContext()), columnNumber))
+ ++columnNumber;
+
+ if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty())
+ return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0));
+
+ String url = toCoreStringWithUndefinedOrNullCheck(message->GetScriptOrigin().ResourceName());
+ if (url.isNull())
+ url = executionContext->url();
+ return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));
+}
+
+// static
PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId)
{
return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId));

Powered by Google App Engine
This is Rietveld 408576698