browser/devtools/markupview/test/browser_markupview_search_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_search_01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     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 that searching for nodes using the selector-search input expands and
    1.11 +// selects the right nodes in the markup-view, even when those nodes are deeply
    1.12 +// nested (and therefore not attached yet when the markup-view is initialized).
    1.13 +
    1.14 +const TEST_URL = TEST_URL_ROOT + "doc_markup_search.html";
    1.15 +
    1.16 +let test = asyncTest(function*() {
    1.17 +  let {inspector, toolbox} = yield addTab(TEST_URL).then(openInspector);
    1.18 +
    1.19 +  ok(!getContainerForRawNode("em", inspector),
    1.20 +    "The <em> tag isn't present yet in the markup-view");
    1.21 +
    1.22 +  // Searching for the innermost element first makes sure that the inspector
    1.23 +  // back-end is able to attach the resulting node to the tree it knows at the
    1.24 +  // moment. When the inspector is started, the <body> is the default selected
    1.25 +  // node, and only the parents up to the ROOT are known, and its direct children
    1.26 +  info("searching for the innermost child: <em>");
    1.27 +  let updated = inspector.once("inspector-updated");
    1.28 +  searchUsingSelectorSearch("em", inspector);
    1.29 +  yield updated;
    1.30 +
    1.31 +  ok(getContainerForRawNode("em", inspector),
    1.32 +    "The <em> tag is now imported in the markup-view");
    1.33 +  is(inspector.selection.node, getNode("em"),
    1.34 +    "The <em> tag is the currently selected node");
    1.35 +
    1.36 +  info("searching for other nodes too");
    1.37 +  for (let node of ["span", "li", "ul"]) {
    1.38 +    let updated = inspector.once("inspector-updated");
    1.39 +    searchUsingSelectorSearch(node, inspector);
    1.40 +    yield updated;
    1.41 +    is(inspector.selection.node, getNode(node),
    1.42 +      "The <" + node + "> tag is the currently selected node");
    1.43 +  }
    1.44 +});

mercurial