test_tree_01.html (1989B)
1 <!-- This Source Code Form is subject to the terms of the Mozilla Public 2 - License, v. 2.0. If a copy of the MPL was not distributed with this 3 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 4 <!DOCTYPE HTML> 5 <html> 6 <!-- 7 Test trees get displayed with the items in correct order and at the correct 8 depth. 9 --> 10 <head> 11 <meta charset="utf-8"> 12 <title>Tree component test</title> 13 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 14 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 15 </head> 16 <body> 17 <pre id="test"> 18 <script src="head.js" type="application/javascript"></script> 19 <script type="application/javascript"> 20 21 'use strict' 22 23 window.onload = async function () { 24 try { 25 const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); 26 const React = browserRequire("devtools/client/shared/vendor/react"); 27 const Tree = React.createFactory(browserRequire("devtools/client/shared/components/VirtualizedTree")); 28 29 ok(React, "Should get React"); 30 ok(Tree, "Should get Tree"); 31 32 const t = Tree(TEST_TREE_INTERFACE); 33 ok(t, "Should be able to create Tree instances"); 34 35 const tree = ReactDOM.render(t, window.document.body); 36 ok(tree, "Should be able to mount Tree instances"); 37 isAccessibleTree(tree); 38 39 TEST_TREE.expanded = new Set("ABCDEFGHIJKLMNO".split("")); 40 await forceRender(tree); 41 42 isRenderedTree(document.body.textContent, [ 43 "A:false", 44 "-B:false", 45 "--E:false", 46 "---K:false", 47 "---L:false", 48 "--F:false", 49 "--G:false", 50 "-C:false", 51 "--H:false", 52 "--I:false", 53 "-D:false", 54 "--J:false", 55 "M:false", 56 "-N:false", 57 "--O:false", 58 ], "Should get the items rendered and indented as expected"); 59 } catch(e) { 60 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); 61 } finally { 62 SimpleTest.finish(); 63 } 64 }; 65 </script> 66 </pre> 67 </body> 68 </html>