Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head><meta charset=utf-8> |
michael@0 | 4 | <title>Test for E4X "for each" syntax</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | |
michael@0 | 12 | </div> |
michael@0 | 13 | <div id="template" style="display: none"> |
michael@0 | 14 | function runTest(i) { |
michael@0 | 15 | var t = tests[i]; |
michael@0 | 16 | count++; |
michael@0 | 17 | try { |
michael@0 | 18 | Function("for each (var a in []) {}"); |
michael@0 | 19 | ok(t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " supports for-each-in"); |
michael@0 | 20 | } catch (e) { |
michael@0 | 21 | ok(!t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " does NOT support for-each-in"); |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | </div> |
michael@0 | 25 | <pre id="test"> |
michael@0 | 26 | <script class="testbody"> |
michael@0 | 27 | |
michael@0 | 28 | var tests = [ |
michael@0 | 29 | {enabled: false}, |
michael@0 | 30 | {version: "1.0", enabled: false}, |
michael@0 | 31 | {version: "1.1", enabled: false}, |
michael@0 | 32 | {version: "1.2", enabled: false}, |
michael@0 | 33 | {version: "1.3", enabled: false}, |
michael@0 | 34 | {version: "1.4", enabled: false}, |
michael@0 | 35 | {version: "1.5", enabled: false}, |
michael@0 | 36 | {version: "1.6", enabled: true}, |
michael@0 | 37 | {version: "1.7", enabled: true}, |
michael@0 | 38 | {version: "1.8", enabled: true}, |
michael@0 | 39 | ]; |
michael@0 | 40 | |
michael@0 | 41 | var count = 0; |
michael@0 | 42 | for (var i = 0; i < tests.length; i++) { |
michael@0 | 43 | var t = tests[i]; |
michael@0 | 44 | var script = document.createElement("script"); |
michael@0 | 45 | script.type = "application/javascript" + ("version" in t ? ";version=" + t.version : ""); |
michael@0 | 46 | script.textContent = document.getElementById("template").textContent + "\n" + "runTest(" + i + ");"; |
michael@0 | 47 | document.body.appendChild(script); |
michael@0 | 48 | } |
michael@0 | 49 | script = document.createElement("script"); |
michael@0 | 50 | script.textContent = 'is(count, tests.length, "runTest() call count");'; |
michael@0 | 51 | document.body.appendChild(script); |
michael@0 | 52 | </script> |
michael@0 | 53 | </pre> |
michael@0 | 54 | </body> |
michael@0 | 55 | </html> |