mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Backed out changeset b9c789ba01a0 (bug 1286186) for test_reps_array.html failures CLOSED TREE
This commit is contained in:
parent
2f6e5ed95c
commit
6b345a6cc2
@ -3,10 +3,8 @@ tags = devtools
|
||||
subsuite = devtools
|
||||
support-files =
|
||||
head.js
|
||||
page_array.html
|
||||
page_basic.html
|
||||
!/devtools/client/framework/test/shared-head.js
|
||||
|
||||
[browser_dom_array.js]
|
||||
[browser_dom_basic.js]
|
||||
[browser_dom_refresh.js]
|
||||
|
@ -1,40 +0,0 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* 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";
|
||||
|
||||
const TEST_PAGE_URL = URL_ROOT + "page_array.html";
|
||||
const TEST_ARRAY = [
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
||||
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
||||
];
|
||||
|
||||
/**
|
||||
* Basic test that checks content of the DOM panel.
|
||||
*/
|
||||
add_task(function* () {
|
||||
info("Test DOM Panel Array Expansion started");
|
||||
|
||||
let { panel } = yield addTestTab(TEST_PAGE_URL);
|
||||
|
||||
// Expand specified row and wait till children are displayed.
|
||||
yield expandRow(panel, "_a");
|
||||
|
||||
// Verify that children is displayed now.
|
||||
let childRows = getAllRowsForLabel(panel, "_a");
|
||||
|
||||
let item = childRows.pop();
|
||||
is(item.name, "length", "length property is correct");
|
||||
is(item.value, 26, "length property value is 26");
|
||||
|
||||
let i = 0;
|
||||
for (let name in childRows) {
|
||||
let row = childRows[name];
|
||||
|
||||
is(name, i++, `index ${name} is correct and sorted into the correct position`);
|
||||
ok(typeof row.name === "number", "array index is displayed as a number");
|
||||
is(TEST_ARRAY[name], row.value, `value for array[${name}] is ${row.value}`);
|
||||
}
|
||||
});
|
@ -97,74 +97,6 @@ function getRowByLabel(panel, text) {
|
||||
return label ? label.closest(".treeRow") : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the children (tree row text) of the specified object name as an
|
||||
* array.
|
||||
*/
|
||||
function getAllRowsForLabel(panel, text) {
|
||||
let rootObjectLevel;
|
||||
let node;
|
||||
let result = [];
|
||||
let doc = panel.panelWin.document;
|
||||
let nodes = [...doc.querySelectorAll(".treeLabel")];
|
||||
|
||||
// Find the label (object name) for which we want the children. We remove
|
||||
// nodes from the start of the array until we reach the property. The children
|
||||
// are then at the start of the array.
|
||||
while (true) {
|
||||
node = nodes.shift();
|
||||
|
||||
if (!node || node.textContent === text) {
|
||||
rootObjectLevel = node.getAttribute("data-level");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return an empty array if the node is not found.
|
||||
if (!node) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Now get the children.
|
||||
for (node of nodes) {
|
||||
let level = node.getAttribute("data-level");
|
||||
|
||||
if (level > rootObjectLevel) {
|
||||
result.push({
|
||||
name: normalizeTreeValue(node.textContent),
|
||||
value: normalizeTreeValue(node.parentNode.nextElementSibling.textContent)
|
||||
});
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strings in the tree are in the form ""a"" and numbers in the form "1". We
|
||||
* normalize these values by converting ""a"" to "a" and "1" to 1.
|
||||
*
|
||||
* @param {String} value
|
||||
* The value to normalize.
|
||||
* @return {String|Number}
|
||||
* The normalized value.
|
||||
*/
|
||||
function normalizeTreeValue(value) {
|
||||
if (value === `""`) {
|
||||
return "";
|
||||
}
|
||||
if (value.startsWith(`"`) && value.endsWith(`"`)) {
|
||||
return value.substr(1, value.length - 2);
|
||||
}
|
||||
if (isFinite(value) && parseInt(value, 10) == value) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands elements with given label and waits till
|
||||
* children are received from the backend.
|
||||
|
@ -1,19 +0,0 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>DOM Panel Array Expansion Test Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>DOM Panel Array Expansion Test Page</h2>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
window._a = [
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
||||
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
||||
];
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
// Extend from the shared list of defined globals for mochitests.
|
||||
"extends": "../../../../../.eslintrc.mochitests"
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||
|
||||
"use strict";
|
||||
|
||||
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
@ -14,9 +14,6 @@ Test ArrayRep rep
|
||||
<pre id="test">
|
||||
<script src="head.js" type="application/javascript;version=1.8"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
"use strict";
|
||||
/* import-globals-from head.js */
|
||||
|
||||
window.onload = Task.async(function* () {
|
||||
let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
|
||||
let { ArrayRep } = browserRequire("devtools/client/shared/components/reps/array");
|
||||
@ -38,9 +35,7 @@ window.onload = Task.async(function* () {
|
||||
|
||||
// Test that properties are rendered as expected by ItemRep
|
||||
yield testNested();
|
||||
|
||||
yield testArray();
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
@ -50,9 +45,7 @@ window.onload = Task.async(function* () {
|
||||
// Test that correct rep is chosen
|
||||
const stub = [];
|
||||
const renderedRep = shallowRenderComponent(Rep, { object: stub });
|
||||
is(renderedRep.type, ArrayRep.rep,
|
||||
`Rep correctly selects ${ArrayRep.rep.displayName}`);
|
||||
|
||||
is(renderedRep.type, ArrayRep.rep, `Rep correctly selects ${ArrayRep.rep.displayName}`);
|
||||
|
||||
// Test rendering
|
||||
const defaultOutput = `[]`;
|
||||
@ -217,39 +210,6 @@ window.onload = Task.async(function* () {
|
||||
|
||||
testRepRenderModes(modeTests, "testNested", componentUnderTest, stub);
|
||||
}
|
||||
|
||||
function testArray() {
|
||||
let stub = [
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
||||
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
||||
];
|
||||
|
||||
const defaultOutput = `["a", "b", "c", "d", "e", "f", "g", "h", "i", "j",` +
|
||||
` "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",` +
|
||||
` "u", "v", "w", "x", "y", "z"]`;
|
||||
const shortOutput = `["a", "b", "c", more...]`;
|
||||
|
||||
const modeTests = [
|
||||
{
|
||||
mode: undefined,
|
||||
expectedOutput: shortOutput,
|
||||
},
|
||||
{
|
||||
mode: "tiny",
|
||||
expectedOutput: `[26]`,
|
||||
},
|
||||
{
|
||||
mode: "short",
|
||||
expectedOutput: shortOutput,
|
||||
},
|
||||
{
|
||||
mode: "long",
|
||||
expectedOutput: defaultOutput,
|
||||
}
|
||||
];
|
||||
|
||||
testRepRenderModes(modeTests, "testNested", componentUnderTest, stub);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -42,10 +42,9 @@ define(function (require, exports, module) {
|
||||
key: "default",
|
||||
style: rowStyle},
|
||||
span({ className: "treeIcon" }),
|
||||
span({
|
||||
className: "treeLabel " + member.type + "Label",
|
||||
"data-level": level
|
||||
}, member.name)
|
||||
span({ className: "treeLabel " + member.type + "Label" },
|
||||
member.name
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user