summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js')
-rw-r--r--js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js b/js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js
new file mode 100644
index 0000000000..910f3791e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/resolve/resolve-from-promise-capability.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 25.4.4.5
+description: >
+ Resolve function is called after Promise constructor returns.
+info: |
+ Promise.resolve ( x )
+
+ ...
+ 4. Let promiseCapability be NewPromiseCapability(C).
+ 5. ReturnIfAbrupt(promiseCapability).
+ 6. Let resolveResult be Call(promiseCapability.[[Resolve]], undefined, «x»).
+ 7. ReturnIfAbrupt(resolveResult).
+ ...
+---*/
+
+var expectedThisValue = (function() {
+ return this;
+}());
+var callCount = 0;
+var object = {};
+var thisValue, args;
+
+Promise.resolve.call(function(executor) {
+ function resolve(v) {
+ callCount += 1;
+ thisValue = this;
+ args = arguments;
+ }
+ executor(resolve, Test262Error.thrower);
+ assert.sameValue(callCount, 0, "callCount before returning from constructor");
+}, object);
+
+assert.sameValue(callCount, 1, "callCount after call to resolve()");
+assert.sameValue(typeof args, "object");
+assert.sameValue(args.length, 1);
+assert.sameValue(args[0], object);
+assert.sameValue(thisValue, expectedThisValue);
+
+reportCompare(0, 0);