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

Unified Diff: extensions/renderer/script_context.cc

Issue 1155183006: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_faster_2
Patch Set: Copy observers Created 5 years, 6 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
« no previous file with comments | « extensions/renderer/script_context.h ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/script_context.cc
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index 32222b0ca065128032dc5142f1401c19ba208368..e6dcfe589112cb26fceda916b1c074589fcf53a6 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -59,6 +59,15 @@ std::string GetContextTypeDescriptionString(Feature::Context context_type) {
return std::string();
}
+static std::string ToStringOrDefault(
+ const v8::Local<v8::String>& v8_string,
+ const std::string& dflt) {
+ if (v8_string.IsEmpty())
+ return dflt;
+ std::string ascii_value = *v8::String::Utf8Value(v8_string);
+ return ascii_value.empty() ? dflt : ascii_value;
+}
+
} // namespace
// A gin::Runner that delegates to its ScriptContext.
@@ -380,6 +389,27 @@ std::string ScriptContext::GetDebugString() const {
GetEffectiveContextTypeDescription().c_str());
}
+std::string ScriptContext::GetStackTraceAsString() const {
+ v8::Local<v8::StackTrace> stack_trace =
+ v8::StackTrace::CurrentStackTrace(isolate(), 10);
+ if (stack_trace.IsEmpty() || stack_trace->GetFrameCount() <= 0) {
+ return " <no stack trace>";
+ } else {
+ std::string result;
+ for (int i = 0; i < stack_trace->GetFrameCount(); ++i) {
+ v8::Local<v8::StackFrame> frame = stack_trace->GetFrame(i);
+ CHECK(!frame.IsEmpty());
+ result += base::StringPrintf(
+ "\n at %s (%s:%d:%d)",
+ ToStringOrDefault(frame->GetFunctionName(), "<anonymous>").c_str(),
+ ToStringOrDefault(frame->GetScriptName(), "<anonymous>").c_str(),
+ frame->GetLineNumber(),
+ frame->GetColumn());
+ }
+ return result;
+ }
+}
+
ScriptContext::Runner::Runner(ScriptContext* context) : context_(context) {
}
« no previous file with comments | « extensions/renderer/script_context.h ('k') | ui/accessibility/ax_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698