Bug 1191292 - Keep ecma_6/Reflect/apply.js from permafailing when Gecko 42 merges to Aurora. r=Waldo.

--HG--
extra : commitid : EeGMbyJL0Du
extra : rebase_source : a555132dee99b2a3b3e3816032d3a821f77fa29c
extra : amend_source : 54942b865cd000c90626a71c6c22d5dfd3d3b0b1
This commit is contained in:
Jason Orendorff 2015-08-06 15:50:06 -05:00
Родитель 09e6660ab4
Коммит 996744154e
5 изменённых файлов: 17 добавлений и 22 удалений

Просмотреть файл

@ -1 +1 @@
load(libdir + "../../tests/ecma_6/Class/shell.js"); load(libdir + "../../tests/ecma_6/shell.js");

Просмотреть файл

@ -4,15 +4,6 @@
if (typeof version != 'undefined') if (typeof version != 'undefined')
version(185); version(185);
function classesEnabled() {
try {
new Function("class Foo { constructor() { } }");
return true;
} catch (e if e instanceof SyntaxError) {
return false;
}
}
function assertThrownErrorContains(thunk, substr) { function assertThrownErrorContains(thunk, substr) {
try { try {
thunk(); thunk();

Просмотреть файл

@ -5,8 +5,11 @@
assertEq(Reflect.apply(Math.floor, undefined, [1.75]), 1); assertEq(Reflect.apply(Math.floor, undefined, [1.75]), 1);
// Reflect.apply requires a target object that's callable. // Reflect.apply requires a target object that's callable.
class clsX { constructor() {} } // classes are not callable var nonCallable = [{}, []];
var nonCallable = [{}, [], clsX]; if (classesEnabled()) {
// classes are not callable
nonCallable.push(eval("(class clsX { constructor() {} })"));
}
for (var value of nonCallable) { for (var value of nonCallable) {
assertThrowsInstanceOf(() => Reflect.apply(nonCallable), TypeError); assertThrowsInstanceOf(() => Reflect.apply(nonCallable), TypeError);
} }

Просмотреть файл

@ -30,16 +30,6 @@ var bound = f.bind(null, "carrot");
assertDeepEq(Reflect.construct(bound, []), new bound); assertDeepEq(Reflect.construct(bound, []), new bound);
// Classes: // Classes:
function classesEnabled(testCode = "class Foo { constructor() {} }") {
try {
new Function(testCode);
return true;
} catch (e) {
if (!(e instanceof SyntaxError))
throw e;
return false;
}
}
if (classesEnabled()) { if (classesEnabled()) {
eval(`{ eval(`{
class Base { class Base {

Просмотреть файл

@ -215,3 +215,14 @@ if (typeof assertWarning === 'undefined') {
disableLastWarning(); disableLastWarning();
} }
} }
function classesEnabled(testCode = "class Foo { constructor() {} }") {
try {
new Function(testCode);
return true;
} catch (e) {
if (!(e instanceof SyntaxError))
throw e;
return false;
}
}