browser_markup_toggle_03.js (1752B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test toggling (expand/collapse) elements by alt-clicking on twisties, which 7 // should expand/collapse all the descendants 8 9 const TEST_URL = URL_ROOT + "doc_markup_toggle.html"; 10 11 add_task(async function () { 12 const { inspector } = await openInspectorForURL(TEST_URL); 13 14 info("Getting the container for the UL parent element"); 15 const container = await getContainerForSelector("ul", inspector); 16 17 info("Alt-clicking on collapsed expander should expand all children"); 18 await toggleContainerByClick(inspector, container, { altKey: true }); 19 20 info("Checking that all nodes exist and are expanded"); 21 let nodeFronts = await getNodeFronts(inspector); 22 for (const nodeFront of nodeFronts) { 23 const nodeContainer = getContainerForNodeFront(nodeFront, inspector); 24 ok(nodeContainer, "Container for node " + nodeFront.tagName + " exists"); 25 ok( 26 nodeContainer.expanded, 27 "Container for node " + nodeFront.tagName + " is expanded" 28 ); 29 } 30 31 info("Alt-clicking on expanded expander should collapse all children"); 32 await toggleContainerByClick(inspector, container, { altKey: true }); 33 34 info("Checking that all nodes are collapsed"); 35 nodeFronts = await getNodeFronts(inspector); 36 for (const nodeFront of nodeFronts) { 37 const nodeContainer = getContainerForNodeFront(nodeFront, inspector); 38 ok( 39 !nodeContainer.expanded, 40 "Container for node " + nodeFront.tagName + " is collapsed" 41 ); 42 } 43 }); 44 45 async function getNodeFronts(inspector) { 46 const nodeList = await inspector.walker.querySelectorAll( 47 inspector.walker.rootNode, 48 "ul, li, span, em" 49 ); 50 return nodeList.items(); 51 }