4 https://bugzilla.mozilla.org/show_bug.cgi?id=835896
8 <title>Test for Bug
835896</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css">
11 <script type=
"application/javascript" src=
"inspector-helpers.js"></script>
12 <script type=
"application/javascript">
15 window.onload = function() {
16 SimpleTest.waitForExplicitFinish();
18 let walkerFront = null;
19 let inspectorCommand = null;
21 // WalkerFront and Inspector Command specific tests. These aren't to exercise search
22 // edge cases so much as to test the state the Front maintains between
25 addAsyncTest(async function setup() {
26 info(
"Setting up inspector and walker actors.");
28 const url = document.getElementById(
"inspectorContent").href;
30 const { commands } = await attachURL(url);
31 const target = commands.targetCommand.targetFront;
32 const inspector = await target.getFront(
"inspector");
34 walkerFront = inspector.walker;
35 inspectorCommand = commands.inspectorCommand;
40 addAsyncTest(async function testWalkerFrontDefaults() {
41 info(
"Testing search API using WalkerFront and Inspector Command.");
42 const nodes = await walkerFront.querySelectorAll(walkerFront.rootNode,
"h2");
43 const fronts = await nodes.items();
45 const commandResult = await inspectorCommand.findNextNode(
"");
46 ok(!commandResult,
"Null result on front when searching for ''");
48 let results = await inspectorCommand.findNextNode(
"h2");
53 },
"Default options work");
55 results = await inspectorCommand.findNextNode(
"h2", { });
60 },
"Search works with empty options");
62 // Clear search data to remove result state on the front
63 await inspectorCommand.findNextNode(
"");
67 addAsyncTest(async function testMultipleSearches() {
68 info(
"Testing search API using WalkerFront and Inspector Command (reverse=false)");
69 const nodes = await walkerFront.querySelectorAll(walkerFront.rootNode,
"h2");
70 const fronts = await nodes.items();
72 let results = await inspectorCommand.findNextNode(
"h2");
77 },
"Search works with multiple results (reverse=false)");
79 results = await inspectorCommand.findNextNode(
"h2");
84 },
"Search works with multiple results (reverse=false)");
86 results = await inspectorCommand.findNextNode(
"h2");
91 },
"Search works with multiple results (reverse=false)");
93 results = await inspectorCommand.findNextNode(
"h2");
98 },
"Search works with multiple results (reverse=false)");
100 // Clear search data to remove result state on the front
101 await inspectorCommand.findNextNode(
"");
105 addAsyncTest(async function testMultipleSearchesReverse() {
106 info(
"Testing search API using WalkerFront and Inspector Command (reverse=true)");
107 const nodes = await walkerFront.querySelectorAll(walkerFront.rootNode,
"h2");
108 const fronts = await nodes.items();
110 let results = await inspectorCommand.findNextNode(
"h2", {reverse: true});
115 },
"Search works with multiple results (reverse=true)");
117 results = await inspectorCommand.findNextNode(
"h2", {reverse: true});
122 },
"Search works with multiple results (reverse=true)");
124 results = await inspectorCommand.findNextNode(
"h2", {reverse: true});
129 },
"Search works with multiple results (reverse=true)");
131 results = await inspectorCommand.findNextNode(
"h2", {reverse: true});
136 },
"Search works with multiple results (reverse=true)");
138 results = await inspectorCommand.findNextNode(
"h2", {reverse: false});
143 },
"Search works with multiple results (reverse=false)");
145 // Clear search data to remove result state on the command
146 await inspectorCommand.findNextNode(
"");
155 <a id=
"inspectorContent" target=
"_blank" href=
"inspector-search-data.html">Test Document
</a>
157 <div id=
"content" style=
"display: none">