Revert "[inspector] queryObjects returns result"

This reverts commit 9732f422c7.

Reason for revert.

Original change's description:
> [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: Pavel Feldman <pfeldman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#52197}

TBR=pfeldman@chromium.org,kozyatinskiy@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:825349
Change-Id: I90f93b96981d8218b9ad1dc0f4ebfb5a7cb671bc
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Reviewed-on: https://chromium-review.googlesource.com/982431
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52254}
This commit is contained in:
Aleksey Kozyatinskiy 2018-03-28 01:04:10 +00:00 committed by Commit Bot
parent 8d29d92f4d
commit caf74f9c61
3 changed files with 67 additions and 59 deletions

View File

@ -188,6 +188,9 @@ 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) {}
@ -566,8 +569,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,
const String16& hint, V8InspectorImpl* inspector) { InspectRequest request, V8InspectorImpl* inspector) {
if (hint.isEmpty()) info.GetReturnValue().Set(value); if (request == kRegular) 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);
@ -581,8 +584,10 @@ 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 (!hint.isEmpty()) { if (request == kCopyToClipboard) {
hints->setBoolean(hint, true); hints->setBoolean("copyToClipboard", 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),
@ -593,13 +598,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, String16(), m_inspector); inspectImpl(info, info[0], sessionId, kRegular, 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, "copyToClipboard", m_inspector); inspectImpl(info, info[0], sessionId, kCopyToClipboard, m_inspector);
} }
void V8Console::queryObjectsCallback( void V8Console::queryObjectsCallback(
@ -622,10 +627,7 @@ void V8Console::queryObjectsCallback(
return; return;
} }
} }
if (!arg->IsObject()) return; inspectImpl(info, arg, sessionId, kQueryObjects, m_inspector);
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,

View File

@ -120,52 +120,61 @@ Running test: testQueryObjects
} }
} }
} }
{"injectedScriptId":1,"id":10}
{ {
id : <messageId> method : Runtime.inspectRequested
result : { params : {
result : { hints : {
className : Array queryObjects : true
description : Array(1) }
object : {
className : Promise
description : Promise
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is Promise.prototype: true
{ {
id : <messageId> method : Runtime.inspectRequested
result : { params : {
result : { hints : {
className : Array queryObjects : true
description : Array(1) }
object : {
className : Promise
description : Promise
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is Promise.prototype: true
{ {
id : <messageId> method : Runtime.inspectRequested
result : { params : {
result : { hints : {
className : Array queryObjects : true
description : Array(0) }
object : {
className : Object
description : Object
objectId : <objectId> objectId : <objectId>
subtype : array
type : object type : object
} }
} }
} }
Is p: true
{ {
id : <messageId> method : Runtime.inspectRequested
result : { params : {
result : { hints : {
className : Array queryObjects : true
description : Array(0) }
objectId : <objectId> object : {
subtype : array description : 1
type : object type : number
value : 1
} }
} }
} }

View File

@ -36,28 +36,25 @@ 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( let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({expression: 'Promise.prototype'});
{expression: 'class Foo {}; a = new Foo(); Foo'}); Protocol.Runtime.evaluate({expression: 'queryObjects(Promise)', includeCommandLineAPI: true});
InspectorTest.logMessage(objectId); let request = await Protocol.Runtime.onceInspectRequested();
const objectGroup = 'query'; InspectorTest.logMessage(request);
InspectorTest.logMessage(await Protocol.Runtime.evaluate({ InspectorTest.logMessage('Is Promise.prototype: ' + await isEqual(objectId, request.params.object.objectId));
expression: 'queryObjects(Foo)',
includeCommandLineAPI: true, Protocol.Runtime.evaluate({expression: 'queryObjects(Promise.prototype)', includeCommandLineAPI: true});
objectGroup request = await Protocol.Runtime.onceInspectRequested();
})); InspectorTest.logMessage(request);
InspectorTest.logMessage(await Protocol.Runtime.evaluate({ InspectorTest.logMessage('Is Promise.prototype: ' + await isEqual(objectId, request.params.object.objectId));
expression: 'queryObjects(Foo.prototype)',
includeCommandLineAPI: true, ({result:{result:{objectId}}} = await Protocol.Runtime.evaluate({expression:'p = {a:1}'}));
objectGroup Protocol.Runtime.evaluate({expression: 'queryObjects(p)', includeCommandLineAPI: true});
})); request = await Protocol.Runtime.onceInspectRequested();
Protocol.Runtime.releaseObjectGroup({objectGroup}) InspectorTest.logMessage(request);
await Protocol.Runtime.evaluate({expression: 'a = null;'}); InspectorTest.logMessage('Is p: ' + await isEqual(objectId, request.params.object.objectId));
InspectorTest.logMessage(await Protocol.Runtime.evaluate(
{expression: 'queryObjects(Foo)', includeCommandLineAPI: true})); Protocol.Runtime.evaluate({expression: 'queryObjects(1)', includeCommandLineAPI: true});
InspectorTest.logMessage(await Protocol.Runtime.evaluate({ InspectorTest.logMessage(await Protocol.Runtime.onceInspectRequested());
expression: 'queryObjects(Foo.prototype)',
includeCommandLineAPI: true
}));
await Protocol.Runtime.disable(); await Protocol.Runtime.disable();
}, },