diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js index 39ac61f1f14fb088f6e3d9da36942a4df26d0654..18bb36f6f75b92f6a5eafe9e2daadb5225e55ec0 100644 --- a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T1.js @@ -6,16 +6,16 @@ info: > Promise reaction jobs have predictable environment author: Sam Mikes description: Promise.onFulfilled gets undefined as 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis, +var expectedThis = fnGlobalObject(), obj = {}; -(function () { expectedThis = this; }()); - var p = Promise.resolve(obj).then(function(arg) { if (this !== expectedThis) { - $ERROR("'this' must be same as for function called without explicit this got " + this); + $ERROR("'this' must be global object, got " + this); } if (arg !== obj) { $ERROR("Expected promise to be fulfilled by obj, actually " + arg); diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js new file mode 100644 index 0000000000000000000000000000000000000000..7d5816f6fbe3abf6c6025d4b60d289c8939f98ce --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2014 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: > + Promise reaction jobs have predictable environment +author: Sam Mikes +description: Promise.onFulfilled gets undefined as 'this' +flags: [onlyStrict] +---*/ + +var expectedThis = undefined, + obj = {}; + +var p = Promise.resolve(obj).then(function(arg) { + if (this !== expectedThis) { + $ERROR("'this' must be undefined, got " + this); + } + if (arg !== obj) { + $ERROR("Expected promise to be fulfilled by obj, actually " + arg); + } +}).then($DONE, $DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js index 2a0f5fdddc5f8fa839c9d1a59cf2f1985a4d2c46..9c2346bf8de34a6626dd218a6e2bd75bcfbf3666 100644 --- a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T1.js @@ -8,18 +8,18 @@ info: > undefined in strict mode author: Sam Mikes description: onRejected gets default 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis, +var expectedThis = fnGlobalObject(), obj = {}; -(function () { expectedThis = this; }()); - var p = Promise.reject(obj).then(function () { $ERROR("Unexpected fulfillment; expected rejection."); }, function(arg) { if (this !== expectedThis) { - $ERROR("'this' must be same as for function called without explicit this, got " + this); + $ERROR("'this' must be global object, got " + this); } if (arg !== obj) { diff --git a/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js new file mode 100644 index 0000000000000000000000000000000000000000..09bab4763ca9fc920a940536d3ebe48ac5d02998 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.2/25.4.2.1/S25.4.2.1_A3.2_T2.js @@ -0,0 +1,27 @@ +// Copyright 2014 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: > + Promise reaction jobs have predictable environment + 'this' is global object in sloppy mode, + undefined in strict mode +author: Sam Mikes +description: onRejected gets default 'this' +flags: [onlyStrict] +---*/ + +var expectedThis = undefined, + obj = {}; + +var p = Promise.reject(obj).then(function () { + $ERROR("Unexpected fulfillment; expected rejection."); +}, function(arg) { + if (this !== expectedThis) { + $ERROR("'this' must be undefined, got " + this); + } + + if (arg !== obj) { + $ERROR("Expected promise to be rejected with obj, actually " + arg); + } +}).then($DONE, $DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js index d4d2dbb4fcf82a8b556f0bdfedbb2e473bdf19b6..91833104fc7f99979fba4dfa7385194a19f65fb9 100644 --- a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js +++ b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T1.js @@ -8,15 +8,15 @@ info: > undefined in strict mode author: Sam Mikes description: Promise executor gets default handling for 'this' +flags: [noStrict] +includes: [fnGlobalObject.js] ---*/ -var expectedThis; - -(function () { expectedThis = this; }()); +var expectedThis = fnGlobalObject(); var p = new Promise(function (resolve) { if (this !== expectedThis) { - $ERROR("'this' must be same as for function called without explicit this, got " + this); + $ERROR("'this' must be global object, got " + this); } resolve(); diff --git a/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js new file mode 100644 index 0000000000000000000000000000000000000000..2a631835134cf5d93d3e5ed137009c31ca4f5621 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.3/25.4.3.1/S25.4.3.1_A5.1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2014 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: > + Promise executor has predictable environment + 'this' should be global object in sloppy mode, + undefined in strict mode +author: Sam Mikes +description: Promise executor gets default handling for 'this' +flags: [onlyStrict] +---*/ + +var expectedThis = undefined; + +var p = new Promise(function (resolve) { + if (this !== expectedThis) { + $ERROR("'this' must be undefined, got " + this); + } + + resolve(); +}).then($DONE, $DONE);