michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test that searching for nodes using the selector-search input expands and michael@0: // selects the right nodes in the markup-view, even when those nodes are deeply michael@0: // nested (and therefore not attached yet when the markup-view is initialized). michael@0: michael@0: const TEST_URL = TEST_URL_ROOT + "doc_markup_search.html"; michael@0: michael@0: let test = asyncTest(function*() { michael@0: let {inspector, toolbox} = yield addTab(TEST_URL).then(openInspector); michael@0: michael@0: ok(!getContainerForRawNode("em", inspector), michael@0: "The tag isn't present yet in the markup-view"); michael@0: michael@0: // Searching for the innermost element first makes sure that the inspector michael@0: // back-end is able to attach the resulting node to the tree it knows at the michael@0: // moment. When the inspector is started, the is the default selected michael@0: // node, and only the parents up to the ROOT are known, and its direct children michael@0: info("searching for the innermost child: "); michael@0: let updated = inspector.once("inspector-updated"); michael@0: searchUsingSelectorSearch("em", inspector); michael@0: yield updated; michael@0: michael@0: ok(getContainerForRawNode("em", inspector), michael@0: "The tag is now imported in the markup-view"); michael@0: is(inspector.selection.node, getNode("em"), michael@0: "The tag is the currently selected node"); michael@0: michael@0: info("searching for other nodes too"); michael@0: for (let node of ["span", "li", "ul"]) { michael@0: let updated = inspector.once("inspector-updated"); michael@0: searchUsingSelectorSearch(node, inspector); michael@0: yield updated; michael@0: is(inspector.selection.node, getNode(node), michael@0: "The <" + node + "> tag is the currently selected node"); michael@0: } michael@0: });