|
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/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Test that searching for nodes using the selector-search input expands and |
|
8 // selects the right nodes in the markup-view, even when those nodes are deeply |
|
9 // nested (and therefore not attached yet when the markup-view is initialized). |
|
10 |
|
11 const TEST_URL = TEST_URL_ROOT + "doc_markup_search.html"; |
|
12 |
|
13 let test = asyncTest(function*() { |
|
14 let {inspector, toolbox} = yield addTab(TEST_URL).then(openInspector); |
|
15 |
|
16 ok(!getContainerForRawNode("em", inspector), |
|
17 "The <em> tag isn't present yet in the markup-view"); |
|
18 |
|
19 // Searching for the innermost element first makes sure that the inspector |
|
20 // back-end is able to attach the resulting node to the tree it knows at the |
|
21 // moment. When the inspector is started, the <body> is the default selected |
|
22 // node, and only the parents up to the ROOT are known, and its direct children |
|
23 info("searching for the innermost child: <em>"); |
|
24 let updated = inspector.once("inspector-updated"); |
|
25 searchUsingSelectorSearch("em", inspector); |
|
26 yield updated; |
|
27 |
|
28 ok(getContainerForRawNode("em", inspector), |
|
29 "The <em> tag is now imported in the markup-view"); |
|
30 is(inspector.selection.node, getNode("em"), |
|
31 "The <em> tag is the currently selected node"); |
|
32 |
|
33 info("searching for other nodes too"); |
|
34 for (let node of ["span", "li", "ul"]) { |
|
35 let updated = inspector.once("inspector-updated"); |
|
36 searchUsingSelectorSearch(node, inspector); |
|
37 yield updated; |
|
38 is(inspector.selection.node, getNode(node), |
|
39 "The <" + node + "> tag is the currently selected node"); |
|
40 } |
|
41 }); |