Skip to content

Commit

Permalink
repair more properties, to fix tape-4.x (#293)
Browse files Browse the repository at this point in the history
This adds `FunctionPrototype.apply`, as well as `.message` for all the
various Error prototypes, to the enablements list.

This allows tape-4.x to be imported after lockdown, as well as fixing tape's
t.throws() method.

refs #293, but does not close it because tape-5.x is still broken
  • Loading branch information
warner committed May 15, 2020
1 parent b05a91f commit 718c856
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/ses/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ User-visible changes in SES:

## Next release

* No changes yet.
* Repair `Function.apply` and `TypeError.message` (as well as `.message` on
all the other Error types), to tolerate what the npm `es-abstract` module
does. This allows `tape` (version 4.x) to be loaded in a locked-down SES
world, and also allows its `t.throws` assertion to work. `tape` (version
5.x) still has problems. (#293)

## Release 0.7.7 (27-Apr-2020)

Expand Down
22 changes: 22 additions & 0 deletions packages/ses/src/enablements.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default {
FunctionPrototype: {
constructor: t, // set by "regenerator-runtime"
bind: t, // set by "underscore"
apply: t, // set by "tape"
name: t,
toString: t,
},
Expand All @@ -82,9 +83,30 @@ export default {

TypeErrorPrototype: {
constructor: t, // set by "readable-stream"
message: t, // set by "tape"
name: t, // set by "readable-stream"
},

SyntaxErrorPrototype: {
message: t, // to match TypeErrorPrototype.message
},

RangeErrorPrototype: {
message: t, // to match TypeErrorPrototype.message
},

URIErrorPrototype: {
message: t, // to match TypeErrorPrototype.message
},

EvalErrorPrototype: {
message: t, // to match TypeErrorPrototype.message
},

ReferenceErrorPrototype: {
message: t, // to match TypeErrorPrototype.message
},

PromisePrototype: {
constructor: t, // set by "core-js"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/ses/test/enable-property-overrides.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ test('enablePropertyOverrides - on', t => {
'constructor',
// 'name', // TODO
'bind',
'apply',
'toString',
]);
testOverriding(t, 'Error', new Error(), [
Expand All @@ -91,7 +92,11 @@ test('enablePropertyOverrides - on', t => {
'message',
'toString',
]);
testOverriding(t, 'TypeError', new TypeError(), ['constructor', 'name']);
testOverriding(t, 'TypeError', new TypeError(), [
'constructor',
'name',
'message',
]);
// eslint-disable-next-line func-names
testOverriding(t, 'Promise', new Promise(function() {}), ['constructor']);
testOverriding(t, 'JSON', JSON);
Expand Down

0 comments on commit 718c856

Please sign in to comment.