test_DominatorTree_03.html (2753B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Test that expanded DominatorTreeItems are correctly rendered and updated 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Tree component test</title> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 11 </head> 12 <body> 13 <!-- Give the container height so that the whole tree is rendered. --> 14 <div id="container" style="height: 900px;"></div> 15 16 <pre id="test"> 17 <script src="head.js" type="application/javascript"></script> 18 <script type="application/javascript"> 19 "use strict"; 20 window.onload = async function() { 21 try { 22 const container = document.getElementById("container"); 23 24 // simple tree with one root and one child 25 const root = makeTestDominatorTreeNode( 26 { moreChildrenAvailable: false }, 27 [ 28 makeTestDominatorTreeNode({ moreChildrenAvailable: false }), 29 ]); 30 ok(root.children); 31 32 // root node is expanded 33 const expanded = new Set(); 34 expanded.add(root.nodeId); 35 36 await renderComponent( 37 DominatorTreeComponent(immutableUpdate( 38 TEST_DOMINATOR_TREE_PROPS, 39 { 40 dominatorTree: immutableUpdate( 41 TEST_DOMINATOR_TREE_PROPS.dominatorTree, 42 { expanded, root } 43 ), 44 })), container); 45 ok(true, "Dominator tree rendered"); 46 47 is(container.querySelectorAll(".tree-node").length, 2, 48 "Should display two rows"); 49 is(container.querySelectorAll(".arrow.open").length, 1, 50 "Should display one expanded arrow"); 51 52 await renderComponent( 53 DominatorTreeComponent(immutableUpdate( 54 TEST_DOMINATOR_TREE_PROPS, 55 { 56 dominatorTree: immutableUpdate( 57 TEST_DOMINATOR_TREE_PROPS.dominatorTree, 58 { expanded: new Set(), root } 59 ), 60 })), container); 61 62 ok(true, "Dominator tree props updated to collapse all nodes"); 63 64 is(container.querySelectorAll(".tree-node").length, 1, 65 "Should display only one row"); 66 is(container.querySelectorAll(".arrow.open").length, 0, 67 "Should display no expanded arrow"); 68 } catch (e) { 69 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); 70 } finally { 71 SimpleTest.finish(); 72 } 73 }; 74 </script> 75 </pre> 76 </body> 77 </html>