From a6d040a4cd831ac0321441fae85f69b9a3e4256b Mon Sep 17 00:00:00 2001 From: Oriol Date: Sun, 11 Sep 2016 17:57:00 -0400 Subject: [PATCH] Bug 1301999 - Stop hiding array indices of generic objects in console. r=fitzgen --- .../test/browser_webconsole_output_06.js | 8 +++--- devtools/server/actors/object.js | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/devtools/client/webconsole/test/browser_webconsole_output_06.js b/devtools/client/webconsole/test/browser_webconsole_output_06.js index 9bcfce9082d1..ad69b390861b 100644 --- a/devtools/client/webconsole/test/browser_webconsole_output_06.js +++ b/devtools/client/webconsole/test/browser_webconsole_output_06.js @@ -198,7 +198,7 @@ var inputTests = [ // 21 { input: '({0: "a", 1: "b", length: 1})', - output: 'Object { 1: "b", length: 1, 1 more\u2026 }', + output: 'Object { 0: "a", 1: "b", length: 1 }', printOutput: "[object Object]", inspectable: true, variablesViewLabel: "Object", @@ -225,7 +225,7 @@ var inputTests = [ // 24 { input: '({0: "a", 2: "b", length: 2})', - output: 'Object { 2: "b", length: 2, 1 more\u2026 }', + output: 'Object { 0: "a", 2: "b", length: 2 }', printOutput: "[object Object]", inspectable: true, variablesViewLabel: "Object", @@ -243,7 +243,7 @@ var inputTests = [ // 26 { input: '({0: "a", b: "b", length: 1})', - output: 'Object { b: "b", length: 1, 1 more\u2026 }', + output: 'Object { 0: "a", b: "b", length: 1 }', printOutput: "[object Object]", inspectable: true, variablesViewLabel: "Object", @@ -252,7 +252,7 @@ var inputTests = [ // 27 { input: '({0: "a", b: "b", length: 2})', - output: 'Object { b: "b", length: 2, 1 more\u2026 }', + output: 'Object { 0: "a", b: "b", length: 2 }', printOutput: "[object Object]", inspectable: true, variablesViewLabel: "Object", diff --git a/devtools/server/actors/object.js b/devtools/server/actors/object.js index 6816338c737e..1f417b951593 100644 --- a/devtools/server/actors/object.js +++ b/devtools/server/actors/object.js @@ -1090,7 +1090,7 @@ function enumWeakSetEntries(objectActor) { * having customized output. This object holds arrays mapped by * Debugger.Object.prototype.class. * - * In each array you can add functions that take two + * In each array you can add functions that take three * arguments: * - the ObjectActor instance and its hooks to make a preview for, * - the grip object being prepared for the client, @@ -1102,16 +1102,16 @@ function enumWeakSetEntries(objectActor) { * information for the debugger object, or true otherwise. */ DebuggerServer.ObjectActorPreviewers = { - String: [function (objectActor, grip) { - return wrappedPrimitivePreviewer("String", String, objectActor, grip); + String: [function (objectActor, grip, rawObj) { + return wrappedPrimitivePreviewer("String", String, objectActor, grip, rawObj); }], - Boolean: [function (objectActor, grip) { - return wrappedPrimitivePreviewer("Boolean", Boolean, objectActor, grip); + Boolean: [function (objectActor, grip, rawObj) { + return wrappedPrimitivePreviewer("Boolean", Boolean, objectActor, grip, rawObj); }], - Number: [function (objectActor, grip) { - return wrappedPrimitivePreviewer("Number", Number, objectActor, grip); + Number: [function (objectActor, grip, rawObj) { + return wrappedPrimitivePreviewer("Number", Number, objectActor, grip, rawObj); }], Function: [function ({obj, hooks}, grip) { @@ -1379,17 +1379,16 @@ DebuggerServer.ObjectActorPreviewers = { * The result grip to fill in * @return Booolean true if the object was handled, false otherwise */ -function wrappedPrimitivePreviewer(className, classObj, objectActor, grip) { +function wrappedPrimitivePreviewer(className, classObj, objectActor, grip, rawObj) { let {obj, hooks} = objectActor; if (!obj.proto || obj.proto.class != className) { return false; } - let raw = obj.unsafeDereference(); let v = null; try { - v = classObj.prototype.valueOf.call(raw); + v = classObj.prototype.valueOf.call(rawObj); } catch (ex) { // valueOf() can throw if the raw JS object is "misbehaved". return false; @@ -1399,7 +1398,7 @@ function wrappedPrimitivePreviewer(className, classObj, objectActor, grip) { return false; } - let canHandle = GenericObject(objectActor, grip, className === "String"); + let canHandle = GenericObject(objectActor, grip, rawObj, className === "String"); if (!canHandle) { return false; } @@ -1409,7 +1408,7 @@ function wrappedPrimitivePreviewer(className, classObj, objectActor, grip) { return true; } -function GenericObject(objectActor, grip, specialStringBehavior = false) { +function GenericObject(objectActor, grip, rawObj, specialStringBehavior = false) { let {obj, hooks} = objectActor; if (grip.preview || grip.displayString || hooks.getGripDepth() > 1) { return false; @@ -1859,7 +1858,9 @@ DebuggerServer.ObjectActorPreviewers.Object = [ return true; }, - GenericObject, + function Object(objectActor, grip, rawObj) { + return GenericObject(objectActor, grip, rawObj, /* specialStringBehavior = */ false); + }, ]; /**