mirror of
https://github.com/ManchildProductions/UXP-Fixed.git
synced 2026-06-10 16:29:28 +00:00
84 lines
2.3 KiB
HTML
84 lines
2.3 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"));
|
|
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(""));
|
|
yield setProps(tree, {
|
|
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>
|