Bug 1237961 - Assert.throws raises a TypeError exception when the "expected" parameter is an arrow function. r=mikedeboer

MozReview-Commit-ID: CyhD00Uwbwj

--HG--
extra : rebase_source : 24a80ca12bfdded82f4bc3487ee491defa60da7b
This commit is contained in:
Paolo Amadini 2017-01-20 15:38:56 +01:00
Родитель 43c1d4a481
Коммит bfb4e9151f
2 изменённых файлов: 10 добавлений и 1 удалений

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

@ -314,7 +314,10 @@ function expectedException(actual, expected) {
if (instanceOf(expected, "RegExp")) {
return expected.test(actual);
} else if (actual instanceof expected) {
// We need to guard against the right hand parameter of "instanceof" lacking
// the "prototype" property, which is true of arrow functions in particular.
} else if (!(typeof expected === "function" && !expected.prototype) &&
actual instanceof expected) {
return true;
} else if (expected.call({}, actual) === true) {
return true;

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

@ -208,6 +208,12 @@ function run_test() {
return true;
}
});
// do the same with an arrow function
assert.throws(makeBlock(thrower, TypeError), err => {
if ((err instanceof TypeError) && /test/.test(err)) {
return true;
}
});
function testAssertionMessage(actual, expected) {
try {