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

Unified Diff: third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp

Issue 1617393002: [DevTools] Not use with statement for evaluated console command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix $1-$4, $_ Created 4 years, 11 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 | « third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp b/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp
index 163107daa64ffda6d2f7d589f48af2c4580ce0ee..0e6d796abb8fbe4ec8af0172f55360165254616b 100644
--- a/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp
+++ b/third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.cpp
@@ -344,6 +344,7 @@ void V8InjectedScriptHost::evaluateWithExceptionDetailsCallback(const v8::Functi
v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
if (wrappedResult.IsEmpty())
return;
+
v8::TryCatch tryCatch(isolate);
v8::Local<v8::Script> script;
v8::Local<v8::Value> result;
@@ -351,11 +352,21 @@ void V8InjectedScriptHost::evaluateWithExceptionDetailsCallback(const v8::Functi
setExceptionAsReturnValue(info, wrappedResult, tryCatch);
return;
}
+
+ v8::Local<v8::Symbol> commandLineAPISymbolValue = commandLineAPISymbol(isolate);
+ v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global();
+ if (info.Length() >= 2 && info[1]->IsObject()) {
+ v8::Local<v8::Object> commandLineAPI = info[1]->ToObject(isolate);
+ global->Set(commandLineAPISymbolValue, commandLineAPI);
+ }
+
if (!v8Call(V8ScriptRunner::runCompiledScript(isolate, script, currentExecutionContext(isolate)), result, tryCatch)) {
+ global->Delete(isolate->GetCurrentContext(), commandLineAPISymbolValue);
setExceptionAsReturnValue(info, wrappedResult, tryCatch);
return;
}
+ global->Delete(isolate->GetCurrentContext(), commandLineAPISymbolValue);
wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result);
wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8::Undefined(isolate));
v8SetReturnValue(info, wrappedResult);
@@ -537,6 +548,24 @@ void V8InjectedScriptHost::idToObjectGroupNameCallback(const v8::FunctionCallbac
info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName));
}
+v8::Local<v8::Symbol> V8InjectedScriptHost::commandLineAPISymbol(v8::Isolate* isolate)
+{
+ return v8::Symbol::ForApi(isolate, v8AtomicString(isolate, "commandLineAPI"));
+}
+
+bool V8InjectedScriptHost::isCommandLineAPIMethod(const AtomicString& name)
+{
+ DEFINE_STATIC_LOCAL(HashSet<String>, methods, ());
+ if (methods.size() == 0) {
+ const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd",
+ "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners",
+ "debug", "undebug", "monitor", "unmonitor", "table", "$_", "$0", "$1", "$2", "$3", "$4" };
+ for (size_t i = 0; i < sizeof(members) / sizeof(const char*); ++i)
+ methods.add(members[i]);
+ }
+ return methods.find(name) != methods.end();
+}
+
namespace {
char hiddenPropertyName[] = "v8inspector::InjectedScriptHost";
« no previous file with comments | « third_party/WebKit/Source/core/inspector/v8/V8InjectedScriptHost.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698