Commit 9732f422 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] queryObjects returns result

queryObjects command line API return array instead of sending
inspectRequest notification.

R=pfeldman@chromium.org

Bug: chromium:825349
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ie6c64419cb108b313c43b66eab533c5a7d5d9024
Reviewed-on: https://chromium-review.googlesource.com/978464
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52197}
parent df6cf50b
...@@ -188,9 +188,6 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context, ...@@ -188,9 +188,6 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context,
} }
createDataProperty(context, console, funcName, func); createDataProperty(context, console, funcName, func);
} }
enum InspectRequest { kRegular, kCopyToClipboard, kQueryObjects };
} // namespace } // namespace
V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {} V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {}
...@@ -569,8 +566,8 @@ void V8Console::lastEvaluationResultCallback( ...@@ -569,8 +566,8 @@ void V8Console::lastEvaluationResultCallback(
static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
v8::Local<v8::Value> value, int sessionId, v8::Local<v8::Value> value, int sessionId,
InspectRequest request, V8InspectorImpl* inspector) { const String16& hint, V8InspectorImpl* inspector) {
if (request == kRegular) info.GetReturnValue().Set(value); if (hint.isEmpty()) info.GetReturnValue().Set(value);
v8::debug::ConsoleCallArguments args(info); v8::debug::ConsoleCallArguments args(info);
ConsoleHelper helper(args, v8::debug::ConsoleContext(), inspector); ConsoleHelper helper(args, v8::debug::ConsoleContext(), inspector);
...@@ -584,10 +581,8 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, ...@@ -584,10 +581,8 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
std::unique_ptr<protocol::DictionaryValue> hints = std::unique_ptr<protocol::DictionaryValue> hints =
protocol::DictionaryValue::create(); protocol::DictionaryValue::create();
if (request == kCopyToClipboard) { if (!hint.isEmpty()) {
hints->setBoolean("copyToClipboard", true); hints->setBoolean(hint, true);
} else if (request == kQueryObjects) {
hints->setBoolean("queryObjects", true);
} }
if (V8InspectorSessionImpl* session = helper.session(sessionId)) { if (V8InspectorSessionImpl* session = helper.session(sessionId)) {
session->runtimeAgent()->inspect(std::move(wrappedObject), session->runtimeAgent()->inspect(std::move(wrappedObject),
...@@ -598,13 +593,13 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, ...@@ -598,13 +593,13 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
void V8Console::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info, void V8Console::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
int sessionId) { int sessionId) {
if (info.Length() < 1) return; if (info.Length() < 1) return;
inspectImpl(info, info[0], sessionId, kRegular, m_inspector); inspectImpl(info, info[0], sessionId, String16(), m_inspector);
} }
void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info, void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
int sessionId) { int sessionId) {
if (info.Length() < 1) return; if (info.Length() < 1) return;
inspectImpl(info, info[0], sessionId, kCopyToClipboard, m_inspector); inspectImpl(info, info[0], sessionId, "copyToClipboard", m_inspector);
} }
void V8Console::queryObjectsCallback( void V8Console::queryObjectsCallback(
...@@ -627,7 +622,10 @@ void V8Console::queryObjectsCallback( ...@@ -627,7 +622,10 @@ void V8Console::queryObjectsCallback(
return; return;
} }
} }
inspectImpl(info, arg, sessionId, kQueryObjects, m_inspector); if (!arg->IsObject()) return;
info.GetReturnValue().Set(m_inspector->debugger()->queryObjects(
info.GetIsolate()->GetCurrentContext(),
v8::Local<v8::Object>::Cast(arg)));
} }
void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
......
...@@ -120,61 +120,52 @@ Running test: testQueryObjects ...@@ -120,61 +120,52 @@ Running test: testQueryObjects
} }
} }
} }
{"injectedScriptId":1,"id":10}
{ {
method : Runtime.inspectRequested id : <messageId>
params : { result : {
hints : { result : {
queryObjects : true className : Array
} description : Array(1)
object : {
className : Promise
description : Promise
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is Promise.prototype: true
{ {
method : Runtime.inspectRequested id : <messageId>
params : { result : {
hints : { result : {
queryObjects : true className : Array
} description : Array(1)
object : {
className : Promise
description : Promise
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is Promise.prototype: true
{ {
method : Runtime.inspectRequested id : <messageId>
params : { result : {
hints : { result : {
queryObjects : true className : Array
} description : Array(0)
object : {
className : Object
description : Object
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is p: true
{ {
method : Runtime.inspectRequested id : <messageId>
params : { result : {
hints : { result : {
queryObjects : true className : Array
} description : Array(0)
object : { objectId : <objectId>
description : 1 subtype : array
type : number type : object
value : 1
} }
} }
} }
......
...@@ -36,25 +36,28 @@ InspectorTest.runAsyncTestSuite([ ...@@ -36,25 +36,28 @@ InspectorTest.runAsyncTestSuite([
async function testQueryObjects() { async function testQueryObjects() {
InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'queryObjects', includeCommandLineAPI: true})); InspectorTest.logMessage(await Protocol.Runtime.evaluate({expression: 'queryObjects', includeCommandLineAPI: true}));
await Protocol.Runtime.enable(); await Protocol.Runtime.enable();
let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({expression: 'Promise.prototype'}); let {result: {result: {objectId}}} = await Protocol.Runtime.evaluate(
Protocol.Runtime.evaluate({expression: 'queryObjects(Promise)', includeCommandLineAPI: true}); {expression: 'class Foo {}; a = new Foo(); Foo'});
let request = await Protocol.Runtime.onceInspectRequested(); InspectorTest.logMessage(objectId);
InspectorTest.logMessage(request); const objectGroup = 'query';
InspectorTest.logMessage('Is Promise.prototype: ' + await isEqual(objectId, request.params.object.objectId)); InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: 'queryObjects(Foo)',
Protocol.Runtime.evaluate({expression: 'queryObjects(Promise.prototype)', includeCommandLineAPI: true}); includeCommandLineAPI: true,
request = await Protocol.Runtime.onceInspectRequested(); objectGroup
InspectorTest.logMessage(request); }));
InspectorTest.logMessage('Is Promise.prototype: ' + await isEqual(objectId, request.params.object.objectId)); InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: 'queryObjects(Foo.prototype)',
({result:{result:{objectId}}} = await Protocol.Runtime.evaluate({expression:'p = {a:1}'})); includeCommandLineAPI: true,
Protocol.Runtime.evaluate({expression: 'queryObjects(p)', includeCommandLineAPI: true}); objectGroup
request = await Protocol.Runtime.onceInspectRequested(); }));
InspectorTest.logMessage(request); Protocol.Runtime.releaseObjectGroup({objectGroup})
InspectorTest.logMessage('Is p: ' + await isEqual(objectId, request.params.object.objectId)); await Protocol.Runtime.evaluate({expression: 'a = null;'});
InspectorTest.logMessage(await Protocol.Runtime.evaluate(
Protocol.Runtime.evaluate({expression: 'queryObjects(1)', includeCommandLineAPI: true}); {expression: 'queryObjects(Foo)', includeCommandLineAPI: true}));
InspectorTest.logMessage(await Protocol.Runtime.onceInspectRequested()); InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: 'queryObjects(Foo.prototype)',
includeCommandLineAPI: true
}));
await Protocol.Runtime.disable(); await Protocol.Runtime.disable();
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment