diff --git a/packages/ses/NEWS.md b/packages/ses/NEWS.md index c503e6dfb8..3fd5ce2e21 100644 --- a/packages/ses/NEWS.md +++ b/packages/ses/NEWS.md @@ -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) diff --git a/packages/ses/src/enablements.js b/packages/ses/src/enablements.js index 0e31b086a1..17b916a5f0 100644 --- a/packages/ses/src/enablements.js +++ b/packages/ses/src/enablements.js @@ -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, }, @@ -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" }, diff --git a/packages/ses/test/enable-property-overrides.test.js b/packages/ses/test/enable-property-overrides.test.js index 761fcb672d..fef57f0133 100644 --- a/packages/ses/test/enable-property-overrides.test.js +++ b/packages/ses/test/enable-property-overrides.test.js @@ -83,6 +83,7 @@ test('enablePropertyOverrides - on', t => { 'constructor', // 'name', // TODO 'bind', + 'apply', 'toString', ]); testOverriding(t, 'Error', new Error(), [ @@ -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);