Commit 915aeab1 authored by Aleksei Koziatinskii's avatar Aleksei Koziatinskii Committed by Commit Bot

inspector: fix queryObjects when page contains JSModuleNamespace

JSModuleNamespace does not have well defined CreationContext: current
implementation of JSReceiver::GetCreationContext crashes on CHECK.

R=lushnikov@chromium.org,yangguo@chromium.org

Bug: none
Change-Id: Ie2c0bfa39117d42d81f9709c21376c177b18e5ba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1652559Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62128}
parent a26adb2b
......@@ -42,6 +42,7 @@ class MatchPrototypePredicate : public v8::debug::QueryObjectPredicate {
: m_inspector(inspector), m_context(context), m_prototype(prototype) {}
bool Filter(v8::Local<v8::Object> object) override {
if (object->IsModuleNamespaceObject()) return false;
v8::Local<v8::Context> objectContext =
v8::debug::GetCreationContext(object);
if (objectContext != m_context) return false;
......
......@@ -39,13 +39,13 @@ Checks basic ES6 modules support.
method : Debugger.scriptParsed
params : {
endColumn : 0
endLine : 8
endLine : 11
executionContextId : <executionContextId>
hasSourceURL : false
hash : 2eda454b04ad45b62a894c7590954c5074ca4569
hash : 2e8186096446efdc472a6e0559ea22216a664cb5
isLiveEdit : false
isModule : true
length : 191
length : 286
scriptId : <scriptId>
sourceMapURL :
startColumn : 0
......@@ -55,17 +55,17 @@ Checks basic ES6 modules support.
}
console.log(module1)
foo (module1:2:10)
(anonymous) (module3:3:12)
(anonymous) (module3:5:12)
console.log(42)
(anonymous) (module3:3:8)
(anonymous) (module3:5:8)
console.log(module2)
foo (module2:2:10)
(anonymous) (module3:4:12)
(anonymous) (module3:6:12)
console.log(239)
(anonymous) (module3:4:8)
(anonymous) (module3:6:8)
{
method : Debugger.paused
......@@ -81,14 +81,14 @@ console.log(239)
functionName :
location : {
columnNumber : 0
lineNumber : 7
lineNumber : 9
scriptId : <scriptId>
}
scopeChain : [
[0] : {
endLocation : {
columnNumber : 0
lineNumber : 8
lineNumber : 11
scriptId : <scriptId>
}
object : {
......@@ -156,6 +156,19 @@ console.log(239)
writable : true
}
[2] : {
configurable : true
enumerable : true
isOwn : true
name : foo3
value : {
className : Module
description : Module
objectId : <objectId>
type : object
}
writable : true
}
[3] : {
configurable : true
enumerable : true
isOwn : true
......@@ -167,7 +180,7 @@ console.log(239)
}
writable : true
}
[3] : {
[4] : {
configurable : true
enumerable : true
isOwn : true
......@@ -239,3 +252,4 @@ console.log(239)
timestamp : <timestamp>
}
}
queryObjects returns Array(N)
......@@ -21,41 +21,59 @@ export let a2 = 2`;
var module3 = `
import { foo as foo1 } from 'module1';
import { foo as foo2 } from 'module2';
// check that queryObjects works with JSModuleNamespace
import * as foo3 from 'module2';
console.log(foo1());
console.log(foo2());
import { a1 } from 'module1';
import { a2 } from 'module2';
debugger;
foo3;
`;
var module4 = '}';
session.setupScriptMap();
// We get scriptParsed events for modules ..
Protocol.Debugger.onScriptParsed(InspectorTest.logMessage);
// .. scriptFailed to parse for modules with syntax error ..
Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage);
// .. API messages from modules contain correct stack trace ..
Protocol.Runtime.onConsoleAPICalled(message => {
InspectorTest.log(`console.log(${message.params.args[0].value})`);
session.logCallFrames(message.params.stackTrace.callFrames);
InspectorTest.log('');
});
// .. we could break inside module and scope contains correct list of variables ..
Protocol.Debugger.onPaused(message => {
InspectorTest.logMessage(message);
Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeChain[0].object.objectId})
.then(InspectorTest.logMessage)
.then(() => Protocol.Debugger.resume());
});
// .. we process uncaught errors from modules correctly.
Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage);
Protocol.Runtime.enable();
Protocol.Debugger.enable()
.then(() => contextGroup.addModule(module1, "module1"))
.then(() => contextGroup.addModule(module2, "module2"))
.then(() => contextGroup.addModule(module3, "module3"))
.then(() => contextGroup.addModule(module4, "module4"))
.then(() => InspectorTest.waitForPendingTasks())
.then(InspectorTest.completeTest);
(async function test() {
session.setupScriptMap();
// We get scriptParsed events for modules ..
Protocol.Debugger.onScriptParsed(InspectorTest.logMessage);
// .. scriptFailed to parse for modules with syntax error ..
Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage);
// .. API messages from modules contain correct stack trace ..
Protocol.Runtime.onConsoleAPICalled(message => {
InspectorTest.log(`console.log(${message.params.args[0].value})`);
session.logCallFrames(message.params.stackTrace.callFrames);
InspectorTest.log('');
});
// .. we could break inside module and scope contains correct list of variables ..
Protocol.Debugger.onPaused(message => {
InspectorTest.logMessage(message);
Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeChain[0].object.objectId})
.then(InspectorTest.logMessage)
.then(() => Protocol.Debugger.resume());
});
// .. we process uncaught errors from modules correctly.
Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage);
Protocol.Runtime.enable();
await Protocol.Debugger.enable();
await contextGroup.addModule(module1, 'module1');
await contextGroup.addModule(module2, 'module2');
await contextGroup.addModule(module3, 'module3');
await contextGroup.addModule(module4, 'module4');
await InspectorTest.waitForPendingTasks();
Protocol.Debugger.onScriptParsed(null);
Protocol.Runtime.evaluate({
includeCommandLineAPI: true,
expression: 'queryObjects(Function)'
});
const {params:{object:{objectId}}} = await Protocol.Runtime.onceInspectRequested();
const {result:{objects}} = await Protocol.Runtime.queryObjects({
prototypeObjectId: objectId
});
InspectorTest.log('queryObjects returns ' + objects.description.replace(/\d+/, 'N'));
InspectorTest.completeTest();
})();
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