mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-06-11 11:08:31 +00:00
91 lines
2.4 KiB
HTML
91 lines
2.4 KiB
HTML
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
Test focusing 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"));
|
|
|
|
function renderTree(props) {
|
|
const treeProps = Object.assign({},
|
|
TEST_TREE_INTERFACE,
|
|
{ onFocus: x => renderTree({ focused: x }) },
|
|
props
|
|
);
|
|
return ReactDOM.render(Tree(treeProps), window.document.body);
|
|
}
|
|
|
|
const tree = renderTree();
|
|
|
|
TEST_TREE.expanded = new Set("ABCDEFGHIJKLMNO".split(""));
|
|
|
|
renderTree({ focused: "G" });
|
|
|
|
isRenderedTree(document.body.textContent, [
|
|
"A:false",
|
|
"-B:false",
|
|
"--E:false",
|
|
"---K:false",
|
|
"---L:false",
|
|
"--F:false",
|
|
"--G:true",
|
|
"-C:false",
|
|
"--H:false",
|
|
"--I:false",
|
|
"-D:false",
|
|
"--J:false",
|
|
"M:false",
|
|
"-N:false",
|
|
"--O:false",
|
|
], "G should be focused");
|
|
|
|
// Click the first tree node
|
|
Simulate.click(document.querySelector(".tree-node"));
|
|
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",
|
|
], "A should be focused");
|
|
} catch(e) {
|
|
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
|
|
} finally {
|
|
SimpleTest.finish();
|
|
}
|
|
});
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|