summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/lists/DOMTokenList-Iterable.html
blob: 4cf84b12a22d15cbc8fb76d174ee0cbb7693b63b (plain)
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
<!doctype html>
<meta charset="utf-8">
<title>DOMTokenList Iterable Test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<span class="foo   Foo foo   "></span>
<script>
    var elementClasses;
    setup(function() {
        elementClasses = document.querySelector("span").classList;
    })
    test(function() {
        assert_true('length' in elementClasses);
    }, 'DOMTokenList has length method.');
    test(function() {
        assert_true('values' in elementClasses);
    }, 'DOMTokenList has values method.');
    test(function() {
        assert_true('entries' in elementClasses);
    }, 'DOMTokenList has entries method.');
    test(function() {
        assert_true('forEach' in elementClasses);
    }, 'DOMTokenList has forEach method.');
    test(function() {
        assert_true(Symbol.iterator in elementClasses);
    }, 'DOMTokenList has Symbol.iterator.');
    test(function() {
        var classList = [];
        for (var className of elementClasses){
            classList.push(className);
        }
        assert_array_equals(classList, ['foo', 'Foo']);
    }, 'DOMTokenList is iterable via for-of loop.');
</script>