mirror of
https://github.com/classilla/tenfourfox.git
synced 2026-04-21 20:17:34 +00:00
48 lines
1.7 KiB
HTML
48 lines
1.7 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
Test that when an item in the Tree component is clicked, it steals focus from
|
|
other inputs.
|
|
-->
|
|
<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">
|
|
<link rel="stylesheet" href="chrome://devtools/skin/light-theme.css" type="text/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(TEST_TREE_INTERFACE), window.document.body);
|
|
|
|
const input = document.createElement("input");
|
|
document.body.appendChild(input);
|
|
|
|
input.focus();
|
|
is(document.activeElement, input, "The text input should be focused.");
|
|
|
|
Simulate.click(document.querySelector(".tree-node"));
|
|
// Let the tree re-render, because focus is dealt with on componentDidUpdate.
|
|
yield setState(tree, {});
|
|
|
|
isnot(document.activeElement, input,
|
|
"The input should have had it's focus stolen by clicking on a tree item.");
|
|
} catch(e) {
|
|
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
|
|
} finally {
|
|
SimpleTest.finish();
|
|
}
|
|
});
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|