generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspec.emu
618 lines (597 loc) · 31.2 KB
/
spec.emu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: Proxy Revocation By Controllers
stage: 0
contributors:
- Alexander J. Vincent
- Bradley Farias
- Mark S. Miller
- Jack Works
</pre>
<emu-clause id="sec-ordinary-and-exotic-objects-behaviours" number="10">
<h1>Ordinary and Exotic Objects Behaviours</h1>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots" number="5">
<h1>Proxy Object Internal Methods and Internal Slots</h1>
<p>The [[ProxyHandler]]<ins>, [[ProxyRevokeSignal]]</ins> and [[ProxyTarget]] internal slots of a Proxy object are always initialized when the object is created and typically may not be modified. Some Proxy objects are created in a manner that permits them to be subsequently <em>revoked</em>. When a proxy is revoked, its [[ProxyHandler]]<ins>, [[ProxyRevokeSignal]]</ins> and [[ProxyTarget]] internal slots are set to *null* causing subsequent invocations of internal methods on that Proxy object to throw a *TypeError* exception.</p>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-getprototypeof" type="internal method">
<h1>[[GetPrototypeOf]] ( ): either a normal completion containing either an Object or *null*, or a throw completion</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"getPrototypeOf"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[GetPrototypeOf]]</emu-meta>().
1. Let _handlerProto_ be ? Call(_trap_, _handler_, « _target_ »).
1. If _handlerProto_ is not an Object and _handlerProto_ is not *null*, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *true*, return _handlerProto_.
1. Let _targetProto_ be ? <emu-meta effects="user-code">_target_.[[GetPrototypeOf]]</emu-meta>().
1. If SameValue(_handlerProto_, _targetProto_) is *false*, throw a *TypeError* exception.
1. Return _handlerProto_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v" type="internal method">
<h1>
[[SetPrototypeOf]] (
_V_: an Object or *null*,
): either a normal completion containing a Boolean or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"setPrototypeOf"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[SetPrototypeOf]]</emu-meta>(_V_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_, _V_ »)).
1. If _booleanTrapResult_ is *false*, return *false*.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *true*, return *true*.
1. Let _targetProto_ be ? <emu-meta effects="user-code">_target_.[[GetPrototypeOf]]</emu-meta>().
1. If SameValue(_V_, _targetProto_) is *false*, throw a *TypeError* exception.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-isextensible" type="internal method">
<h1>[[IsExtensible]] ( ): either a normal completion containing a Boolean or a throw completion</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"isExtensible"*).
1. If _trap_ is *undefined*, then
1. Return ? IsExtensible(_target_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_ »)).
1. Let _targetResult_ be ? IsExtensible(_target_).
1. If SameValue(_booleanTrapResult_, _targetResult_) is *false*, throw a *TypeError* exception.
1. Return _booleanTrapResult_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-preventextensions" type="internal method">
<h1>[[PreventExtensions]] ( ): either a normal completion containing a Boolean or a throw completion</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"preventExtensions"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[PreventExtensions]]()</emu-meta>.
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_ »)).
1. If _booleanTrapResult_ is *true*, then
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *true*, throw a *TypeError* exception.
1. Return _booleanTrapResult_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p" type="internal method">
<h1>
[[GetOwnProperty]] (
_P_: a property key,
): either a normal completion containing either a Property Descriptor or *undefined*, or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"getOwnPropertyDescriptor"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. Let _trapResultObj_ be ? Call(_trap_, _handler_, « _target_, _P_ »).
1. If _trapResultObj_ is not an Object and _trapResultObj_ is not *undefined*, throw a *TypeError* exception.
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. If _trapResultObj_ is *undefined*, then
1. If _targetDesc_ is *undefined*, return *undefined*.
1. If _targetDesc_.[[Configurable]] is *false*, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *false*, throw a *TypeError* exception.
1. Return *undefined*.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. Let _resultDesc_ be ? ToPropertyDescriptor(_trapResultObj_).
1. Perform CompletePropertyDescriptor(_resultDesc_).
1. Let _valid_ be IsCompatiblePropertyDescriptor(_extensibleTarget_, _resultDesc_, _targetDesc_).
1. If _valid_ is *false*, throw a *TypeError* exception.
1. If _resultDesc_.[[Configurable]] is *false*, then
1. If _targetDesc_ is *undefined* or _targetDesc_.[[Configurable]] is *true*, then
1. Throw a *TypeError* exception.
1. If _resultDesc_ has a [[Writable]] field and _resultDesc_.[[Writable]] is *false*, then
1. Assert: _targetDesc_ has a [[Writable]] field.
1. If _targetDesc_.[[Writable]] is *true*, throw a *TypeError* exception.
1. Return _resultDesc_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc" type="internal method">
<h1>
[[DefineOwnProperty]] (
_P_: a property key,
_Desc_: a Property Descriptor,
): either a normal completion containing a Boolean or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"defineProperty"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[DefineOwnProperty]]</emu-meta>(_P_, _Desc_).
1. Let _descObj_ be FromPropertyDescriptor(_Desc_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_, _P_, _descObj_ »)).
1. If _booleanTrapResult_ is *false*, return *false*.
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _Desc_ has a [[Configurable]] field and if _Desc_.[[Configurable]] is *false*, then
1. Let _settingConfigFalse_ be *true*.
1. Else, let _settingConfigFalse_ be *false*.
1. If _targetDesc_ is *undefined*, then
1. If _extensibleTarget_ is *false*, throw a *TypeError* exception.
1. If _settingConfigFalse_ is *true*, throw a *TypeError* exception.
1. Else,
1. If IsCompatiblePropertyDescriptor(_extensibleTarget_, _Desc_, _targetDesc_) is *false*, throw a *TypeError* exception.
1. If _settingConfigFalse_ is *true* and _targetDesc_.[[Configurable]] is *true*, throw a *TypeError* exception.
1. If IsDataDescriptor(_targetDesc_) is *true*, _targetDesc_.[[Configurable]] is *false*, and _targetDesc_.[[Writable]] is *true*, then
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *false*, throw a *TypeError* exception.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p" type="internal method">
<h1>
[[HasProperty]] (
_P_: a property key,
): either a normal completion containing a Boolean or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"has"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[HasProperty]]</emu-meta>(_P_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_, _P_ »)).
1. If _booleanTrapResult_ is *false*, then
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. If _targetDesc_ is not *undefined*, then
1. If _targetDesc_.[[Configurable]] is *false*, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *false*, throw a *TypeError* exception.
1. Return _booleanTrapResult_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver" type="internal method">
<h1>
[[Get]] (
_P_: a property key,
_Receiver_: an ECMAScript language value,
): either a normal completion containing an ECMAScript language value or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"get"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[Get]]</emu-meta>(_P_, _Receiver_).
1. Let _trapResult_ be ? Call(_trap_, _handler_, « _target_, _P_, _Receiver_ »).
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. If _targetDesc_ is not *undefined* and _targetDesc_.[[Configurable]] is *false*, then
1. If IsDataDescriptor(_targetDesc_) is *true* and _targetDesc_.[[Writable]] is *false*, then
1. If SameValue(_trapResult_, _targetDesc_.[[Value]]) is *false*, throw a *TypeError* exception.
1. If IsAccessorDescriptor(_targetDesc_) is *true* and _targetDesc_.[[Get]] is *undefined*, then
1. If _trapResult_ is not *undefined*, throw a *TypeError* exception.
1. Return _trapResult_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver" type="internal method">
<h1>
[[Set]] (
_P_: a property key,
_V_: an ECMAScript language value,
_Receiver_: an ECMAScript language value,
): either a normal completion containing a Boolean or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"set"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[Set]]</emu-meta>(_P_, _V_, _Receiver_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_, _P_, _V_, _Receiver_ »)).
1. If _booleanTrapResult_ is *false*, return *false*.
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. If _targetDesc_ is not *undefined* and _targetDesc_.[[Configurable]] is *false*, then
1. If IsDataDescriptor(_targetDesc_) is *true* and _targetDesc_.[[Writable]] is *false*, then
1. If SameValue(_V_, _targetDesc_.[[Value]]) is *false*, throw a *TypeError* exception.
1. If IsAccessorDescriptor(_targetDesc_) is *true*, then
1. If _targetDesc_.[[Set]] is *undefined*, throw a *TypeError* exception.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-delete-p" type="internal method">
<h1>
[[Delete]] (
_P_: a property key,
): either a normal completion containing a Boolean or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"deleteProperty"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[Delete]]</emu-meta>(_P_).
1. Let _booleanTrapResult_ be ToBoolean(? Call(_trap_, _handler_, « _target_, _P_ »)).
1. If _booleanTrapResult_ is *false*, return *false*.
1. Let _targetDesc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_P_).
1. If _targetDesc_ is *undefined*, return *true*.
1. If _targetDesc_.[[Configurable]] is *false*, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. If _extensibleTarget_ is *false*, throw a *TypeError* exception.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys" type="internal method">
<h1>[[OwnPropertyKeys]] ( ): either a normal completion containing a List of property keys or a throw completion</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"ownKeys"*).
1. If _trap_ is *undefined*, then
1. Return ? <emu-meta effects="user-code">_target_.[[OwnPropertyKeys]]()</emu-meta>.
1. Let _trapResultArray_ be ? Call(_trap_, _handler_, « _target_ »).
1. Let _trapResult_ be ? CreateListFromArrayLike(_trapResultArray_, « String, Symbol »).
1. If _trapResult_ contains any duplicate entries, throw a *TypeError* exception.
1. Let _extensibleTarget_ be ? IsExtensible(_target_).
1. Let _targetKeys_ be ? <emu-meta effects="user-code">_target_.[[OwnPropertyKeys]]()</emu-meta>.
1. Assert: _targetKeys_ is a List of property keys.
1. Assert: _targetKeys_ contains no duplicate entries.
1. Let _targetConfigurableKeys_ be a new empty List.
1. Let _targetNonconfigurableKeys_ be a new empty List.
1. For each element _key_ of _targetKeys_, do
1. Let _desc_ be ? <emu-meta effects="user-code">_target_.[[GetOwnProperty]]</emu-meta>(_key_).
1. If _desc_ is not *undefined* and _desc_.[[Configurable]] is *false*, then
1. Append _key_ as an element of _targetNonconfigurableKeys_.
1. Else,
1. Append _key_ as an element of _targetConfigurableKeys_.
1. If _extensibleTarget_ is *true* and _targetNonconfigurableKeys_ is empty, then
1. Return _trapResult_.
1. Let _uncheckedResultKeys_ be a List whose elements are the elements of _trapResult_.
1. For each element _key_ of _targetNonconfigurableKeys_, do
1. If _key_ is not an element of _uncheckedResultKeys_, throw a *TypeError* exception.
1. Remove _key_ from _uncheckedResultKeys_.
1. If _extensibleTarget_ is *true*, return _trapResult_.
1. For each element _key_ of _targetConfigurableKeys_, do
1. If _key_ is not an element of _uncheckedResultKeys_, throw a *TypeError* exception.
1. Remove _key_ from _uncheckedResultKeys_.
1. If _uncheckedResultKeys_ is not empty, throw a *TypeError* exception.
1. Return _trapResult_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist" type="internal method">
<h1>
[[Call]] (
_thisArgument_: an ECMAScript language value,
_argumentsList_: a List of ECMAScript language values,
): either a normal completion containing an ECMAScript language value or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Let _trap_ be ? GetMethod(_handler_, *"apply"*).
1. If _trap_ is *undefined*, then
1. Return ? Call(_target_, _thisArgument_, _argumentsList_).
1. Let _argArray_ be CreateArrayFromList(_argumentsList_).
1. Return ? Call(_trap_, _handler_, « _target_, _thisArgument_, _argArray_ »).
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget" type="internal method">
<h1>
[[Construct]] (
_argumentsList_: a List of ECMAScript language values,
_newTarget_: a constructor,
): either a normal completion containing an Object or a throw completion
</h1>
<dl class="header">
<dt>for</dt>
<dd>a Proxy exotic object _O_</dd>
</dl>
<emu-alg>
1. <ins>Perform ? EnsureProxyAlive(_O_)</ins>.
1. Let _handler_ be _O_.[[ProxyHandler]].
1. <del>If _handler_ is *null*, throw a *TypeError* exception.</del>
1. Assert: _handler_ is an Object.
1. Let _target_ be _O_.[[ProxyTarget]].
1. Assert: IsConstructor(_target_) is *true*.
1. Let _trap_ be ? GetMethod(_handler_, *"construct"*).
1. If _trap_ is *undefined*, then
1. Return ? Construct(_target_, _argumentsList_, _newTarget_).
1. Let _argArray_ be CreateArrayFromList(_argumentsList_).
1. Let _newObj_ be ? Call(_trap_, _handler_, « _target_, _argArray_, _newTarget_ »).
1. If _newObj_ is not an Object, throw a *TypeError* exception.
1. Return _newObj_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxycreate" type="abstract operation">
<h1>
ProxyCreate (
_target_: an ECMAScript language value,
_handler_: an ECMAScript language value,
<ins>_options_: an ECMAScript language value,</ins>
): either a normal completion containing a Proxy exotic object or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It is used to specify the creation of new Proxy objects.</dd>
</dl>
<emu-alg>
1. If _target_ is not an Object, throw a *TypeError* exception.
1. If _handler_ is not an Object, throw a *TypeError* exception.
1. <ins>Let _revokeSignal_ be *null*.</ins>
1. <ins>If _options_ is an Object, then</ins>
1. <ins>Let _signal_ be ? Get(_options_, "signal").</ins>
1. <ins>If _signal_ is a Symbol, then</ins>
1. <ins>Let _found_ be *false*.</ins>
1. <ins>For each element _e_ of the GlobalProxySignalRegistry List, do</ins>
1. <ins>If SameValue(_e_.[[Symbol]], _signal_) is *true*, then</ins>
1. <ins>Set _found_ to *true*.</ins>
1. <ins>If _e_.[[Revoked]] is *true*, then</ins>
1. <ins>Throw a *TypeError* exception.</ins>
1. <ins>Set _revokeSignal_ to _signal_.</ins>
1. <ins>If _found_ is *false*, throw a *TypeError* exception.</ins>
1. <ins>Else if _signal_ is not *undefined*, then</ins>
1. <ins>Throw a *TypeError* exception.</ins>
1. <ins>Else if _options_ is not *undefined*, then</ins>
1. <ins>Throw a *TypeError* exception.</ins>
1. Let _P_ be MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]], [[ProxyRevokeSignal]] »).
1. Set _P_'s essential internal methods, except for [[Call]] and [[Construct]], to the definitions specified in <emu-xref href="#sec-proxy-object-internal-methods-and-internal-slots"></emu-xref>.
1. If IsCallable(_target_) is *true*, then
1. Set _P_.[[Call]] as specified in <emu-xref href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist"></emu-xref>.
1. If IsConstructor(_target_) is *true*, then
1. Set _P_.[[Construct]] as specified in <emu-xref href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget"></emu-xref>.
1. Set _P_.[[ProxyTarget]] to _target_.
1. Set _P_.[[ProxyHandler]] to _handler_.
1. <ins>Set _P_.[[ProxyRevokeSignal]] to _revokeSignal_.</ins>
1. Return _P_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-ensure-proxy-alive" type="abstract operation">
<h1>
<ins>
EnsureProxyAlive (
_object_: a Proxy,
): either a normal completion containing ~unused~ or an abrupt completion
</ins>
</h1>
<dl class="header">
<dt>description</dt>
<dd>It is used make sure the proxy is not revoked.</dd>
</dl>
<emu-alg>
1. If _object_.[[ProxyHandler]] is *null*, throw a *TypeError* exception.
1. If _object_.[[ProxyTarget]] is *null*, throw a *TypeError* exception.
1. If _object_.[[ProxyRevokeSignal]] is not *null*, then
1. For each element _e_ of the GlobalProxySignalRegistry List, do
1. If SameValue(_e_.[[Symbol]], _object_.[[ProxyRevokeSignal]]) is *true* and _e_.[[Revoked]] is *true*, then
1. Set _object_.[[ProxyTarget]] to *null*.
1. Set _object_.[[ProxyHandler]] to *null*.
1. Set _object_.[[ProxyRevokeSignal]] to *null*.
1. Throw a *TypeError* exception.
1. Return ~unused~.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-reflect" number="28">
<h1>Reflection</h1>
<emu-clause id="sec-proxy-objects" number="2">
<h1>Proxy Objects</h1>
<emu-clause id="sec-proxy-constructor">
<h1>The Proxy Constructor</h1>
<p>The Proxy constructor:</p>
<ul>
<li>is <dfn>%Proxy%</dfn>.</li>
<li>is the initial value of the *"Proxy"* property of the global object.</li>
<li>creates and initializes a new Proxy object when called as a constructor.</li>
<li>is not intended to be called as a function and will throw an exception when called in that manner.</li>
</ul>
<emu-clause id="sec-proxy-target-handler">
<h1>Proxy ( _target_, _handler_<ins>, _options_</ins> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg>
1. If NewTarget is *undefined*, throw a *TypeError* exception.
1. Return ? ProxyCreate(_target_, _handler_<ins>, _options_</ins>).
</emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-proxy-constructor">
<h1>Properties of the Proxy Constructor</h1>
<p>The Proxy constructor:</p>
<ul>
<li>has a [[Prototype]] internal slot whose value is %Function.prototype%.</li>
<li>does not have a *"prototype"* property because Proxy objects do not have a [[Prototype]] internal slot that requires initialization.</li>
<li>has the following properties:</li>
</ul>
<emu-clause id="sec-proxy.revocable" oldids="sec-proxy-revocation-functions">
<h1>Proxy.revocable ( _target_, _handler_<ins>, _options_</ins> )</h1>
<p>This function creates a revocable Proxy object.</p>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _p_ be ? ProxyCreate(_target_, _handler_<ins>, _options_</ins>).
1. Let _revokerClosure_ be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
1. Let _F_ be the active function object.
1. Let _p_ be _F_.[[RevocableProxy]].
1. If _p_ is *null*, return *undefined*.
1. Set _F_.[[RevocableProxy]] to *null*.
1. Assert: _p_ is a Proxy object.
1. Set _p_.[[ProxyTarget]] to *null*.
1. Set _p_.[[ProxyHandler]] to *null*.
1. Return *undefined*.
1. Let _revoker_ be CreateBuiltinFunction(_revokerClosure_, 0, *""*, « [[RevocableProxy]] »).
1. Set _revoker_.[[RevocableProxy]] to _p_.
1. Let _result_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"proxy"*, _p_).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"revoke"*, _revoker_).
1. Return _result_.
</emu-alg>
</emu-clause>
<emu-clause id="sec-proxy.createsignal">
<h1><ins>Proxy.createSignal ( )</ins></h1>
<p>This function creates a symbol that can be used to revoke Proxies.</p>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _symbol_ be a new unique Symbol value whose [[Description]] value is *undefined*.
1. Append the Record { [[Symbol]]: _symbol_, [[Revoked]]: *false* } to the GlobalProxySignalRegistry List.
1. Return _symbol_.
</emu-alg>
<p>The <dfn>GlobalProxySignalRegistry</dfn> is a List that is globally available. It is shared by all realms. Prior to the evaluation of any ECMAScript code, it is initialized as a new empty List. Elements of the GlobalProxySignalRegistry are Records with the structure defined in Table 1.</p>
<emu-table id="table-globalproxysignalregistry-record-fields" caption="GlobalProxySignalRegistry Record Fields">
<table>
<tbody>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Usage
</th>
</tr>
<tr>
<td>
[[Symbol]]
</td>
<td>
a Symbol
</td>
<td>
A symbol key used to revoke a Proxy across any Realm.
</td>
</tr>
<tr>
<td>
[[Revoked]]
</td>
<td>
a Boolean
</td>
<td>
A boolean that indicate if this signal is revoked.
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>
<emu-clause id="sec-proxy.finalizeSignal">
<h1><ins>Proxy.finalizeSignal ( _signal_ )</ins></h1>
<p>This function revoke all Proxied that [[ProxyRevokeSignal]] is _signal_.</p>
<p>It performs the following steps when called:</p>
<emu-alg>
1. For each element _e_ of the GlobalProxySignalRegistry List, do
1. If SameValue(_e_.[[Symbol]], _signal_) is *true*, then
1. Set _e_.[[Revoked]] to *true*.
1. Return *undefined*.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>