Bug 977500: Add NodeList to the list of classes whose keys should not be sorted in VariablesView. r=past

--HG--
extra : rebase_source : 4801e884d8b5fb8b4aecd1733439c2d63ccdf456
This commit is contained in:
Sami Jaktholm 2014-05-28 23:27:00 +03:00
parent cf437cee16
commit 7a8b5ac404
3 changed files with 104 additions and 1 deletions

View File

@ -1039,7 +1039,8 @@ VariablesView.NON_SORTABLE_CLASSES = [
"Int32Array",
"Uint32Array",
"Float32Array",
"Float64Array"
"Float64Array",
"NodeList"
];
/**

View File

@ -143,6 +143,7 @@ support-files =
[browser_console_optimized_out_vars.js]
[browser_console_private_browsing.js]
[browser_console_variables_view.js]
[browser_console_variables_view_dont_sort_non_sortable_classes_properties.js]
[browser_console_variables_view_while_debugging.js]
[browser_console_variables_view_while_debugging_and_inspecting.js]
[browser_eval_in_debugger_stackframe.js]

View File

@ -0,0 +1,101 @@
/* -*- js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* Test case that ensures Array and other list types are not sorted in variables
* view.
*
* The tested types are:
* - Array
* - Int8Array
* - Int16Array
* - Int32Array
* - Uint8Array
* - Uint16Array
* - Uint32Array
* - Uint8ClampedArray
* - Float32Array
* - Float64Array
* - NodeList
*/
function test() {
const TEST_URI = "data:text/html;charset=utf-8, \
<html> \
<head> \
<title>Test document for bug 977500</title> \
</head> \
<body> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
<div></div> \
</body> \
</html>";
let jsterm;
function* runner() {
const typedArrayTypes = ["Int8Array", "Int16Array", "Int32Array",
"Uint8Array", "Uint16Array", "Uint32Array",
"Uint8ClampedArray", "Float32Array",
"Float64Array"];
const {tab} = yield loadTab(TEST_URI);
const hud = yield openConsole(tab);
jsterm = hud.jsterm;
// Create an ArrayBuffer of 80 bytes to test TypedArrays. 80 bytes is
// enough to get 10 items in all different TypedArrays.
jsterm.execute("let buf = ArrayBuffer(80);");
// Array
yield testNotSorted("Array(0,1,2,3,4,5,6,7,8,9,10)");
// NodeList
yield testNotSorted("document.querySelectorAll('div')");
// Typed arrays.
for (let type of typedArrayTypes) {
yield testNotSorted(type + "(buf)");
}
}
/**
* A helper that ensures the properties are not sorted when an object
* specified by aObject is inspected.
*
* @param string aObject
* A string that, once executed, creates and returns the object to
* inspect.
*/
function testNotSorted(aObject) {
info("Testing " + aObject);
let deferred = promise.defer();
jsterm.once("variablesview-fetched", (_, aVar) => deferred.resolve(aVar));
jsterm.execute("inspect(" + aObject + ")");
let variableScope = yield deferred.promise;
ok(variableScope, "Variables view opened");
// If the properties are sorted: keys = ["0", "1", "10",...] <- incorrect
// If the properties are not sorted: keys = ["0", "1", "2",...] <- correct
let keyIterator = variableScope._store.keys();
is(keyIterator.next().value, "0", "First key is 0");
is(keyIterator.next().value, "1", "Second key is 1");
// If the properties are sorted, the next one will be 10.
is(keyIterator.next().value, "2", "Third key is 2, not 10");
}
Task.spawn(runner).then(finishTest);
}