Commit 0bdc7bba authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[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/636469Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47623}
parent 8aed7767
...@@ -856,6 +856,7 @@ InjectedScript.RemoteObject.prototype = { ...@@ -856,6 +856,7 @@ InjectedScript.RemoteObject.prototype = {
properties: [], properties: [],
__proto__: null __proto__: null
}; };
InjectedScriptHost.nullifyPrototype(preview.properties);
if (this.subtype) if (this.subtype)
preview.subtype = /** @type {!RuntimeAgent.ObjectPreviewSubtype.<string>} */ (this.subtype); preview.subtype = /** @type {!RuntimeAgent.ObjectPreviewSubtype.<string>} */ (this.subtype);
return preview; return preview;
...@@ -1041,6 +1042,7 @@ InjectedScript.RemoteObject.prototype = { ...@@ -1041,6 +1042,7 @@ InjectedScript.RemoteObject.prototype = {
return; return;
} }
preview.entries = []; preview.entries = [];
InjectedScriptHost.nullifyPrototype(preview.entries);
var entriesThreshold = 5; var entriesThreshold = 5;
for (var i = 0; i < entries.length; ++i) { for (var i = 0; i < entries.length; ++i) {
if (preview.entries.length >= entriesThreshold) { if (preview.entries.length >= entriesThreshold) {
......
...@@ -235,4 +235,14 @@ expression: ({}) ...@@ -235,4 +235,14 @@ expression: ({})
Running test: overridenArrayGetter Running test: overridenArrayGetter
expression: Promise.resolve(42) expression: Promise.resolve(42)
{
name : [[PromiseStatus]]
type : string
value : resolved
}
{
name : [[PromiseValue]]
type : number
value : 42
}
...@@ -8,6 +8,8 @@ Protocol.Debugger.enable(); ...@@ -8,6 +8,8 @@ Protocol.Debugger.enable();
Protocol.Runtime.enable(); Protocol.Runtime.enable();
Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries); Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries);
contextGroup.setupInjectedScriptEnvironment();
InspectorTest.runTestSuite([ InspectorTest.runTestSuite([
function boxedObjects(next) function boxedObjects(next)
{ {
......
...@@ -129,7 +129,7 @@ InspectorTest.ContextGroup = class { ...@@ -129,7 +129,7 @@ InspectorTest.ContextGroup = class {
return new InspectorTest.Session(this); return new InspectorTest.Session(this);
} }
setupInjectedScriptEnvironment(debug) { setupInjectedScriptEnvironment(session) {
let scriptSource = ''; let scriptSource = '';
// First define all getters on Object.prototype. // First define all getters on Object.prototype.
let injectedScriptSource = utils.read('src/inspector/injected-script-source.js'); let injectedScriptSource = utils.read('src/inspector/injected-script-source.js');
...@@ -141,8 +141,13 @@ InspectorTest.ContextGroup = class { ...@@ -141,8 +141,13 @@ InspectorTest.ContextGroup = class {
} }
scriptSource += `(function installSettersAndGetters() { scriptSource += `(function installSettersAndGetters() {
let defineProperty = Object.defineProperty; let defineProperty = Object.defineProperty;
let ObjectPrototype = Object.prototype;\n`; let ObjectPrototype = Object.prototype;
scriptSource += Array.from(getters).map(getter => ` 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}', { defineProperty(ObjectPrototype, '${getter}', {
set() { debugger; throw 42; }, get() { debugger; throw 42; }, set() { debugger; throw 42; }, get() { debugger; throw 42; },
__proto__: null __proto__: null
...@@ -150,13 +155,12 @@ InspectorTest.ContextGroup = class { ...@@ -150,13 +155,12 @@ InspectorTest.ContextGroup = class {
`).join('\n') + '})();'; `).join('\n') + '})();';
this.addScript(scriptSource); 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: 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: 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.'); 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(); session.setupScriptMap();
sesison.Protocol.Debugger.enable(); session.Protocol.Debugger.enable();
session.Protocol.Debugger.onPaused(message => { session.Protocol.Debugger.onPaused(message => {
let callFrames = message.params.callFrames; let callFrames = message.params.callFrames;
session.logSourceLocations(callFrames.map(frame => frame.location)); session.logSourceLocations(callFrames.map(frame => frame.location));
......
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