@@ -13,35 +13,7 @@ const harden = /** @type {import('ses').Harden & { isFake?: boolean }} */ (
13
13
global . harden
14
14
) ;
15
15
16
- const { getPrototypeOf, defineProperty, freeze } = Object ;
17
- /**
18
- * Local alias of `harden` to eventually be switched to whatever applies
19
- * the suppress-trapping integrity trait. For the shim at
20
- * https://github.com/endojs/endo/pull/2673
21
- * that is `suppressTrapping`, which is why we choose that name for the
22
- * placeholder here. But it is a separate definition so these aliased uses
23
- * do not yet depend on the final name.
24
- *
25
- * TODO Once we do have support for an explicit `suppressTrapping` operation,
26
- * we should import that instead, and if necessary rename all uses to that
27
- * operation's final name.
28
- */
29
- const hardenToBeSuppressTrapping = harden ;
30
-
31
- /**
32
- * Local alias of `freeze` to eventually be switched to whatever applies
33
- * the suppress-trapping integrity trait. For the shim at
34
- * https://github.com/endojs/endo/pull/2673
35
- * that is `suppressTrapping`, which is why we choose that name for the
36
- * placeholder here. But it is a separate definition so these aliased uses
37
- * do not yet depend on the final name.
38
- *
39
- * TODO Once we do have support for an explicit `suppressTrapping` operation,
40
- * we should import that instead, and if necessary rename all uses to that
41
- * operation's final name.
42
- */
43
- const freezeToBeSuppressTrapping = freeze ;
44
-
16
+ const { getPrototypeOf, defineProperty, freeze, suppressTrapping } = Object ;
45
17
const { ownKeys } = Reflect ;
46
18
47
19
test ( 'passStyleOf basic success cases' , t => {
@@ -224,23 +196,15 @@ test('passStyleOf testing remotables', t => {
224
196
t . is ( passStyleOf ( Far ( 'foo' , ( ) => 'far function' ) ) , 'remotable' ) ;
225
197
226
198
const tagRecord1 = harden ( makeTagishRecord ( 'Alleged: manually constructed' ) ) ;
227
- const farObj1 = hardenToBeSuppressTrapping ( { __proto__ : tagRecord1 } ) ;
199
+ const farObj1 = suppressTrapping ( { __proto__ : tagRecord1 } ) ;
228
200
t . is ( passStyleOf ( farObj1 ) , 'remotable' ) ;
229
201
230
202
const tagRecord2 = makeTagishRecord ( 'Alleged: tagRecord not hardened' ) ;
231
203
/**
232
204
* Do not freeze `tagRecord2` in order to test that an object with
233
205
* a non-frozen __proto__ is not passable.
234
- *
235
- * TODO In order to run this test before we have explicit support for a
236
- * non-trapping integrity trait, we have to `freeze` here but not `harden`.
237
- * However, once we do have that support, and `passStyleOf` checks that
238
- * its argument is also non-trapping, we still need to avoid `harden`
239
- * because that would also harden `__proto__`. So we will need to
240
- * explicitly make this non-trapping, which we cannot yet express.
241
- * @see https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md
242
206
*/
243
- const farObj2 = freezeToBeSuppressTrapping ( { __proto__ : tagRecord2 } ) ;
207
+ const farObj2 = suppressTrapping ( { __proto__ : tagRecord2 } ) ;
244
208
if ( harden . isFake ) {
245
209
t . is ( passStyleOf ( farObj2 ) , 'remotable' ) ;
246
210
} else {
@@ -251,23 +215,23 @@ test('passStyleOf testing remotables', t => {
251
215
}
252
216
253
217
const tagRecord3 = harden ( makeTagishRecord ( 'Alleged: both manually frozen' ) ) ;
254
- const farObj3 = hardenToBeSuppressTrapping ( { __proto__ : tagRecord3 } ) ;
218
+ const farObj3 = suppressTrapping ( { __proto__ : tagRecord3 } ) ;
255
219
t . is ( passStyleOf ( farObj3 ) , 'remotable' ) ;
256
220
257
221
const tagRecord4 = harden ( makeTagishRecord ( 'Remotable' ) ) ;
258
- const farObj4 = hardenToBeSuppressTrapping ( { __proto__ : tagRecord4 } ) ;
222
+ const farObj4 = suppressTrapping ( { __proto__ : tagRecord4 } ) ;
259
223
t . is ( passStyleOf ( farObj4 ) , 'remotable' ) ;
260
224
261
225
const tagRecord5 = harden ( makeTagishRecord ( 'Not alleging' ) ) ;
262
- const farObj5 = hardenToBeSuppressTrapping ( { __proto__ : tagRecord5 } ) ;
226
+ const farObj5 = suppressTrapping ( { __proto__ : tagRecord5 } ) ;
263
227
t . throws ( ( ) => passStyleOf ( farObj5 ) , {
264
228
message :
265
229
/ 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 / ,
266
230
} ) ;
267
231
268
232
const tagRecord6 = harden ( makeTagishRecord ( 'Alleged: manually constructed' ) ) ;
269
- const farObjProto6 = hardenToBeSuppressTrapping ( { __proto__ : tagRecord6 } ) ;
270
- const farObj6 = hardenToBeSuppressTrapping ( { __proto__ : farObjProto6 } ) ;
233
+ const farObjProto6 = suppressTrapping ( { __proto__ : tagRecord6 } ) ;
234
+ const farObj6 = suppressTrapping ( { __proto__ : farObjProto6 } ) ;
271
235
t . is ( passStyleOf ( farObj6 ) , 'remotable' , 'tagRecord grandproto is accepted' ) ;
272
236
273
237
// Our current agoric-sdk plans for far classes are to create a class-like
@@ -321,7 +285,7 @@ test('passStyleOf testing remotables', t => {
321
285
const tagRecordA1 = harden (
322
286
makeTagishRecord ( 'Alleged: null-proto tagRecord proto' , null ) ,
323
287
) ;
324
- const farObjA1 = hardenToBeSuppressTrapping ( { __proto__ : tagRecordA1 } ) ;
288
+ const farObjA1 = suppressTrapping ( { __proto__ : tagRecordA1 } ) ;
325
289
t . throws (
326
290
( ) => passStyleOf ( farObjA1 ) ,
327
291
{ message : unusualTagRecordProtoMessage } ,
@@ -331,8 +295,8 @@ test('passStyleOf testing remotables', t => {
331
295
const tagRecordA2 = harden (
332
296
makeTagishRecord ( 'Alleged: null-proto tagRecord grandproto' , null ) ,
333
297
) ;
334
- const farObjProtoA2 = hardenToBeSuppressTrapping ( { __proto__ : tagRecordA2 } ) ;
335
- const farObjA2 = hardenToBeSuppressTrapping ( { __proto__ : farObjProtoA2 } ) ;
298
+ const farObjProtoA2 = suppressTrapping ( { __proto__ : tagRecordA2 } ) ;
299
+ const farObjA2 = suppressTrapping ( { __proto__ : farObjProtoA2 } ) ;
336
300
t . throws (
337
301
( ) => passStyleOf ( farObjA2 ) ,
338
302
{ message : unusualTagRecordProtoMessage } ,
@@ -346,10 +310,10 @@ test('passStyleOf testing remotables', t => {
346
310
const fauxTagRecordB = harden (
347
311
makeTagishRecord ( 'Alleged: manually constructed' , harden ( { } ) ) ,
348
312
) ;
349
- const farObjProtoB = hardenToBeSuppressTrapping ( {
313
+ const farObjProtoB = suppressTrapping ( {
350
314
__proto__ : fauxTagRecordB ,
351
315
} ) ;
352
- const farObjB = hardenToBeSuppressTrapping ( { __proto__ : farObjProtoB } ) ;
316
+ const farObjB = suppressTrapping ( { __proto__ : farObjProtoB } ) ;
353
317
t . throws ( ( ) => passStyleOf ( farObjB ) , {
354
318
message :
355
319
'cannot serialize Remotables with non-methods like "Symbol(passStyle)" in "[Alleged: manually constructed]"' ,
@@ -360,7 +324,7 @@ test('passStyleOf testing remotables', t => {
360
324
) ;
361
325
Object . defineProperty ( farObjProtoWithExtra , 'extra' , { value : ( ) => { } } ) ;
362
326
harden ( farObjProtoWithExtra ) ;
363
- const badFarObjExtraProtoProp = hardenToBeSuppressTrapping ( {
327
+ const badFarObjExtraProtoProp = suppressTrapping ( {
364
328
__proto__ : farObjProtoWithExtra ,
365
329
} ) ;
366
330
t . throws ( ( ) => passStyleOf ( badFarObjExtraProtoProp ) , {
@@ -425,8 +389,7 @@ test('remotables - safety from the gibson042 attack', t => {
425
389
* explicitly make this non-trapping, which we cannot yet express.
426
390
* @see https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md
427
391
*/
428
- const makeInput = ( ) =>
429
- freezeToBeSuppressTrapping ( { __proto__ : mercurialProto } ) ;
392
+ const makeInput = ( ) => suppressTrapping ( { __proto__ : mercurialProto } ) ;
430
393
const input1 = makeInput ( ) ;
431
394
const input2 = makeInput ( ) ;
432
395
@@ -487,12 +450,12 @@ test('Allow toStringTag overrides', t => {
487
450
t . is ( `${ alice } ` , '[object DebugName: Allison]' ) ;
488
451
t . is ( `${ q ( alice ) } ` , '"[DebugName: Allison]"' ) ;
489
452
490
- const carol = hardenToBeSuppressTrapping ( { __proto__ : alice } ) ;
453
+ const carol = suppressTrapping ( { __proto__ : alice } ) ;
491
454
t . is ( passStyleOf ( carol ) , 'remotable' ) ;
492
455
t . is ( `${ carol } ` , '[object DebugName: Allison]' ) ;
493
456
t . is ( `${ q ( carol ) } ` , '"[DebugName: Allison]"' ) ;
494
457
495
- const bob = hardenToBeSuppressTrapping ( {
458
+ const bob = suppressTrapping ( {
496
459
__proto__ : carol ,
497
460
[ Symbol . toStringTag ] : 'DebugName: Robert' ,
498
461
} ) ;
0 commit comments