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.

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

mercurial