Skip to content
Snippets Groups Projects
Commit f5447735 authored by smikes's avatar smikes
Browse files

split "expectedThis" cases into strict/nonstrict branches

parent 26787ab0
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
// 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);
......@@ -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) {
......
// 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);
......@@ -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();
......
// 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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment