1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_for_of.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,24 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// A for-of loop in Web Console code can loop over a content NodeList. 1.8 + 1.9 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-for-of.html"; 1.10 + 1.11 +function test() { 1.12 + addTab(TEST_URI); 1.13 + browser.addEventListener("load", function onLoad() { 1.14 + browser.removeEventListener("load", onLoad, true); 1.15 + openConsole(null, testForOf); 1.16 + }, true); 1.17 +} 1.18 + 1.19 +function testForOf(hud) { 1.20 + var jsterm = hud.jsterm; 1.21 + jsterm.execute("{ [x.tagName for (x of document.body.childNodes) if (x.nodeType === 1)].join(' '); }", 1.22 + (node) => { 1.23 + ok(/H1 DIV H2 P/.test(node.textContent), 1.24 + "for-of loop should find all top-level nodes"); 1.25 + finishTest(); 1.26 + }); 1.27 +}