diff --git a/test/es6/ES6Promise.js b/test/es6/ES6Promise.js index 4c208f36b84..180c7e89575 100644 --- a/test/es6/ES6Promise.js +++ b/test/es6/ES6Promise.js @@ -74,6 +74,7 @@ var tests = [ assert.isTrue(descriptor.configurable, "Promise.prototype.catch.configurable === true"); assert.areEqual('function', typeof descriptor.value, "typeof Promise.prototype.catch === 'function'"); assert.areEqual(1, Promise.prototype.catch.length, "Promise.prototype.catch.length === 1"); + assert.areEqual("catch", Promise.prototype.catch.name, "Promise.prototype.catch.name === 'catch'"); var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'then'); assert.isTrue(descriptor.writable, "Promise.prototype.then.writable === true"); @@ -81,6 +82,7 @@ var tests = [ assert.isTrue(descriptor.configurable, "Promise.prototype.then.configurable === true"); assert.areEqual('function', typeof descriptor.value, "typeof Promise.prototype.then === 'function'"); assert.areEqual(2, Promise.prototype.then.length, "Promise.prototype.then.length === 2"); + assert.areEqual("then", Promise.prototype.then.name, "Promise.prototype.then.name === 'then'"); var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'finally'); assert.isTrue(descriptor.writable, "Promise.prototype.finally.writable === true"); @@ -88,6 +90,7 @@ var tests = [ assert.isTrue(descriptor.configurable, "Promise.prototype.finally.configurable === true"); assert.areEqual('function', typeof descriptor.value, "typeof Promise.prototype.finally === 'function'"); assert.areEqual(1, Promise.prototype.finally.length, "Promise.prototype.finally.length === 1"); + assert.areEqual("finally", Promise.prototype.finally.name, "Promise.prototype.finally.name === 'finally'"); var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, Symbol.toStringTag); assert.isFalse(descriptor.writable, "Promise.prototype[@@toStringTag].writable === false"); @@ -411,6 +414,26 @@ var tests = [ assert.isTrue(calledThen, "Promise.prototype.finally uses the modified then function"); } }, + { + name: "Promise.prototype.finally creates anonymous ThenFinally function", + body: function (index) { + class TestPromise extends Promise { + then (a, b) + { + this.first = a; + this.second = b; + this.argCount = arguments.length; + } + } + var p = new TestPromise(function() {}); + p.finally(function() {}); + assert.areEqual(p.first.name, "", "Promise.prototype.finally creates anonymous resolve handler"); + assert.areEqual(p.first.length, 1, "Promise.prototype.finally creates resolve handler with length 1"); + assert.areEqual(p.second.name, "", "Promise.prototype.finally creates anonymous reject handler"); + assert.areEqual(p.second.length, 1, "Promise.prototype.finally creates reject handler with length 1"); + assert.areEqual(p.argCount, 2, "Promise.prototype.finally invokes then with exactly 2 arguments"); + } + }, { name: "Subclass of Promise should return instances of the subclass from Promise methods", body: function () {