@@ -13,7 +13,7 @@ const harden = /** @type {import('ses').Harden & { isFake?: boolean }} */ (
13
13
global . harden
14
14
) ;
15
15
16
- const { getPrototypeOf, defineProperty } = Object ;
16
+ const { getPrototypeOf, defineProperty, freeze } = Object ;
17
17
const { ownKeys } = Reflect ;
18
18
19
19
test ( 'passStyleOf basic success cases' , t => {
@@ -193,16 +193,22 @@ test('passStyleOf testing remotables', t => {
193
193
194
194
const tagRecord1 = harden ( makeTagishRecord ( 'Alleged: manually constructed' ) ) ;
195
195
/** @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385 */
196
- const farObj1 = harden ( {
197
- __proto__ : tagRecord1 ,
198
- } ) ;
196
+ const farObj1 = harden ( { __proto__ : tagRecord1 } ) ;
199
197
t . is ( passStyleOf ( farObj1 ) , 'remotable' ) ;
200
198
201
199
const tagRecord2 = makeTagishRecord ( 'Alleged: tagRecord not hardened' ) ;
202
- /** @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385 */
203
- const farObj2 = Object . freeze ( {
204
- __proto__ : tagRecord2 ,
205
- } ) ;
200
+ /**
201
+ * TODO In order to run this test before we have explicit support for a
202
+ * non-trapping integrity level, we have to `freeze` here but not `harden`.
203
+ * However, once we do have that support, and `passStyleOf` checks that
204
+ * its argument is also non-trapping, we still need to avoid `harden`
205
+ * because that would also hardden `__proto__`. So we will need to
206
+ * explicitly make this non-trapping, which we cannot yet express.
207
+ * @see https://github.com/tc39/proposal-stabilize
208
+ *
209
+ * @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385
210
+ */
211
+ const farObj2 = freeze ( { __proto__ : tagRecord2 } ) ;
206
212
if ( harden . isFake ) {
207
213
t . is ( passStyleOf ( farObj2 ) , 'remotable' ) ;
208
214
} else {
@@ -212,39 +218,27 @@ test('passStyleOf testing remotables', t => {
212
218
} ) ;
213
219
}
214
220
215
- const tagRecord3 = Object . freeze (
216
- makeTagishRecord ( 'Alleged: both manually frozen' ) ,
217
- ) ;
221
+ const tagRecord3 = harden ( makeTagishRecord ( 'Alleged: both manually frozen' ) ) ;
218
222
/** @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385 */
219
- const farObj3 = Object . freeze ( {
220
- __proto__ : tagRecord3 ,
221
- } ) ;
223
+ const farObj3 = harden ( { __proto__ : tagRecord3 } ) ;
222
224
t . is ( passStyleOf ( farObj3 ) , 'remotable' ) ;
223
225
224
226
const tagRecord4 = harden ( makeTagishRecord ( 'Remotable' ) ) ;
225
227
/** @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385 */
226
- const farObj4 = harden ( {
227
- __proto__ : tagRecord4 ,
228
- } ) ;
228
+ const farObj4 = harden ( { __proto__ : tagRecord4 } ) ;
229
229
t . is ( passStyleOf ( farObj4 ) , 'remotable' ) ;
230
230
231
231
const tagRecord5 = harden ( makeTagishRecord ( 'Not alleging' ) ) ;
232
- const farObj5 = harden ( {
233
- __proto__ : tagRecord5 ,
234
- } ) ;
232
+ const farObj5 = harden ( { __proto__ : tagRecord5 } ) ;
235
233
t . throws ( ( ) => passStyleOf ( farObj5 ) , {
236
234
message :
237
235
/ F o r n o w , i f a c e " N o t a l l e g i n g " m u s t b e " R e m o t a b l e " o r b e g i n w i t h " A l l e g e d : " o r " D e b u g N a m e : " ; u n i m p l e m e n t e d / ,
238
236
} ) ;
239
237
240
238
const tagRecord6 = harden ( makeTagishRecord ( 'Alleged: manually constructed' ) ) ;
241
- const farObjProto6 = harden ( {
242
- __proto__ : tagRecord6 ,
243
- } ) ;
239
+ const farObjProto6 = harden ( { __proto__ : tagRecord6 } ) ;
244
240
/** @type {any } UNTIL https://github.com/microsoft/TypeScript/issues/38385 */
245
- const farObj6 = harden ( {
246
- __proto__ : farObjProto6 ,
247
- } ) ;
241
+ const farObj6 = harden ( { __proto__ : farObjProto6 } ) ;
248
242
t . is ( passStyleOf ( farObj6 ) , 'remotable' , 'tagRecord grandproto is accepted' ) ;
249
243
250
244
// Our current agoric-sdk plans for far classes are to create a class-like
@@ -323,12 +317,8 @@ test('passStyleOf testing remotables', t => {
323
317
const fauxTagRecordB = harden (
324
318
makeTagishRecord ( 'Alleged: manually constructed' , harden ( { } ) ) ,
325
319
) ;
326
- const farObjProtoB = harden ( {
327
- __proto__ : fauxTagRecordB ,
328
- } ) ;
329
- const farObjB = harden ( {
330
- __proto__ : farObjProtoB ,
331
- } ) ;
320
+ const farObjProtoB = harden ( { __proto__ : fauxTagRecordB } ) ;
321
+ const farObjB = harden ( { __proto__ : farObjProtoB } ) ;
332
322
t . throws ( ( ) => passStyleOf ( farObjB ) , {
333
323
message :
334
324
'cannot serialize Remotables with non-methods like "Symbol(passStyle)" in "[Alleged: manually constructed]"' ,
@@ -387,7 +377,16 @@ test('remotables - safety from the gibson042 attack', t => {
387
377
} ,
388
378
) ;
389
379
390
- const makeInput = ( ) => Object . freeze ( { __proto__ : mercurialProto } ) ;
380
+ /**
381
+ * TODO In order to run this test before we have explicit support for a
382
+ * non-trapping integrity level, we have to `freeze` here but not `harden`.
383
+ * However, once we do have that support, and `passStyleOf` checks that
384
+ * its argument is also non-trapping, we still need to avoid `harden`
385
+ * because that would also hardden `__proto__`. So we will need to
386
+ * explicitly make this non-trapping, which we cannot yet express.
387
+ * @see https://github.com/tc39/proposal-stabilize
388
+ */
389
+ const makeInput = ( ) => freeze ( { __proto__ : mercurialProto } ) ;
391
390
const input1 = makeInput ( ) ;
392
391
const input2 = makeInput ( ) ;
393
392
0 commit comments