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

Unified Diff: Source/bindings/dart/DartHandleProxy.cpp

Issue 28763006: Support $0, $1, ... $6, inspect, and other console api methods. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: ready for review Created 7 years, 2 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: Source/bindings/dart/DartHandleProxy.cpp
diff --git a/Source/bindings/dart/DartHandleProxy.cpp b/Source/bindings/dart/DartHandleProxy.cpp
index cbe2c15a53e2d6f47dc857c2cc43b8fa0dcdb5fe..78637cf5630c95bd4b1e3e6b09f074107f5931d9 100644
--- a/Source/bindings/dart/DartHandleProxy.cpp
+++ b/Source/bindings/dart/DartHandleProxy.cpp
@@ -31,6 +31,7 @@
#include "bindings/dart/DartHandleProxy.h"
#include "DartNode.h"
+#include "bindings/dart/DartJsInterop.h"
#include "bindings/dart/DartScriptValue.h"
#include "bindings/dart/V8Converter.h"
#include "bindings/v8/PageScriptDebugServer.h"
@@ -1124,11 +1125,10 @@ v8::Handle<v8::Value> DartHandleProxy::createLocalScopeProxy(Dart_Handle localVa
v8::Handle<v8::Value> DartHandleProxy::evaluate(Dart_Handle target, Dart_Handle expression, Dart_Handle localVariables)
{
+ DartDOMData* domData = DartDOMData::current();
+ ASSERT(domData);
ASSERT(Dart_IsList(localVariables) || Dart_IsNull(localVariables));
- intptr_t localVariablesLength = 0;
- Dart_ListLength(localVariables, &localVariablesLength);
- Dart_Handle wrapExpressionArgs[2] = { expression, localVariables };
Dart_Handle exception = 0;
bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isJsExpression", 1, &expression), exception);
ASSERT(!exception);
@@ -1142,6 +1142,53 @@ v8::Handle<v8::Value> DartHandleProxy::evaluate(Dart_Handle target, Dart_Handle
return result;
}
+ bool expectsConsoleApi = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("expectsConsoleApi", 1, &expression), exception);
+ ASSERT(!exception);
+ Dart_Handle commandLineApi;
+ if (expectsConsoleApi) {
+ // Vector of local variables and injected console variables.
+ Vector<Dart_Handle> locals;
+ if (Dart_IsList(localVariables)) {
+ DartUtilities::extractListElements(localVariables, exception, locals);
+ ASSERT(!exception);
+ }
+ // Use JsInterop to proxy all properties and functions defined by
+ // window.console._commandLineAPI
+ v8::Handle<v8::Value> v8Console = v8::Context::GetCurrent()->Global()->Get(v8::String::NewSymbol("console"));
+ if (v8Console->IsObject()) {
+ v8::Handle<v8::Value> commandLineApiValue = v8Console.As<v8::Object>()->Get(v8::String::NewSymbol("_commandLineAPI"));
+ if (commandLineApiValue->IsObject()) {
+ v8::Handle<v8::Object> commandLineApi = commandLineApiValue.As<v8::Object>();
+ v8::Local<v8::Array> propertyNames = commandLineApi->GetOwnPropertyNames();
+ uint32_t length = propertyNames->Length();
+ for (uint32_t i = 0; i < length; i++) {
+ v8::Handle<v8::String> propertyName = propertyNames->Get(i).As<v8::String>();
+ ASSERT(!propertyNames.IsEmpty());
+ v8::Handle<v8::Value> propertyValue = commandLineApi->Get(propertyName);
+
+ Dart_Handle dartValue;
+ if (propertyValue->IsFunction()) {
+ dartValue = JsInterop::toDart(propertyValue);
+ // We need to wrap the JsFunction object we get back
+ // from the vanila JsInterop library so that users can
+ // call it like a normal Dart function instead of
+ // having to use the apply method.
+ dartValue = Dart_Invoke(domData->jsLibrary(), Dart_NewStringFromCString("_wrapAsDebuggerVarArgsFunction"), 1, &dartValue);
+ } else {
+ dartValue = JsInterop::toDart(propertyValue);
+ }
+ locals.append(V8Converter::stringToDart(propertyName));
+ locals.append(dartValue);
+ }
+ }
+ }
+ localVariables = DartUtilities::toList(locals, exception);
+ ASSERT(!exception);
+ } else {
+ commandLineApi = Dart_Null();
+ }
+
+ Dart_Handle wrapExpressionArgs[2] = { expression, localVariables };
Dart_Handle wrappedExpressionTuple =
DartUtilities::invokeUtilsMethod("wrapExpressionAsClosure", 2, wrapExpressionArgs);
ASSERT(Dart_IsList(wrappedExpressionTuple));
« no previous file with comments | « LayoutTests/dart/inspector/debugger-eval-on-call-frame-expected.txt ('k') | Source/bindings/dart/DartJsInterop.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698