browser_markup_toggle_01.js (2282B)
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 clicking on twisties 7 8 const TEST_URL = URL_ROOT + "doc_markup_toggle.html"; 9 10 add_task(async function () { 11 const { inspector } = await openInspectorForURL(TEST_URL); 12 13 info("Getting the container for the html element"); 14 let container = await getContainerForSelector("html", inspector); 15 ok(container.mustExpand, "HTML element mustExpand"); 16 ok(container.canExpand, "HTML element canExpand"); 17 is(container.expander.style.visibility, "hidden", "HTML twisty is hidden"); 18 19 info("Getting the container for the UL parent element"); 20 container = await getContainerForSelector("ul", inspector); 21 ok(!container.mustExpand, "UL element !mustExpand"); 22 ok(container.canExpand, "UL element canExpand"); 23 is(container.expander.style.visibility, "visible", "HTML twisty is visible"); 24 ok(!container.selected, "UL container is not selected"); 25 26 info("Clicking on the UL parent expander, and waiting for children"); 27 await toggleContainerByClick(inspector, container); 28 ok(!container.selected, "UL container is still not selected after expand"); 29 30 info("Checking that child LI elements have been created"); 31 let numLi = await getNumberOfMatchingElementsInContentPage("li"); 32 for (let i = 0; i < numLi; i++) { 33 const liContainer = await getContainerForSelector( 34 `li:nth-child(${i + 1})`, 35 inspector 36 ); 37 ok(liContainer, "A container for the child LI element was created"); 38 } 39 ok(container.expanded, "Parent UL container is expanded"); 40 41 info("Clicking again on the UL expander"); 42 await toggleContainerByClick(inspector, container); 43 ok(!container.selected, "UL container is still not selected after collapse"); 44 45 info("Checking that child LI elements have been hidden"); 46 numLi = await getNumberOfMatchingElementsInContentPage("li"); 47 for (let i = 0; i < numLi; i++) { 48 const liContainer = await getContainerForSelector( 49 `li:nth-child(${i + 1})`, 50 inspector 51 ); 52 is( 53 liContainer.elt.getClientRects().length, 54 0, 55 "The container for the child LI element was hidden" 56 ); 57 } 58 ok(!container.expanded, "Parent UL container is collapsed"); 59 });