-
Notifications
You must be signed in to change notification settings - Fork 72
/
permits.js
1650 lines (1480 loc) · 41.8 KB
/
permits.js
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable no-restricted-globals */
/* eslint max-lines: 0 */
import { arrayPush } from './commons.js';
/** @import {GenericErrorConstructor} from '../types.js' */
/**
* @file Exports {@code whitelist}, a recursively defined
* JSON record enumerating all intrinsics and their properties
* according to ECMA specs.
*
* @author JF Paradis
* @author Mark S. Miller
*/
/**
* constantProperties
* non-configurable, non-writable data properties of all global objects.
* Must be powerless.
* Maps from property name to the actual value
*/
export const constantProperties = {
// *** Value Properties of the Global Object
Infinity,
NaN,
undefined,
};
/**
* universalPropertyNames
* Properties of all global objects.
* Must be powerless.
* Maps from property name to the intrinsic name in the whitelist.
*/
export const universalPropertyNames = {
// *** Function Properties of the Global Object
isFinite: 'isFinite',
isNaN: 'isNaN',
parseFloat: 'parseFloat',
parseInt: 'parseInt',
decodeURI: 'decodeURI',
decodeURIComponent: 'decodeURIComponent',
encodeURI: 'encodeURI',
encodeURIComponent: 'encodeURIComponent',
// *** Constructor Properties of the Global Object
Array: 'Array',
ArrayBuffer: 'ArrayBuffer',
BigInt: 'BigInt',
BigInt64Array: 'BigInt64Array',
BigUint64Array: 'BigUint64Array',
Boolean: 'Boolean',
DataView: 'DataView',
EvalError: 'EvalError',
// https://github.com/tc39/proposal-float16array
Float16Array: 'Float16Array',
Float32Array: 'Float32Array',
Float64Array: 'Float64Array',
Int8Array: 'Int8Array',
Int16Array: 'Int16Array',
Int32Array: 'Int32Array',
Map: 'Map',
Number: 'Number',
Object: 'Object',
Promise: 'Promise',
Proxy: 'Proxy',
RangeError: 'RangeError',
ReferenceError: 'ReferenceError',
Set: 'Set',
String: 'String',
SyntaxError: 'SyntaxError',
TypeError: 'TypeError',
Uint8Array: 'Uint8Array',
Uint8ClampedArray: 'Uint8ClampedArray',
Uint16Array: 'Uint16Array',
Uint32Array: 'Uint32Array',
URIError: 'URIError',
WeakMap: 'WeakMap',
WeakSet: 'WeakSet',
// https://github.com/tc39/proposal-iterator-helpers
Iterator: 'Iterator',
// https://github.com/tc39/proposal-async-iterator-helpers
AsyncIterator: 'AsyncIterator',
// https://github.com/endojs/endo/issues/550
AggregateError: 'AggregateError',
// *** Other Properties of the Global Object
JSON: 'JSON',
Reflect: 'Reflect',
// *** Annex B
escape: 'escape',
unescape: 'unescape',
// ESNext
// https://github.com/tc39/proposal-source-phase-imports?tab=readme-ov-file#js-module-source
ModuleSource: 'ModuleSource',
lockdown: 'lockdown',
harden: 'harden',
HandledPromise: 'HandledPromise', // TODO: Until Promise.delegate (see below).
};
/**
* initialGlobalPropertyNames
* Those found only on the initial global, i.e., the global of the
* start compartment, as well as any compartments created before lockdown.
* These may provide much of the power provided by the original.
* Maps from property name to the intrinsic name in the whitelist.
*/
export const initialGlobalPropertyNames = {
// *** Constructor Properties of the Global Object
Date: '%InitialDate%',
Error: '%InitialError%',
RegExp: '%InitialRegExp%',
// Omit `Symbol`, because we want the original to appear on the
// start compartment without passing through the whitelist mechanism, since
// we want to preserve all its properties, even if we never heard of them.
// Symbol: '%InitialSymbol%',
// *** Other Properties of the Global Object
Math: '%InitialMath%',
// ESNext
// From Error-stack proposal
// Only on initial global. No corresponding
// powerless form for other globals.
getStackString: '%InitialGetStackString%',
// TODO https://github.com/Agoric/SES-shim/issues/551
// Need initial WeakRef and FinalizationGroup in
// start compartment only.
};
/**
* sharedGlobalPropertyNames
* Those found only on the globals of new compartments created after lockdown,
* which must therefore be powerless.
* Maps from property name to the intrinsic name in the whitelist.
*/
export const sharedGlobalPropertyNames = {
// *** Constructor Properties of the Global Object
Date: '%SharedDate%',
Error: '%SharedError%',
RegExp: '%SharedRegExp%',
Symbol: '%SharedSymbol%',
// *** Other Properties of the Global Object
Math: '%SharedMath%',
};
/**
* uniqueGlobalPropertyNames
* Those made separately for each global, including the initial global
* of the start compartment.
* Maps from property name to the intrinsic name in the whitelist
* (which is currently always the same).
*/
export const uniqueGlobalPropertyNames = {
// *** Value Properties of the Global Object
globalThis: '%UniqueGlobalThis%',
// *** Function Properties of the Global Object
eval: '%UniqueEval%',
// *** Constructor Properties of the Global Object
Function: '%UniqueFunction%',
// *** Other Properties of the Global Object
// ESNext
Compartment: '%UniqueCompartment%',
// According to current agreements, eventually the Realm constructor too.
// 'Realm',
};
// All the "subclasses" of Error. These are collectively represented in the
// ECMAScript spec by the meta variable NativeError.
/** @type {GenericErrorConstructor[]} */
const NativeErrors = [
EvalError,
RangeError,
ReferenceError,
SyntaxError,
TypeError,
URIError,
// https://github.com/endojs/endo/issues/550
// Commented out to accommodate platforms prior to AggregateError.
// Instead, conditional push below.
// AggregateError,
];
if (typeof AggregateError !== 'undefined') {
// Conditional, to accommodate platforms prior to AggregateError
arrayPush(NativeErrors, AggregateError);
}
export { NativeErrors };
/**
* <p>Each JSON record enumerates the disposition of the properties on
* some corresponding intrinsic object.
*
* <p>All records are made of key-value pairs where the key
* is the property to process, and the value is the associated
* dispositions a.k.a. the "permit". Those permits can be:
* <ul>
* <li>The boolean value "false", in which case this property is
* blacklisted and simply removed. Properties not mentioned
* are also considered blacklisted and are removed.
* <li>A string value equal to a primitive ("number", "string", etc),
* in which case the property is whitelisted if its value property
* is typeof the given type. For example, {@code "Infinity"} leads to
* "number" and property values that fail {@code typeof "number"}.
* are removed.
* <li>A string value equal to an intinsic name ("ObjectPrototype",
* "Array", etc), in which case the property whitelisted if its
* value property is equal to the value of the corresponfing
* intrinsics. For example, {@code Map.prototype} leads to
* "MapPrototype" and the property is removed if its value is
* not equal to %MapPrototype%
* <li>Another record, in which case this property is simply
* whitelisted and that next record represents the disposition of
* the object which is its value. For example, {@code "Object"}
* leads to another record explaining what properties {@code
* "Object"} may have and how each such property should be treated.
*
* <p>Notes:
* <li>"[[Proto]]" is used to refer to the "[[Prototype]]" internal
* slot, which says which object this object inherits from.
* <li>"--proto--" is used to refer to the "__proto__" property name,
* which is the name of an accessor property on Object.prototype.
* In practice, it is used to access the [[Proto]] internal slot,
* but is distinct from the internal slot itself. We use
* "--proto--" rather than "__proto__" below because "__proto__"
* in an object literal is special syntax rather than a normal
* property definition.
* <li>"ObjectPrototype" is the default "[[Proto]]" (when not specified).
* <li>Constants "fn" and "getter" are used to keep the structure DRY.
* <li>Symbol properties are listed as follow:
* <li>Well-known symbols use the "@@name" form.
* <li>Registered symbols use the "RegisteredSymbol(key)" form.
* <li>Unique symbols use the "UniqueSymbol(description)" form.
*/
// Function Instances
export const FunctionInstance = {
'[[Proto]]': '%FunctionPrototype%',
length: 'number',
name: 'string',
// Do not specify "prototype" here, since only Function instances that can
// be used as a constructor have a prototype property. For constructors,
// since prototype properties are instance-specific, we define it there.
};
// AsyncFunction Instances
export const AsyncFunctionInstance = {
// This property is not mentioned in ECMA 262, but is present in V8 and
// necessary for lockdown to succeed.
'[[Proto]]': '%AsyncFunctionPrototype%',
};
// Aliases
const fn = FunctionInstance;
const asyncFn = AsyncFunctionInstance;
const getter = {
get: fn,
set: 'undefined',
};
// Possible but not encountered in the specs
// export const setter = {
// get: 'undefined',
// set: fn,
// };
const accessor = {
get: fn,
set: fn,
};
export const isAccessorPermit = permit => {
return permit === getter || permit === accessor;
};
// NativeError Object Structure
function NativeError(prototype) {
return {
// Properties of the NativeError Constructors
'[[Proto]]': '%SharedError%',
// NativeError.prototype
prototype,
};
}
function NativeErrorPrototype(constructor) {
return {
// Properties of the NativeError Prototype Objects
'[[Proto]]': '%ErrorPrototype%',
constructor,
message: 'string',
name: 'string',
// Redundantly present only on v8. Safe to remove.
toString: false,
// Superfluously present in some versions of V8.
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
cause: false,
};
}
// The TypedArray Constructors
function TypedArray(prototype) {
return {
// Properties of the TypedArray Constructors
'[[Proto]]': '%TypedArray%',
BYTES_PER_ELEMENT: 'number',
prototype,
};
}
function TypedArrayPrototype(constructor) {
return {
// Properties of the TypedArray Prototype Objects
'[[Proto]]': '%TypedArrayPrototype%',
BYTES_PER_ELEMENT: 'number',
constructor,
};
}
// Without Math.random
const CommonMath = {
E: 'number',
LN10: 'number',
LN2: 'number',
LOG10E: 'number',
LOG2E: 'number',
PI: 'number',
SQRT1_2: 'number',
SQRT2: 'number',
'@@toStringTag': 'string',
abs: fn,
acos: fn,
acosh: fn,
asin: fn,
asinh: fn,
atan: fn,
atanh: fn,
atan2: fn,
cbrt: fn,
ceil: fn,
clz32: fn,
cos: fn,
cosh: fn,
exp: fn,
expm1: fn,
floor: fn,
fround: fn,
hypot: fn,
imul: fn,
log: fn,
log1p: fn,
log10: fn,
log2: fn,
max: fn,
min: fn,
pow: fn,
round: fn,
sign: fn,
sin: fn,
sinh: fn,
sqrt: fn,
tan: fn,
tanh: fn,
trunc: fn,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
idiv: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
idivmod: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
imod: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
imuldiv: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
irem: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
mod: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505
irandom: false,
};
export const permitted = {
// ECMA https://tc39.es/ecma262
// The intrinsics object has no prototype to avoid conflicts.
'[[Proto]]': null,
// %ThrowTypeError%
'%ThrowTypeError%': fn,
// *** The Global Object
// *** Value Properties of the Global Object
Infinity: 'number',
NaN: 'number',
undefined: 'undefined',
// *** Function Properties of the Global Object
// eval
'%UniqueEval%': fn,
isFinite: fn,
isNaN: fn,
parseFloat: fn,
parseInt: fn,
decodeURI: fn,
decodeURIComponent: fn,
encodeURI: fn,
encodeURIComponent: fn,
// *** Fundamental Objects
Object: {
// Properties of the Object Constructor
'[[Proto]]': '%FunctionPrototype%',
assign: fn,
create: fn,
defineProperties: fn,
defineProperty: fn,
entries: fn,
freeze: fn,
fromEntries: fn,
getOwnPropertyDescriptor: fn,
getOwnPropertyDescriptors: fn,
getOwnPropertyNames: fn,
getOwnPropertySymbols: fn,
getPrototypeOf: fn,
hasOwn: fn,
is: fn,
isExtensible: fn,
isFrozen: fn,
isSealed: fn,
keys: fn,
preventExtensions: fn,
prototype: '%ObjectPrototype%',
seal: fn,
setPrototypeOf: fn,
values: fn,
// https://github.com/tc39/proposal-array-grouping
groupBy: fn,
// Seen on QuickJS
__getClass: false,
},
'%ObjectPrototype%': {
// Properties of the Object Prototype Object
'[[Proto]]': null,
constructor: 'Object',
hasOwnProperty: fn,
isPrototypeOf: fn,
propertyIsEnumerable: fn,
toLocaleString: fn,
toString: fn,
valueOf: fn,
// Annex B: Additional Properties of the Object.prototype Object
// See note in header about the difference between [[Proto]] and --proto--
// special notations.
'--proto--': accessor,
__defineGetter__: fn,
__defineSetter__: fn,
__lookupGetter__: fn,
__lookupSetter__: fn,
},
'%UniqueFunction%': {
// Properties of the Function Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%FunctionPrototype%',
},
'%InertFunction%': {
'[[Proto]]': '%FunctionPrototype%',
prototype: '%FunctionPrototype%',
},
'%FunctionPrototype%': {
apply: fn,
bind: fn,
call: fn,
constructor: '%InertFunction%',
toString: fn,
'@@hasInstance': fn,
// proposed but not yet std. To be removed if there
caller: false,
// proposed but not yet std. To be removed if there
arguments: false,
// Seen on QuickJS. TODO grab getter for use by console
fileName: false,
// Seen on QuickJS. TODO grab getter for use by console
lineNumber: false,
},
Boolean: {
// Properties of the Boolean Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%BooleanPrototype%',
},
'%BooleanPrototype%': {
constructor: 'Boolean',
toString: fn,
valueOf: fn,
},
'%SharedSymbol%': {
// Properties of the Symbol Constructor
'[[Proto]]': '%FunctionPrototype%',
asyncDispose: 'symbol',
asyncIterator: 'symbol',
dispose: 'symbol',
for: fn,
hasInstance: 'symbol',
isConcatSpreadable: 'symbol',
iterator: 'symbol',
keyFor: fn,
match: 'symbol',
matchAll: 'symbol',
prototype: '%SymbolPrototype%',
replace: 'symbol',
search: 'symbol',
species: 'symbol',
split: 'symbol',
toPrimitive: 'symbol',
toStringTag: 'symbol',
unscopables: 'symbol',
// Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
useSimple: false,
// Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
useSetter: false,
// Seen on QuickJS
operatorSet: false,
},
'%SymbolPrototype%': {
// Properties of the Symbol Prototype Object
constructor: '%SharedSymbol%',
description: getter,
toString: fn,
valueOf: fn,
'@@toPrimitive': fn,
'@@toStringTag': 'string',
},
'%InitialError%': {
// Properties of the Error Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%ErrorPrototype%',
// Non standard, v8 only, used by tap
captureStackTrace: fn,
// Non standard, v8 only, used by tap, tamed to accessor
stackTraceLimit: accessor,
// Non standard, v8 only, used by several, tamed to accessor
prepareStackTrace: accessor,
},
'%SharedError%': {
// Properties of the Error Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%ErrorPrototype%',
// Non standard, v8 only, used by tap
captureStackTrace: fn,
// Non standard, v8 only, used by tap, tamed to accessor
stackTraceLimit: accessor,
// Non standard, v8 only, used by several, tamed to accessor
prepareStackTrace: accessor,
},
'%ErrorPrototype%': {
constructor: '%SharedError%',
message: 'string',
name: 'string',
toString: fn,
// proposed de-facto, assumed TODO
// Seen on FF Nightly 88.0a1
at: false,
// Seen on FF and XS
stack: accessor,
// Superfluously present in some versions of V8.
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
cause: false,
},
// NativeError
EvalError: NativeError('%EvalErrorPrototype%'),
RangeError: NativeError('%RangeErrorPrototype%'),
ReferenceError: NativeError('%ReferenceErrorPrototype%'),
SyntaxError: NativeError('%SyntaxErrorPrototype%'),
TypeError: NativeError('%TypeErrorPrototype%'),
URIError: NativeError('%URIErrorPrototype%'),
// https://github.com/endojs/endo/issues/550
AggregateError: NativeError('%AggregateErrorPrototype%'),
'%EvalErrorPrototype%': NativeErrorPrototype('EvalError'),
'%RangeErrorPrototype%': NativeErrorPrototype('RangeError'),
'%ReferenceErrorPrototype%': NativeErrorPrototype('ReferenceError'),
'%SyntaxErrorPrototype%': NativeErrorPrototype('SyntaxError'),
'%TypeErrorPrototype%': NativeErrorPrototype('TypeError'),
'%URIErrorPrototype%': NativeErrorPrototype('URIError'),
// https://github.com/endojs/endo/issues/550
'%AggregateErrorPrototype%': NativeErrorPrototype('AggregateError'),
// *** Numbers and Dates
Number: {
// Properties of the Number Constructor
'[[Proto]]': '%FunctionPrototype%',
EPSILON: 'number',
isFinite: fn,
isInteger: fn,
isNaN: fn,
isSafeInteger: fn,
MAX_SAFE_INTEGER: 'number',
MAX_VALUE: 'number',
MIN_SAFE_INTEGER: 'number',
MIN_VALUE: 'number',
NaN: 'number',
NEGATIVE_INFINITY: 'number',
parseFloat: fn,
parseInt: fn,
POSITIVE_INFINITY: 'number',
prototype: '%NumberPrototype%',
},
'%NumberPrototype%': {
// Properties of the Number Prototype Object
constructor: 'Number',
toExponential: fn,
toFixed: fn,
toLocaleString: fn,
toPrecision: fn,
toString: fn,
valueOf: fn,
},
BigInt: {
// Properties of the BigInt Constructor
'[[Proto]]': '%FunctionPrototype%',
asIntN: fn,
asUintN: fn,
prototype: '%BigIntPrototype%',
// See https://github.com/Moddable-OpenSource/moddable/issues/523
bitLength: false,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
fromArrayBuffer: false,
// Seen on QuickJS
tdiv: false,
// Seen on QuickJS
fdiv: false,
// Seen on QuickJS
cdiv: false,
// Seen on QuickJS
ediv: false,
// Seen on QuickJS
tdivrem: false,
// Seen on QuickJS
fdivrem: false,
// Seen on QuickJS
cdivrem: false,
// Seen on QuickJS
edivrem: false,
// Seen on QuickJS
sqrt: false,
// Seen on QuickJS
sqrtrem: false,
// Seen on QuickJS
floorLog2: false,
// Seen on QuickJS
ctz: false,
},
'%BigIntPrototype%': {
constructor: 'BigInt',
toLocaleString: fn,
toString: fn,
valueOf: fn,
'@@toStringTag': 'string',
},
'%InitialMath%': {
...CommonMath,
// `%InitialMath%.random()` has the standard unsafe behavior
random: fn,
},
'%SharedMath%': {
...CommonMath,
// `%SharedMath%.random()` is tamed to always throw
random: fn,
},
'%InitialDate%': {
// Properties of the Date Constructor
'[[Proto]]': '%FunctionPrototype%',
now: fn,
parse: fn,
prototype: '%DatePrototype%',
UTC: fn,
},
'%SharedDate%': {
// Properties of the Date Constructor
'[[Proto]]': '%FunctionPrototype%',
// `%SharedDate%.now()` is tamed to always throw
now: fn,
parse: fn,
prototype: '%DatePrototype%',
UTC: fn,
},
'%DatePrototype%': {
constructor: '%SharedDate%',
getDate: fn,
getDay: fn,
getFullYear: fn,
getHours: fn,
getMilliseconds: fn,
getMinutes: fn,
getMonth: fn,
getSeconds: fn,
getTime: fn,
getTimezoneOffset: fn,
getUTCDate: fn,
getUTCDay: fn,
getUTCFullYear: fn,
getUTCHours: fn,
getUTCMilliseconds: fn,
getUTCMinutes: fn,
getUTCMonth: fn,
getUTCSeconds: fn,
setDate: fn,
setFullYear: fn,
setHours: fn,
setMilliseconds: fn,
setMinutes: fn,
setMonth: fn,
setSeconds: fn,
setTime: fn,
setUTCDate: fn,
setUTCFullYear: fn,
setUTCHours: fn,
setUTCMilliseconds: fn,
setUTCMinutes: fn,
setUTCMonth: fn,
setUTCSeconds: fn,
toDateString: fn,
toISOString: fn,
toJSON: fn,
toLocaleDateString: fn,
toLocaleString: fn,
toLocaleTimeString: fn,
toString: fn,
toTimeString: fn,
toUTCString: fn,
valueOf: fn,
'@@toPrimitive': fn,
// Annex B: Additional Properties of the Date.prototype Object
getYear: fn,
setYear: fn,
toGMTString: fn,
},
// Text Processing
String: {
// Properties of the String Constructor
'[[Proto]]': '%FunctionPrototype%',
fromCharCode: fn,
fromCodePoint: fn,
prototype: '%StringPrototype%',
raw: fn,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
fromArrayBuffer: false,
},
'%StringPrototype%': {
// Properties of the String Prototype Object
length: 'number',
at: fn,
charAt: fn,
charCodeAt: fn,
codePointAt: fn,
concat: fn,
constructor: 'String',
endsWith: fn,
includes: fn,
indexOf: fn,
lastIndexOf: fn,
localeCompare: fn,
match: fn,
matchAll: fn,
normalize: fn,
padEnd: fn,
padStart: fn,
repeat: fn,
replace: fn,
replaceAll: fn, // ES2021
search: fn,
slice: fn,
split: fn,
startsWith: fn,
substring: fn,
toLocaleLowerCase: fn,
toLocaleUpperCase: fn,
toLowerCase: fn,
toString: fn,
toUpperCase: fn,
trim: fn,
trimEnd: fn,
trimStart: fn,
valueOf: fn,
'@@iterator': fn,
// Annex B: Additional Properties of the String.prototype Object
substr: fn,
anchor: fn,
big: fn,
blink: fn,
bold: fn,
fixed: fn,
fontcolor: fn,
fontsize: fn,
italics: fn,
link: fn,
small: fn,
strike: fn,
sub: fn,
sup: fn,
trimLeft: fn,
trimRight: fn,
// See https://github.com/Moddable-OpenSource/moddable/issues/523
compare: false,
// https://github.com/tc39/proposal-is-usv-string
isWellFormed: fn,
toWellFormed: fn,
unicodeSets: fn,
// Seen on QuickJS
__quote: false,
},
'%StringIteratorPrototype%': {
'[[Proto]]': '%IteratorPrototype%',
next: fn,
'@@toStringTag': 'string',
},
'%InitialRegExp%': {
// Properties of the RegExp Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%RegExpPrototype%',
'@@species': getter,
// The https://github.com/tc39/proposal-regexp-legacy-features
// are all optional, unsafe, and omitted
input: false,
$_: false,
lastMatch: false,
'$&': false,
lastParen: false,
'$+': false,
leftContext: false,
'$`': false,
rightContext: false,
"$'": false,
$1: false,
$2: false,
$3: false,
$4: false,
$5: false,
$6: false,
$7: false,
$8: false,
$9: false,
},
'%SharedRegExp%': {
// Properties of the RegExp Constructor
'[[Proto]]': '%FunctionPrototype%',
prototype: '%RegExpPrototype%',
'@@species': getter,
},
'%RegExpPrototype%': {
// Properties of the RegExp Prototype Object
constructor: '%SharedRegExp%',
exec: fn,
dotAll: getter,
flags: getter,
global: getter,
hasIndices: getter,
ignoreCase: getter,
'@@match': fn,
'@@matchAll': fn,
multiline: getter,
'@@replace': fn,
'@@search': fn,
source: getter,
'@@split': fn,
sticky: getter,
test: fn,
toString: fn,
unicode: getter,
unicodeSets: getter,
// Annex B: Additional Properties of the RegExp.prototype Object
compile: false, // UNSAFE and suppressed.
},
'%RegExpStringIteratorPrototype%': {
// The %RegExpStringIteratorPrototype% Object
'[[Proto]]': '%IteratorPrototype%',
next: fn,
'@@toStringTag': 'string',
},
// Indexed Collections
Array: {
// Properties of the Array Constructor
'[[Proto]]': '%FunctionPrototype%',
from: fn,
isArray: fn,
of: fn,
prototype: '%ArrayPrototype%',
'@@species': getter,
// Stage 3:
// https://tc39.es/proposal-relative-indexing-method/
at: fn,
// https://tc39.es/proposal-array-from-async/
fromAsync: fn,
},
'%ArrayPrototype%': {
// Properties of the Array Prototype Object
at: fn,
length: 'number',
concat: fn,
constructor: 'Array',
copyWithin: fn,
entries: fn,
every: fn,
fill: fn,
filter: fn,
find: fn,
findIndex: fn,
flat: fn,
flatMap: fn,
forEach: fn,
includes: fn,
indexOf: fn,
join: fn,
keys: fn,
lastIndexOf: fn,
map: fn,
pop: fn,
push: fn,
reduce: fn,
reduceRight: fn,
reverse: fn,
shift: fn,
slice: fn,
some: fn,
sort: fn,
splice: fn,
toLocaleString: fn,
toString: fn,