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