1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/markupview/test/browser_markupview_toggle_03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Test toggling (expand/collapse) elements by alt-clicking on twisties, which 1.11 +// should expand all the descendants 1.12 + 1.13 +const TEST_URL = TEST_URL_ROOT + "doc_markup_toggle.html"; 1.14 + 1.15 +let test = asyncTest(function*() { 1.16 + let {inspector} = yield addTab(TEST_URL).then(openInspector); 1.17 + 1.18 + info("Getting the container for the UL parent element"); 1.19 + let container = getContainerForRawNode("ul", inspector); 1.20 + 1.21 + info("Alt-clicking on the UL parent expander, and waiting for children"); 1.22 + let onUpdated = inspector.once("inspector-updated"); 1.23 + EventUtils.synthesizeMouseAtCenter(container.expander, {altKey: true}, 1.24 + inspector.markup.doc.defaultView); 1.25 + yield onUpdated; 1.26 + yield waitForMultipleChildrenUpdates(inspector); 1.27 + 1.28 + info("Checking that all nodes exist and are expanded"); 1.29 + for (let node of content.document.querySelectorAll("ul, li, span, em")) { 1.30 + let nodeContainer = getContainerForRawNode(node, inspector); 1.31 + ok(nodeContainer, "Container for node " + node.tagName + " exists"); 1.32 + ok(nodeContainer.expanded, 1.33 + "Container for node " + node.tagName + " is expanded"); 1.34 + } 1.35 +}); 1.36 + 1.37 +// The expand all operation of the markup-view calls itself recursively and 1.38 +// there's not one event we can wait for to know when it's done 1.39 +function* waitForMultipleChildrenUpdates(inspector) { 1.40 + // As long as child updates are queued up while we wait for an update already 1.41 + // wait again 1.42 + if (inspector.markup._queuedChildUpdates && 1.43 + inspector.markup._queuedChildUpdates.size) { 1.44 + yield waitForChildrenUpdated(inspector); 1.45 + return yield waitForMultipleChildrenUpdates(inspector); 1.46 + } 1.47 +} 1.48 \ No newline at end of file