|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // A for-of loop in Web Console code can loop over a content NodeList. |
|
5 |
|
6 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-for-of.html"; |
|
7 |
|
8 function test() { |
|
9 addTab(TEST_URI); |
|
10 browser.addEventListener("load", function onLoad() { |
|
11 browser.removeEventListener("load", onLoad, true); |
|
12 openConsole(null, testForOf); |
|
13 }, true); |
|
14 } |
|
15 |
|
16 function testForOf(hud) { |
|
17 var jsterm = hud.jsterm; |
|
18 jsterm.execute("{ [x.tagName for (x of document.body.childNodes) if (x.nodeType === 1)].join(' '); }", |
|
19 (node) => { |
|
20 ok(/H1 DIV H2 P/.test(node.textContent), |
|
21 "for-of loop should find all top-level nodes"); |
|
22 finishTest(); |
|
23 }); |
|
24 } |