forked from compat-table/compat-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
398 lines (356 loc) · 14.2 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Strict mode support test — Strict mode support</title>
<style type="text/css">
body { font-family: Garamond, "Hoefler Text", "Times New Roman", Times, serif; margin: 0; }
#header { background: #454545; margin-bottom: 1em; }
#header a { color: #eee; text-decoration: none; }
#header h1 { margin: 0 0 0 0.5em; color: #eee; padding: 0.5em 0.5em 0.25em 0.5em; font-size: 1.25em; }
p { margin: 0 0 0.25em 1em; }
.test { display: inline-block; width: 570px; }
.non-standard { width: 900px; }
.non-standard code { background-color: #ffc; }
.pass, .fail { color: #fff; padding: 0.1em; width: 2.5em; display: inline-block; text-align: center; }
.pass { background-color: green; }
.fail { background-color: red; }
.back-to-the-table-header { margin-bottom: 1em; background: #ffc; padding: 0.5em; width: 595px }
</style>
</head>
<body>
<div id="header">
<h1>
<a href="http://kangax.github.com/es5-compat-table/"><span title="ECMA-262 5th edition">ECMAScript 5</span> compatibility table</a> —
<span style="color:#afa;font-weight:normal;">Strict mode support</span>
<span style="font-size:0.8em;float:right;font-weight:normal;">by
<a href="http://twitter.com/kangax/" style="color:#eee">kangax</a>
</span>
</h1>
</div>
<p class="back-to-the-table-header">
<a href="http://kangax.github.com/es5-compat-table/">
← Back to the main table
</a>
</p>
<script type="text/javascript">
// enable strict globally
"use strict";
var __global = this;
function print(message) {
var el = document.createElement('p');
el.innerHTML = message;
document.body.appendChild(el);
}
function colorResult(result) {
return '<span class="' + (result === true ? "pass" : "fail") + '">' + (result === true ? 'Yes' : 'No') + '<\/span>';
}
(function(){
var result = (function(){ try { eval('"\\010"'); return false; } catch(err) { return err instanceof SyntaxError; } })();
print('<span class="test"><code>eval(\'"\\010"\')<\/code> is a SyntaxError<\/span>' + colorResult(result));
})();
(function(){
var result = (function(){ try { eval('010'); return false; } catch(err) { return err instanceof SyntaxError; } })();
print('<span class="test"><code>eval(\'010\')<\/code> is a SyntaxError<\/span>' + colorResult(result));
})();
(function(){
var error;
try {
eval('__i_dont_exist = 1');
}
catch (err) { error = err; }
print('<span class="test"><code>__i_dont_exist = 1;<\/code> is a ReferenceError<\/span>' + colorResult(error instanceof ReferenceError));
})();
(function(){
var error;
try {
eval('eval = 1;');
}
catch (err) { error = err; }
print('<span class="test"><code>eval = 1;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('arguments = 1;');
}
catch (err) { error = err; }
print('<span class="test"><code>arguments = 1;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('eval++;');
}
catch (err) { error = err; }
print('<span class="test"><code>eval++;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('arguments++;');
}
catch (err) { error = err; }
print('<span class="test"><code>arguments++;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
(function(){ return arguments.caller; })();
}
catch (err) { error = err; }
print('<span class="test"><code>arguments.caller;<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
(function(){ return arguments.callee; })();
}
catch (err) { error = err; }
print('<span class="test"><code>arguments.callee;<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var result = (function(x){
x = 2;
return arguments[0] === 1;
})(1);
print('<span class="test"><code>(function(x){ x = 2; return arguments[0] === 1; })(1);<\/code><\/span>' + colorResult(result));
})();
(function(){
var result = (function(x){
arguments[0] = 2;
return x === 1;
})(1);
print('<span class="test"><code>(function(x){ arguments[0] = 2; return x === 1; })(1);<\/code><\/span>' + colorResult(result));
})();
(function(){
var error;
try {
eval('({ x: 1, x: 1 })');
}
catch (err) { error = err; }
print('<span class="test"><code>({ x: 1, x: 1 });<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error1, error2;
try {
eval('({ set x(eval){ } })');
}
catch (err) { error1 = err; }
try {
eval('({ set x(y){ } })');
}
catch(err) { error2 = err; }
print('<span class="test"><code>({ set x(eval){ } });<\/code> is a SyntaxError<\/span>' +
colorResult(error1 instanceof SyntaxError && error2 === undefined));
})();
(function(){
var error1, error2;
try {
eval('({ set x(arguments){ } })');
}
catch (err) { error1 = err; }
try {
eval('({ set x(y){ } })');
}
catch(err) { error2 = err; }
print('<span class="test"><code>({ set x(arguments){ } });<\/code> is a SyntaxError<\/span>' +
colorResult(error1 instanceof SyntaxError && error2 === undefined));
})();
(function(){
var error;
try {
eval('var __some_unique_variable;');
__some_unique_variable;
}
catch (err) { error = err; }
print('<span class="test"><code>eval(\'var x\'); x;<\/code> is a ReferenceError<\/span>' + colorResult(error instanceof ReferenceError));
})();
(function(){
var result = (function(){ return this === undefined; })();
print('<span class="test"><code>(function(){ return this === undefined; })();<\/code><\/span>' + colorResult(result));
})();
(function(){
var result = (function(){ return this === undefined; }).call();
print('<span class="test"><code>(function(){ return this === undefined; }).call();<\/code><\/span>' + colorResult(result));
})();
(function(){
var error;
try {
eval('var x; delete x;');
}
catch (err) { error = err; }
print('<span class="test"><code>var x; delete x;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('delete (function(){}).length;');
}
catch (err) { error = err; }
print('<span class="test"><code>delete (function(){}).length;<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
(function f() { f = 123; })();
}
catch (err) { error = err; }
print('<span class="test"><code>(function f() { f = 123; })()<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
if (Object.defineProperty) {
Object.defineProperty({ }, 'x', { writable: false }).x = 1;
}
}
catch (err) { error = err; }
print('<span class="test"><code>Object.defineProperty({ }, "x", { writable: false }).x = 1<\/code> is a TypeError<\/span>' +
colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
eval('({ get x(){ } }).x = 1');
}
catch (err) { error = err; }
print('<span class="test"><code>({ get x(){ } }).x = 1;<\/code> is a TypeError<\/span>' +
colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
eval('var eval;');
}
catch (err) { error = err; }
print('<span class="test"><code>var eval;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('var arguments;');
}
catch (err) { error = err; }
print('<span class="test"><code>var arguments;<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('with({}) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>with({}){ }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('try { } catch (eval) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>try { } catch (eval) { }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('try { } catch (arguments) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>try { } catch (arguments) { }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('function f(eval) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>function f(eval) { }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('function f(arguments) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>function f(arguments) { }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('function f(x, x) { }');
}
catch (err) { error = err; }
print('<span class="test"><code>function f(x, x) { }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('(function(){}).caller');
}
catch (err) { error = err; }
print('<span class="test"><code>(function(){}).caller;<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
eval('(function(){}).arguments');
}
catch (err) { error = err; }
print('<span class="test"><code>(function(){}).arguments;<\/code> is a TypeError<\/span>' + colorResult(error instanceof TypeError));
})();
(function(){
var error;
try {
eval('function eval(){ }');
}
catch (err) { error = err; }
print('<span class="test"><code>function eval(){ }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
(function(){
var error;
try {
eval('function arguments(){ }');
}
catch (err) { error = err; }
print('<span class="test"><code>function arguments(){ }<\/code> is a SyntaxError<\/span>' + colorResult(error instanceof SyntaxError));
})();
print('<br><strong>NON-STANDARD</strong> (i.e. not part of ECMA-262 standard)<br><br>');
(function(){
var error;
try {
eval('if (1) { function f(){ } }');
}
catch(err) {
error = err;
}
print('<span class="test non-standard">Function declarations in statements are disallowed '+
'(e.g.: <code>if (…) { function f(){ } }<\/code>) '+
'[as per <a href="http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls">ES5 Implementation Best Practice</a>]<\/span>' +
colorResult(error instanceof SyntaxError));
})();
(function(){
setTimeout('"use strict"; try { (function(){ arguments.callee; })() } catch(err) { __global.__setTimeoutError = err; }', 10);
setTimeout(function() {
print('<span class="test non-standard">setTimeout follows strict mode rules when string starts with ' +
'use strict directive (e.g.: <code>setTimeout(\'"use strict"; …\', …)<\/code>)<\/span>' +
colorResult(__global.__setTimeoutError instanceof TypeError));
}, 50);
})();
(function(){
var formEl = document.createElement('form');
formEl.setAttribute('onreset',
'"use strict"; try { eval(\'with({}){}\') } catch(err) { __global.__eventHandlerError = err; }');
document.body.appendChild(formEl);
try {
formEl.reset();
}
catch(err) { }
document.body.removeChild(formEl);
print('<span class="test non-standard">Event handler follows strict mode rules when its body starts with ' +
'use strict directive (e.g.: <code><p onclick="\'use strict\'; …">…<\/p></code>)<\/span>' +
colorResult(__global.__eventHandlerError instanceof SyntaxError));
})();
</script>
</body>
</html>