diff --git a/devtools/client/shared/components/reps/array.js b/devtools/client/shared/components/reps/array.js index 8221fc216f9c..76fab50705bd 100644 --- a/devtools/client/shared/components/reps/array.js +++ b/devtools/client/shared/components/reps/array.js @@ -32,7 +32,7 @@ define(function (require, exports, module) { let items = []; let delim; - for (let i = 0; i < array.length && i < max; i++) { + for (let i = 0; i < array.length && i <= max; i++) { try { let value = array[i]; @@ -61,12 +61,14 @@ define(function (require, exports, module) { } if (array.length > max) { + items.pop(); + let objectLink = this.props.objectLink || DOM.span; items.push(Caption({ key: "more", object: objectLink({ object: this.props.object - }, (array.length - max) + " more…") + }, "more…") })); } diff --git a/devtools/client/shared/components/reps/grip-array.js b/devtools/client/shared/components/reps/grip-array.js index c9090a5c3670..4aa0aa9440dd 100644 --- a/devtools/client/shared/components/reps/grip-array.js +++ b/devtools/client/shared/components/reps/grip-array.js @@ -59,7 +59,7 @@ define(function (require, exports, module) { let delim; let provider = this.props.provider; - for (let i = 0; i < array.length && i < max; i++) { + for (let i = 0; i < array.length && i <= max; i++) { try { let itemGrip = array[i]; let value = provider ? provider.getValue(itemGrip) : itemGrip; @@ -89,12 +89,13 @@ define(function (require, exports, module) { } if (array.length > max) { + items.pop(); let objectLink = this.props.objectLink || span; items.push(Caption({ key: "more", object: objectLink({ object: this.props.object - }, (grip.preview.length - max) + " more…") + }, "more…") })); } diff --git a/devtools/client/shared/components/reps/grip.js b/devtools/client/shared/components/reps/grip.js index 7212d7ea0222..7dd19b8ff777 100644 --- a/devtools/client/shared/components/reps/grip.js +++ b/devtools/client/shared/components/reps/grip.js @@ -79,7 +79,7 @@ define(function (require, exports, module) { key: "more", object: objectLink({ object: object - }, ((object ? object.ownPropertyLength : 0) - max) + " more…") + }, "more…") })); } else if (props.length > 0) { // Remove the last comma. diff --git a/devtools/client/shared/components/reps/object.js b/devtools/client/shared/components/reps/object.js index b71176c8ced7..92965aa57890 100644 --- a/devtools/client/shared/components/reps/object.js +++ b/devtools/client/shared/components/reps/object.js @@ -78,7 +78,7 @@ define(function (require, exports, module) { key: "more", object: objectLink({ object: object - }, (Object.keys(object).length - max) + " more…") + }, "more…") })); } else if (props.length > 0) { // Remove the last comma. diff --git a/devtools/client/shared/components/test/mochitest/test_reps_array.html b/devtools/client/shared/components/test/mochitest/test_reps_array.html index a05306a065e3..23f83bea78d0 100644 --- a/devtools/client/shared/components/test/mochitest/test_reps_array.html +++ b/devtools/client/shared/components/test/mochitest/test_reps_array.html @@ -107,7 +107,7 @@ window.onload = Task.async(function* () { function testMoreThanShortMaxProps() { const stub = Array(maxLength.short + 1).fill("foo"); - const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, 1 more…]`; + const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, more…]`; const modeTests = [ { @@ -133,8 +133,8 @@ window.onload = Task.async(function* () { function testMoreThanLongMaxProps() { const stub = Array(maxLength.long + 1).fill("foo"); - const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, ${maxLength.long + 1 - maxLength.short} more…]`; - const defaultLongOutput = `[${Array(maxLength.long).fill("\"foo\"").join(", ")}, 1 more…]`; + const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, more…]`; + const defaultLongOutput = `[${Array(maxLength.long).fill("\"foo\"").join(", ")}, more…]`; const modeTests = [ { @@ -194,7 +194,7 @@ window.onload = Task.async(function* () { p4: "s4" } ]; - const defaultOutput = `[Object{p1: "s1", p3: "s3", p4: "s4", 1 more…}]`; + const defaultOutput = `[Object{p1: "s1", p3: "s3", p4: "s4", more…}]`; const modeTests = [ { diff --git a/devtools/client/shared/components/test/mochitest/test_reps_grip-array.html b/devtools/client/shared/components/test/mochitest/test_reps_grip-array.html index 41b7a3c60e37..ccb5ea1c752e 100644 --- a/devtools/client/shared/components/test/mochitest/test_reps_grip-array.html +++ b/devtools/client/shared/components/test/mochitest/test_reps_grip-array.html @@ -106,7 +106,7 @@ window.onload = Task.async(function* () { // Test array = `["test string"…] //4 items` const testName = "testMoreThanShortMaxProps"; - const defaultOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, 1 more…]`; + const defaultOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, more…]`; const modeTests = [ { @@ -134,8 +134,8 @@ window.onload = Task.async(function* () { // Test array = `["test string"…] //301 items` const testName = "testMoreThanLongMaxProps"; - const defaultShortOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, ${maxLength.long + 1 - maxLength.short} more…]`; - const defaultLongOutput = `Array[${Array(maxLength.long).fill("\"test string\"").join(", ")}, 1 more…]`; + const defaultShortOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, more…]`; + const defaultLongOutput = `Array[${Array(maxLength.long).fill("\"test string\"").join(", ")}, more…]`; const modeTests = [ { diff --git a/devtools/client/shared/components/test/mochitest/test_reps_grip.html b/devtools/client/shared/components/test/mochitest/test_reps_grip.html index 926781b4629f..958ee3e56306 100644 --- a/devtools/client/shared/components/test/mochitest/test_reps_grip.html +++ b/devtools/client/shared/components/test/mochitest/test_reps_grip.html @@ -100,10 +100,10 @@ window.onload = Task.async(function* () { } function testMoreThanMaxProps() { - // Test object = `{p0: "0", p1: "1", p2: "2", …, p100: "100"}` + // Test object = `{p0: "0", p1: "1", p2: "2", …, p101: "101"}` const testName = "testMoreThanMaxProps"; - const defaultOutput = `Object {p0: "0", p1: "1", p2: "2", 98 more…}`; + const defaultOutput = `Object {p0: "0", p1: "1", p2: "2", more…}`; // Generate string with 100 properties, which is the max limit // for 'long' mode. @@ -112,7 +112,7 @@ window.onload = Task.async(function* () { props += "p" + i + ": \"" + i + "\", "; } - const longOutput = `Object {${props}1 more…}`; + const longOutput = `Object {${props}more…}`; const modeTests = [ { @@ -140,7 +140,7 @@ window.onload = Task.async(function* () { // Test object: `{a: undefined, b: undefined, c: "c", d: 1}` // @TODO This is not how we actually want the preview to be output. // See https://bugzilla.mozilla.org/show_bug.cgi?id=1276376 - const expectedOutput = `Object {a: undefined, b: undefined, c: "c", 1 more…}`; + const expectedOutput = `Object {a: undefined, b: undefined, c: "c", more…}`; } function testNestedObject() { diff --git a/devtools/client/shared/components/test/mochitest/test_reps_object.html b/devtools/client/shared/components/test/mochitest/test_reps_object.html index 4ee35a531af6..47708cc8f506 100644 --- a/devtools/client/shared/components/test/mochitest/test_reps_object.html +++ b/devtools/client/shared/components/test/mochitest/test_reps_object.html @@ -101,7 +101,7 @@ window.onload = Task.async(function* () { for (let i = 0; i<100; i++) { stub[`p${i}`] = i } - const defaultOutput = `Object{p0: 0, p1: 1, p2: 2, 97 more…}`; + const defaultOutput = `Object{p0: 0, p1: 1, p2: 2, more…}`; const modeTests = [ { @@ -127,7 +127,7 @@ window.onload = Task.async(function* () { function testUninterestingProps() { const stub = {a:undefined, b:undefined, c:"c", d:0}; - const defaultOutput = `Object{c: "c", d: 0, a: undefined, 1 more…}`; + const defaultOutput = `Object{c: "c", d: 0, a: undefined, more…}`; const modeTests = [ {