michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test toggling (expand/collapse) elements by alt-clicking on twisties, which michael@0: // should expand all the descendants michael@0: michael@0: const TEST_URL = TEST_URL_ROOT + "doc_markup_toggle.html"; michael@0: michael@0: let test = asyncTest(function*() { michael@0: let {inspector} = yield addTab(TEST_URL).then(openInspector); michael@0: michael@0: info("Getting the container for the UL parent element"); michael@0: let container = getContainerForRawNode("ul", inspector); michael@0: michael@0: info("Alt-clicking on the UL parent expander, and waiting for children"); michael@0: let onUpdated = inspector.once("inspector-updated"); michael@0: EventUtils.synthesizeMouseAtCenter(container.expander, {altKey: true}, michael@0: inspector.markup.doc.defaultView); michael@0: yield onUpdated; michael@0: yield waitForMultipleChildrenUpdates(inspector); michael@0: michael@0: info("Checking that all nodes exist and are expanded"); michael@0: for (let node of content.document.querySelectorAll("ul, li, span, em")) { michael@0: let nodeContainer = getContainerForRawNode(node, inspector); michael@0: ok(nodeContainer, "Container for node " + node.tagName + " exists"); michael@0: ok(nodeContainer.expanded, michael@0: "Container for node " + node.tagName + " is expanded"); michael@0: } michael@0: }); michael@0: michael@0: // The expand all operation of the markup-view calls itself recursively and michael@0: // there's not one event we can wait for to know when it's done michael@0: function* waitForMultipleChildrenUpdates(inspector) { michael@0: // As long as child updates are queued up while we wait for an update already michael@0: // wait again michael@0: if (inspector.markup._queuedChildUpdates && michael@0: inspector.markup._queuedChildUpdates.size) { michael@0: yield waitForChildrenUpdated(inspector); michael@0: return yield waitForMultipleChildrenUpdates(inspector); michael@0: } michael@0: }