browser/devtools/markupview/test/browser_markupview_toggle_01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/markupview/test/browser_markupview_toggle_01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     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 clicking on twisties
    1.11 +
    1.12 +const TEST_URL = TEST_URL_ROOT + "doc_markup_toggle.html";
    1.13 +
    1.14 +let test = asyncTest(function*() {
    1.15 +  let {inspector} = yield addTab(TEST_URL).then(openInspector);
    1.16 +
    1.17 +  info("Getting the container for the UL parent element");
    1.18 +  let container = getContainerForRawNode("ul", inspector);
    1.19 +
    1.20 +  info("Clicking on the UL parent expander, and waiting for children");
    1.21 +  let onChildren = waitForChildrenUpdated(inspector);
    1.22 +  let onUpdated = inspector.once("inspector-updated");
    1.23 +  EventUtils.synthesizeMouseAtCenter(container.expander, {},
    1.24 +    inspector.markup.doc.defaultView);
    1.25 +  yield onChildren;
    1.26 +  yield onUpdated;
    1.27 +
    1.28 +  info("Checking that child LI elements have been created");
    1.29 +  for (let li of content.document.querySelectorAll("li")) {
    1.30 +    ok(getContainerForRawNode(li, inspector),
    1.31 +      "A container for the child LI element was created");
    1.32 +  }
    1.33 +  ok(container.expanded, "Parent UL container is expanded");
    1.34 +
    1.35 +  info("Clicking again on the UL expander");
    1.36 +  // No need to wait, this is a local, synchronous operation where nodes are
    1.37 +  // only hidden from the view, not destroyed
    1.38 +  EventUtils.synthesizeMouseAtCenter(container.expander, {},
    1.39 +    inspector.markup.doc.defaultView);
    1.40 +
    1.41 +  info("Checking that child LI elements have been hidden");
    1.42 +  for (let li of content.document.querySelectorAll("li")) {
    1.43 +    let liContainer = getContainerForRawNode(li, inspector);
    1.44 +    is(liContainer.elt.getClientRects().length, 0,
    1.45 +      "The container for the child LI element was hidden");
    1.46 +  }
    1.47 +  ok(!container.expanded, "Parent UL container is collapsed");
    1.48 +});

mercurial