Files
firefox/devtools/client/shared/components/test/mochitest/test_tree_06.html
T
Nick Fitzgerald 07140c5952 Bug 1229229 - Display dominator trees in the memory tool's UI; r=jsantell
This patch overhauls the memory tool's frontend from being in a state of viewing
a snapshot's census (the implicit default) or viewing a census diff (a special
cased kind of thing) to one of three recognized view states: (1) census, (2)
diffing, or (3) dominator tree. The logic surrounding our current view is more
explicit now. View option (3) is the new one, whose introduction required those
clean ups.

Dominator trees are too large to render in full, all at once. Instead, we
eagerly load and render a few levels deep and then incrementally fetch further
subtrees as their parents are expanded in the UI. This means that we get new
Tree component instances across incremental fetches. Before this commit, the
Tree component stored a bunch of state internally (in this.state rather than
this.props) and we would lose focus and expansion state across incremental
fetches. This internal state has been pulled out and made as explicit props,
which are now managed by actions and reducers just like the rest of the state.
2016-01-13 12:27:30 -08:00

289 lines
7.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
Test keyboard navigation with the Tree component.
-->
<head>
<meta charset="utf-8">
<title>Tree component test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="head.js" type="application/javascript;version=1.8"></script>
<script type="application/javascript;version=1.8">
window.onload = Task.async(function* () {
try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
const React = browserRequire("devtools/client/shared/vendor/react");
const { Simulate } = React.addons.TestUtils;
const Tree = React.createFactory(browserRequire("devtools/client/shared/components/tree"));
const tree = ReactDOM.render(Tree(Object.assign({}, TEST_TREE_INTERFACE, {
onFocus: x => setProps(tree, { focused: x }),
})), window.document.body);
TEST_TREE.expanded = new Set("ABCDEFGHIJKLMNO".split(""));
// UP ----------------------------------------------------------------------
info("Up to the previous sibling.");
yield setProps(tree, {
focused: "L"
});
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowUp" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:false",
"---K:true",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the UP, K should be focused.");
info("Up to the parent.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowUp" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:true",
"---K:false",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the UP, E should be focused.");
info("Try and navigate up, past the first item.");
yield setProps(tree, {
focused: "A"
});
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowUp" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:true",
"-B:false",
"--E:false",
"---K:false",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the UP, A should be focused and we shouldn't have overflowed past it.");
// DOWN --------------------------------------------------------------------
yield setProps(tree, {
focused: "K"
});
info("Down to next sibling.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowDown" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:false",
"---K:false",
"---L:true",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the DOWN, L should be focused.");
info("Down to parent's next sibling.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowDown" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:false",
"---K:false",
"---L:false",
"--F:true",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the DOWN, F should be focused.");
info("Try and go down past the last item.");
yield setProps(tree, {
focused: "O"
});
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowDown" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:false",
"---K:false",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:true",
], "After the DOWN, O should still be focused and we shouldn't have overflowed past it.");
// LEFT --------------------------------------------------------------------
info("Left to go to parent.");
yield setProps(tree, {
focused: "L"
})
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowLeft" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:true",
"---K:false",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the LEFT, E should be focused.");
info("Left to collapse children.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowLeft" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:true",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the LEFT, E's children should be collapsed.");
// RIGHT -------------------------------------------------------------------
info("Right to expand children.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowRight" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:true",
"---K:false",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the RIGHT, E's children should be expanded again.");
info("Right to go to next item.");
Simulate.keyDown(document.querySelector(".tree"), { key: "ArrowRight" });
yield forceRender(tree);
isRenderedTree(document.body.textContent, [
"A:false",
"-B:false",
"--E:false",
"---K:true",
"---L:false",
"--F:false",
"--G:false",
"-C:false",
"--H:false",
"--I:false",
"-D:false",
"--J:false",
"M:false",
"-N:false",
"--O:false",
], "After the RIGHT, K should be focused.");
} catch(e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
}
});
</script>
</pre>
</body>
</html>