browser/devtools/markupview/test/browser_markupview_toggle_03.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Test toggling (expand/collapse) elements by alt-clicking on twisties, which
michael@0 8 // should expand all the descendants
michael@0 9
michael@0 10 const TEST_URL = TEST_URL_ROOT + "doc_markup_toggle.html";
michael@0 11
michael@0 12 let test = asyncTest(function*() {
michael@0 13 let {inspector} = yield addTab(TEST_URL).then(openInspector);
michael@0 14
michael@0 15 info("Getting the container for the UL parent element");
michael@0 16 let container = getContainerForRawNode("ul", inspector);
michael@0 17
michael@0 18 info("Alt-clicking on the UL parent expander, and waiting for children");
michael@0 19 let onUpdated = inspector.once("inspector-updated");
michael@0 20 EventUtils.synthesizeMouseAtCenter(container.expander, {altKey: true},
michael@0 21 inspector.markup.doc.defaultView);
michael@0 22 yield onUpdated;
michael@0 23 yield waitForMultipleChildrenUpdates(inspector);
michael@0 24
michael@0 25 info("Checking that all nodes exist and are expanded");
michael@0 26 for (let node of content.document.querySelectorAll("ul, li, span, em")) {
michael@0 27 let nodeContainer = getContainerForRawNode(node, inspector);
michael@0 28 ok(nodeContainer, "Container for node " + node.tagName + " exists");
michael@0 29 ok(nodeContainer.expanded,
michael@0 30 "Container for node " + node.tagName + " is expanded");
michael@0 31 }
michael@0 32 });
michael@0 33
michael@0 34 // The expand all operation of the markup-view calls itself recursively and
michael@0 35 // there's not one event we can wait for to know when it's done
michael@0 36 function* waitForMultipleChildrenUpdates(inspector) {
michael@0 37 // As long as child updates are queued up while we wait for an update already
michael@0 38 // wait again
michael@0 39 if (inspector.markup._queuedChildUpdates &&
michael@0 40 inspector.markup._queuedChildUpdates.size) {
michael@0 41 yield waitForChildrenUpdated(inspector);
michael@0 42 return yield waitForMultipleChildrenUpdates(inspector);
michael@0 43 }
michael@0 44 }

mercurial