ECMAScript 5 compatibility table:
Non-writable array length:
test(function(){
try {
var a = Object.defineProperty([1], "length", {writable:false});
a.length = 0;
return a[0] === 1 && a.length === 1;
}
catch(err) {
return false;
}
}());
Getter and setter syntax:
test(function(){
try {
var setx, set15;
var obj = eval("({ get x() { return 17; }," +
" set x(v) { setx = v; }," +
" get 1.5() { return 1.5; }," +
" set '1.5'(v) { set15 = v; } })");
return obj.x === 17 && (obj.x = 42, setx === 42) &&
obj["1.5"] === 1.5 && (obj[1.5] = 1.5, set15 === 1.5);
}
catch(err) {
return false;
}
}());
Non-writable Infinity, NaN, and undefined:
test((Infinity = 5, NaN = 2, undefined = 3,
Infinity === 1/0 && NaN !== NaN && typeof undefined === "undefined"));
Non-writable user-defined properties:
var nonWritableUserProperty = 17;
var global = this;
test(function(){
nonWritableUserProperty = 42;
var writable = nonWritableUserProperty === 42;
var obj = Object.defineProperty(global, "nonWritableUserProperty", {writable:false});
nonWritableUserProperty = 9;
var writable2 = nonWritableUserProperty === 42;
return writable && obj === global && !writable2;
}());
Global function statement semantics:
ECMAScript 5 compatibility table - Strict mode support
ES5 requires this behavior if setTimeout is passed eval, so it's not quite
non-standard. But setTimeout isn't ES5, of course. I might split the
non-standard section into "INTERACTION WITH OTHER SPECIFICATIONS" and
"NON-STANDARD" to clarify this, adding this test to the INTERACTION section.
Indirect eval called with no JS running:
test(function(){
setTimeout(eval, 10, "__global.__setTimeoutEvalWorks = this === __global;");
setTimeout(function() {
print('eval works as a setTimeout callback (e.g.: setTimeout(eval, time, code)<\/code>)<\/span>' +
colorResult(__global.__setTimeoutEvalWorks === true));
}, 50);
}());