|
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 toggling (expand/collapse) elements by dbl-clicking on tag lines |
|
8 |
|
9 const TEST_URL = TEST_URL_ROOT + "doc_markup_toggle.html"; |
|
10 |
|
11 let test = asyncTest(function*() { |
|
12 let {inspector} = yield addTab(TEST_URL).then(openInspector); |
|
13 |
|
14 info("Getting the container for the UL parent element"); |
|
15 let container = getContainerForRawNode("ul", inspector); |
|
16 |
|
17 info("Dbl-clicking on the UL parent expander, and waiting for children"); |
|
18 let onChildren = waitForChildrenUpdated(inspector); |
|
19 let onUpdated = inspector.once("inspector-updated"); |
|
20 EventUtils.synthesizeMouseAtCenter(container.tagLine, {clickCount: 2}, |
|
21 inspector.markup.doc.defaultView); |
|
22 yield onChildren; |
|
23 yield onUpdated; |
|
24 |
|
25 info("Checking that child LI elements have been created"); |
|
26 for (let li of content.document.querySelectorAll("li")) { |
|
27 ok(getContainerForRawNode(li, inspector), |
|
28 "A container for the child LI element was created"); |
|
29 } |
|
30 ok(container.expanded, "Parent UL container is expanded"); |
|
31 |
|
32 info("Dbl-clicking again on the UL expander"); |
|
33 // No need to wait, this is a local, synchronous operation where nodes are |
|
34 // only hidden from the view, not destroyed |
|
35 EventUtils.synthesizeMouseAtCenter(container.tagLine, {clickCount: 2}, |
|
36 inspector.markup.doc.defaultView); |
|
37 |
|
38 info("Checking that child LI elements have been hidden"); |
|
39 for (let li of content.document.querySelectorAll("li")) { |
|
40 let liContainer = getContainerForRawNode(li, inspector); |
|
41 is(liContainer.elt.getClientRects().length, 0, |
|
42 "The container for the child LI element was hidden"); |
|
43 } |
|
44 ok(!container.expanded, "Parent UL container is collapsed"); |
|
45 }); |