Update inert constructor error messages
MODIFY
packages/ses/src/compartment-shim.js
packages/ses/src/compartment-shim.js
@@ -60,7 +60,9 @@ export const InertCompartment = function Compartment(
_modules = {},
_options = {},
) {
- throw new TypeError('Not available');
+ throw new TypeError(
+ 'Compartment.prototype.constructor is not a valid constructor.',
+ );
};
export const CompartmentPrototype = {

MODIFY
packages/ses/src/tame-function-constructors.js
packages/ses/src/tame-function-constructors.js
@@ -75,7 +75,9 @@ export default function tameFunctionConstructors() {
// prototype of functions.
// eslint-disable-next-line func-names
const InertConstructor = function() {
- throw new TypeError('Not available');
+ throw new TypeError(
+ 'Function.prototype.constructor is not a valid constructor.',
+ );
};
defineProperties(InertConstructor, {
prototype: { value: FunctionPrototype },

MODIFY
packages/ses/test/test-whitelist.js
packages/ses/test/test-whitelist.js
@@ -68,18 +68,22 @@ x.slice;
);
});
-test('Function constructor is inert', t => {
+test('Function constructor should be inert', t => {
t.throws(
() => Function.prototype.constructor(),
- { message: 'Not available' },
- 'Function constructor is disabled',
+ {
+ message: 'Function.prototype.constructor is not a valid constructor.',
+ },
+ 'Function constructor should be disabled',
);
});
-test('Compartment constructor is inert', t => {
+test('Compartment constructor should be inert', t => {
t.throws(
() => Compartment.prototype.constructor(),
- { message: 'Not available' },
- 'Compartment constructor is disabled',
+ {
+ message: 'Compartment.prototype.constructor is not a valid constructor.',
+ },
+ 'Compartment constructor should be disabled',
);
});

Update inert constructor error messages