summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/toString-dontEnum.html
blob: d376d538c8ca7ce14ab97c76b093e3770cd985c4 (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
35
36
37
38
39
40
41
42
43
44
45
46
<html>
<head>
    <script type="text/javascript" charset="utf-8">
        function log(msg)
        {
            document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
        }

        function test(element, name)
        {
            var didPass = true;
            for (prop in element) {
                if (prop == "toString")
                    didPass = false;
            }
            if (didPass)
                log("PASS: the toString function is not enumerable for " + name + ".");
            else
                log("FAIL: the toString function is enumerable for " + name + " and should not be.");
        }

        function runTests()
        {
            if (window.testRunner)
                testRunner.dumpAsText();

            // DOM objects with custom toString() functions
            test(document.createElement('a'), "HTMLAnchorElement");
            test(window.location, "Location");
            test(window.getSelection(), "Selection");

            // Other DOM objects
            test(document.createElement('div'), "HTMLDivElement");
            test(document, "HTMLDocument");

            // JS objects
            test({}, "Object");
            test([], "Array");
        }
    </script>
</head>
<body onload="runTests();">
    <p>This tests that the toString() function does not enumerate.</p>
    <pre id="console"></pre>
</body>
</html>