browser/devtools/webconsole/test/browser_webconsole_for_of.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // A for-of loop in Web Console code can loop over a content NodeList.
     6 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-for-of.html";
     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 }
    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 }

mercurial