test_Heap_02.html (2581B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Test that the currently selected view is rendered. 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 <div id="container"></div> 14 <pre id="test"> 15 <script src="head.js" type="application/javascript"></script> 16 <script type="application/javascript"> 17 "use strict"; 18 window.onload = async function() { 19 try { 20 ok(React, "Should get React"); 21 ok(Heap, "Should get Heap"); 22 23 const container = document.getElementById("container"); 24 25 // Dominator tree view. 26 27 await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, { 28 view: { state: viewState.DOMINATOR_TREE }, 29 })), container); 30 31 ok(container.querySelector(`[data-state=${dominatorTreeState.LOADED}]`), 32 "Should render the dominator tree."); 33 34 // Census view. 35 36 await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, { 37 view: { state: viewState.CENSUS }, 38 })), container); 39 40 ok(container.querySelector(`[data-state=${censusState.SAVED}]`), 41 "Should render the census."); 42 43 // Diffing view. 44 45 await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, { 46 view: { state: viewState.DIFFING }, 47 snapshot: null, 48 diffing: { 49 firstSnapshotId: null, 50 secondSnapshotId: null, 51 census: null, 52 error: null, 53 state: diffingState.SELECTING, 54 }, 55 })), container); 56 57 ok(container.querySelector(`[data-state=${diffingState.SELECTING}]`), 58 "Should render the diffing."); 59 60 // Initial view. 61 62 await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, { 63 snapshot: null, 64 diffing: null, 65 })), container); 66 67 ok(container.querySelector("[data-state=initial]"), 68 "With no snapshot, nor a diffing, should render initial prompt."); 69 } catch (e) { 70 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); 71 } finally { 72 SimpleTest.finish(); 73 } 74 }; 75 </script> 76 </pre> 77 </body> 78 </html>