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
47
48
49
50
51
52
53
54
55
|
<!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>
|