[inspector] improved injected-script-source

setupInjectedScriptEnvironment should check array getters/setters as well.

R=dgozman@chromium.org

Bug: none
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I72b03f62980e339d83bcfda55f1d35135b23da3b
Reviewed-on: https://chromium-review.googlesource.com/636469
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47623}
This commit is contained in:
Alexey Kozyatinskiy 2017-08-25 16:13:23 -07:00 committed by Commit Bot
parent 8aed7767d6
commit 0bdc7bbabc
4 changed files with 24 additions and 6 deletions

View File

@ -856,6 +856,7 @@ InjectedScript.RemoteObject.prototype = {
properties: [],
__proto__: null
};
InjectedScriptHost.nullifyPrototype(preview.properties);
if (this.subtype)
preview.subtype = /** @type {!RuntimeAgent.ObjectPreviewSubtype.<string>} */ (this.subtype);
return preview;
@ -1041,6 +1042,7 @@ InjectedScript.RemoteObject.prototype = {
return;
}
preview.entries = [];
InjectedScriptHost.nullifyPrototype(preview.entries);
var entriesThreshold = 5;
for (var i = 0; i < entries.length; ++i) {
if (preview.entries.length >= entriesThreshold) {

View File

@ -235,4 +235,14 @@ expression: ({})
Running test: overridenArrayGetter
expression: Promise.resolve(42)
{
name : [[PromiseStatus]]
type : string
value : resolved
}
{
name : [[PromiseValue]]
type : number
value : 42
}

View File

@ -8,6 +8,8 @@ Protocol.Debugger.enable();
Protocol.Runtime.enable();
Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries);
contextGroup.setupInjectedScriptEnvironment();
InspectorTest.runTestSuite([
function boxedObjects(next)
{

View File

@ -129,7 +129,7 @@ InspectorTest.ContextGroup = class {
return new InspectorTest.Session(this);
}
setupInjectedScriptEnvironment(debug) {
setupInjectedScriptEnvironment(session) {
let scriptSource = '';
// First define all getters on Object.prototype.
let injectedScriptSource = utils.read('src/inspector/injected-script-source.js');
@ -141,7 +141,12 @@ InspectorTest.ContextGroup = class {
}
scriptSource += `(function installSettersAndGetters() {
let defineProperty = Object.defineProperty;
let ObjectPrototype = Object.prototype;\n`;
let ObjectPrototype = Object.prototype;
let ArrayPrototype = Array.prototype;
defineProperty(ArrayPrototype, 0, {
set() { debugger; throw 42; }, get() { debugger; throw 42; },
__proto__: null
});`,
scriptSource += Array.from(getters).map(getter => `
defineProperty(ObjectPrototype, '${getter}', {
set() { debugger; throw 42; }, get() { debugger; throw 42; },
@ -150,13 +155,12 @@ InspectorTest.ContextGroup = class {
`).join('\n') + '})();';
this.addScript(scriptSource);
if (debug) {
if (session) {
InspectorTest.log('WARNING: setupInjectedScriptEnvironment with debug flag for debugging only and should not be landed.');
InspectorTest.log('WARNING: run test with --expose-inspector-scripts flag to get more details.');
InspectorTest.log('WARNING: you can additionally comment rjsmin in xxd.py to get unminified injected-script-source.js.');
var session = InspectorTest._sessions.next().value;
session.setupScriptMap();
sesison.Protocol.Debugger.enable();
session.Protocol.Debugger.enable();
session.Protocol.Debugger.onPaused(message => {
let callFrames = message.params.callFrames;
session.logSourceLocations(callFrames.map(frame => frame.location));