gecko/dom/base/test/test_e4x_for_each.html
2012-12-23 05:13:02 +09:00

56 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html>
<head><meta charset=utf-8>
<title>Test for E4X "for each" syntax</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="template" style="display: none">
function runTest(i) {
var t = tests[i];
count++;
try {
Function("for each (var a in []) {}");
ok(t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " supports for-each-in");
} catch (e) {
ok(!t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " does NOT support for-each-in");
}
}
</div>
<pre id="test">
<script class="testbody">
var tests = [
{enabled: false},
{version: "1.0", enabled: false},
{version: "1.1", enabled: false},
{version: "1.2", enabled: false},
{version: "1.3", enabled: false},
{version: "1.4", enabled: false},
{version: "1.5", enabled: false},
{version: "1.6", enabled: true},
{version: "1.7", enabled: true},
{version: "1.8", enabled: true},
];
var count = 0;
for (var i = 0; i < tests.length; i++) {
var t = tests[i];
var script = document.createElement("script");
script.type = "application/javascript" + ("version" in t ? ";version=" + t.version : "");
script.textContent = document.getElementById("template").textContent + "\n" + "runTest(" + i + ");";
document.body.appendChild(script);
}
script = document.createElement("script");
script.textContent = 'is(count, tests.length, "runTest() call count");';
document.body.appendChild(script);
</script>
</pre>
</body>
</html>