Backed out changeset 4cba7ff88539 (bug 1301794) for timing out in devtools test browser_webconsole_output_05.js. r=backout

This commit is contained in:
Sebastian Hengst 2016-09-10 22:29:12 +02:00
parent eb51e3096c
commit 9c8a34a6a8
2 changed files with 32 additions and 52 deletions

View File

@ -131,10 +131,10 @@ var inputTests = [
// 14
{
input: '({0: "a", 42: "b"})',
output: '[ "a", <9 empty slots>, 33 more\u2026 ]',
output: 'Object { 0: "a", 42: "b" }',
printOutput: "[object Object]",
inspectable: true,
variablesViewLabel: "Object[43]",
variablesViewLabel: "Object",
},
// 15
@ -189,10 +189,10 @@ var inputTests = [
// 20
{
input: '({length: 1})',
output: '[ <1 empty slot> ]',
output: 'Object { length: 1 }',
printOutput: "[object Object]",
inspectable: true,
variablesViewLabel: "Object[1]",
variablesViewLabel: "Object",
},
// 21
@ -216,10 +216,10 @@ var inputTests = [
// 23
{
input: '({0: "a", 1: "b", length: 3})',
output: '[ "a", "b", <1 empty slot> ]',
output: 'Object { length: 3, 2 more\u2026 }',
printOutput: "[object Object]",
inspectable: true,
variablesViewLabel: "Object[3]",
variablesViewLabel: "Object",
},
// 24
@ -234,10 +234,10 @@ var inputTests = [
// 25
{
input: '({0: "a", 2: "b", length: 3})',
output: '[ "a", <1 empty slot>, "b" ]',
output: 'Object { length: 3, 2 more\u2026 }',
printOutput: "[object Object]",
inspectable: true,
variablesViewLabel: "Object[3]",
variablesViewLabel: "Object",
},
// 26
@ -257,15 +257,6 @@ var inputTests = [
inspectable: true,
variablesViewLabel: "Object",
},
// 28
{
input: '({42: "a"})',
output: 'Object { 42: "a" }',
printOutput: "[object Object]",
inspectable: true,
variablesViewLabel: "Object",
},
];
function test() {

View File

@ -1793,45 +1793,36 @@ DebuggerServer.ObjectActorPreviewers.Object = [
},
function PseudoArray({obj, hooks}, grip, rawObj) {
let length;
let length = 0;
let keys = obj.getOwnPropertyNames();
if (keys.length == 0) {
return false;
}
// If no item is going to be displayed in preview, better display as sparse object.
// The first key should contain the smallest integer index (if any).
if(keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) {
return false;
}
// Pseudo-arrays should only have array indices and, optionally, a "length" property.
// Since integer indices are sorted first, check if the last property is "length".
// Since array indices are sorted first, check if the last property is "length".
if(keys[keys.length-1] === "length") {
keys.pop();
length = DevToolsUtils.getProperty(obj, "length");
} else {
// Otherwise, let length be the (presumably) greatest array index plus 1.
length = +keys[keys.length-1] + 1;
}
// Check if length is a valid array length, i.e. is a Uint32 number.
if(typeof length !== "number" || length >>> 0 !== length) {
return false;
}
// Ensure all keys are increasing array indices smaller than length. The order is not
// guaranteed for exotic objects but, in most cases, big array indices and properties
// which are not integer indices should be at the end. Then, iterating backwards
// allows us to return earlier when the object is not completely a pseudo-array.
let prev = length;
for(let i = keys.length - 1; i >= 0; --i) {
let key = keys[i];
let numKey = key >>> 0; // ToUint32(key)
if (numKey + '' !== key || numKey >= prev) {
// The value of "length" should equal the number of other properties. If eventually
// we allow sparse pseudo-arrays, we should check whether it's a Uint32 instead.
if(rawObj.length !== keys.length) {
return false;
}
}
// Ensure that the keys are consecutive integers starting at "0". If eventually we
// allow sparse pseudo-arrays, we should check that they are array indices, that is:
// `(key >>> 0) + '' === key && key !== "4294967295"`.
// Checking the last property first allows us to avoid useless iterations when
// there is any property which is not an array index.
if(keys.length && keys[keys.length-1] !== keys.length - 1 + '') {
return false;
}
for (let key of keys) {
if (key !== (length++) + '') {
return false;
}
prev = numKey;
}
grip.preview = {
@ -1845,14 +1836,12 @@ DebuggerServer.ObjectActorPreviewers.Object = [
}
let items = grip.preview.items = [];
let numItems = Math.min(OBJECT_PREVIEW_MAX_ITEMS, length);
for (let i = 0; i < numItems; ++i) {
let desc = obj.getOwnPropertyDescriptor(i);
if (desc && 'value' in desc) {
items.push(hooks.createValueGrip(desc.value));
} else {
items.push(null);
let i = 0;
for (let key of keys) {
if (rawObj.hasOwnProperty(key) && i++ < OBJECT_PREVIEW_MAX_ITEMS) {
let value = makeDebuggeeValueIfNeeded(obj, rawObj[key]);
items.push(hooks.createValueGrip(value));
}
}