style(marshal): Respond to PR feedback
MODIFY
packages/marshal/src/helpers/copyRecord.js
packages/marshal/src/helpers/copyRecord.js
@@ -38,6 +38,7 @@ export const CopyRecordHelper = harden({
(!canBeMethod(candidate[key]) ||
(!!reject &&
reject(
+ // TODO: Update message now that there is no such thing as "implicit Remotable".
X`Records cannot contain non-far functions because they may be methods of an implicit Remotable: ${candidate}`,
)));
if (!valid) {

MODIFY
packages/marshal/src/helpers/passStyle-helpers.js
packages/marshal/src/helpers/passStyle-helpers.js
@@ -128,14 +128,12 @@ export const getTag = tagRecord => tagRecord[Symbol.toStringTag];
harden(getTag);
export const checkPassStyle = (obj, expectedPassStyle, check) => {
+ const reject = !!check && (details => check(false, details));
const actual = obj[PASS_STYLE];
return (
actual === expectedPassStyle ||
- (!!check &&
- check(
- false,
- X`Expected ${q(expectedPassStyle)}, not ${q(actual)}: ${obj}`,
- ))
+ (reject &&
+ reject(X`Expected ${q(expectedPassStyle)}, not ${q(actual)}: ${obj}`))
);
};
harden(checkPassStyle);
@@ -177,6 +175,7 @@ export const checkTagRecord = makeCheckTagRecord(
(!!check &&
check(false, X`A tagRecord must inherit from Object.prototype: ${val}`)),
);
+harden(checkTagRecord);
export const checkFunctionTagRecord = makeCheckTagRecord(
(val, proto, check) =>
@@ -188,3 +187,4 @@ export const checkFunctionTagRecord = makeCheckTagRecord(
X`For functions, a tagRecord must inherit from Function.prototype: ${val}`,
)),
);
+harden(checkFunctionTagRecord);

MODIFY
packages/marshal/test/test-passStyleOf.js
packages/marshal/test/test-passStyleOf.js
@@ -42,6 +42,18 @@ test('some passStyleOf rejections', t => {
message: /Cannot pass non-frozen objects like {}. Use harden\(\)/,
});
+ const copyRecordBadAccessor = Object.defineProperty({}, 'foo', {
+ get: () => undefined,
+ enumerable: true,
+ });
+ t.throws(() => passStyleOf(harden(copyRecordBadAccessor)), {
+ message: /^"foo" must not be an accessor property/,
+ });
+ const copyRecordBadNonenumerable = Object.defineProperty({}, 'foo', {});
+ t.throws(() => passStyleOf(harden(copyRecordBadNonenumerable)), {
+ message: /^"foo" must be an enumerable property/,
+ });
+
const prbad1 = Promise.resolve();
Object.setPrototypeOf(prbad1, { __proto__: Promise.prototype });
harden(prbad1);

style(marshal): Respond to PR feedback