summaryrefslogtreecommitdiff
path: root/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js
blob: e431a27932d692cc4f6f1419f18539be8276ecdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2014 Cubane Canada, Inc.  All rights reserved.
// See LICENSE for details.

/*---
info: |
    [...]
    6. Else, let handlerResult be Call(handler, undefined, «argument»).
es6id: S25.4.2.1_A3.1_T2
author: Sam Mikes
description: >
    "fulfilled" handler invoked correctly in strict mode
flags: [async, onlyStrict]
---*/

var expectedThis = undefined,
    obj = {};

var p = Promise.resolve(obj).then(function(arg) {
    if (this !== expectedThis) {
        $DONE("'this' must be undefined, got " + this);
        return;
    }

    if (arg !== obj) {
        $DONE("Expected promise to be fulfilled by obj, actually " + arg);
        return;
    }

    if (arguments.length !== 1) {
        $DONE('Expected handler function to be called with exactly 1 argument.');
        return;
    }

    $DONE();
}, function() {
  $DONE('The promise should not be rejected.');
});