File: NodeList-Iterable.html

package info (click to toggle)
firefox-esr 52.8.1esr-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,983,244 kB
  • sloc: cpp: 4,810,275; ansic: 2,004,548; python: 451,282; java: 241,615; asm: 178,649; xml: 136,302; sh: 82,207; makefile: 22,575; perl: 15,783; objc: 4,389; yacc: 1,816; ada: 1,697; pascal: 1,519; lex: 1,257; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (37 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!doctype html>
<meta charset="utf-8">
<title>NodeList Iterable Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
    <p id="1"></p>
    <p id="2"></p>
    <p id="3"></p>
    <p id="4"></p>
    <p id="5"></p>
<script>
    var paragraphs;
    setup(function() {
        paragraphs = document.querySelectorAll('p');
    })
    test(function() {
        assert_true('length' in paragraphs);
    }, 'NodeList has length method.');
    test(function() {
        assert_true('values' in paragraphs);
    }, 'NodeList has values method.');
    test(function() {
        assert_true('entries' in paragraphs);
    }, 'NodeList has entries method.');
    test(function() {
        assert_true('forEach' in paragraphs);
    }, 'NodeList has forEach method.');
    test(function() {
        assert_true(Symbol.iterator in paragraphs);
    }, 'NodeList has Symbol.iterator.');
    test(function() {
        var ids = "12345", idx=0;
        for(var node of paragraphs){
            assert_equals(node.getAttribute('id'), ids[idx++]);
        }
    }, 'NodeList is iterable via for-of loop.');
</script>