tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

shell.js (8703B)


      1 // GENERATED, DO NOT EDIT
      2 // file: isConstructor.js
      3 // Copyright (C) 2017 André Bargull. All rights reserved.
      4 // This code is governed by the BSD license found in the LICENSE file.
      5 
      6 /*---
      7 description: |
      8    Test if a given function is a constructor function.
      9 defines: [isConstructor]
     10 features: [Reflect.construct]
     11 ---*/
     12 
     13 function isConstructor(f) {
     14    if (typeof f !== "function") {
     15      throw new Test262Error("isConstructor invoked with a non-function value");
     16    }
     17 
     18    try {
     19        Reflect.construct(function(){}, [], f);
     20    } catch (e) {
     21        return false;
     22    }
     23    return true;
     24 }
     25 
     26 // file: wellKnownIntrinsicObjects.js
     27 // Copyright (C) 2018 the V8 project authors. All rights reserved.
     28 // This code is governed by the BSD license found in the LICENSE file.
     29 /*---
     30 description: |
     31    An Array of all representable Well-Known Intrinsic Objects
     32 defines: [WellKnownIntrinsicObjects, getWellKnownIntrinsicObject]
     33 ---*/
     34 
     35 const WellKnownIntrinsicObjects = [
     36  {
     37    name: '%AggregateError%',
     38    source: 'AggregateError',
     39  },
     40  {
     41    name: '%Array%',
     42    source: 'Array',
     43  },
     44  {
     45    name: '%ArrayBuffer%',
     46    source: 'ArrayBuffer',
     47  },
     48  {
     49    name: '%ArrayIteratorPrototype%',
     50    source: 'Object.getPrototypeOf([][Symbol.iterator]())',
     51  },
     52  {
     53    // Not currently accessible to ECMAScript user code
     54    name: '%AsyncFromSyncIteratorPrototype%',
     55    source: '',
     56  },
     57  {
     58    name: '%AsyncFunction%',
     59    source: '(async function() {}).constructor',
     60  },
     61  {
     62    name: '%AsyncGeneratorFunction%',
     63    source: '(async function* () {}).constructor',
     64  },
     65  {
     66    name: '%AsyncGeneratorPrototype%',
     67    source: 'Object.getPrototypeOf(async function* () {}).prototype',
     68  },
     69  {
     70    name: '%AsyncIteratorPrototype%',
     71    source: 'Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype)',
     72  },
     73  {
     74    name: '%Atomics%',
     75    source: 'Atomics',
     76  },
     77  {
     78    name: '%BigInt%',
     79    source: 'BigInt',
     80  },
     81  {
     82    name: '%BigInt64Array%',
     83    source: 'BigInt64Array',
     84  },
     85  {
     86    name: '%BigUint64Array%',
     87    source: 'BigUint64Array',
     88  },
     89  {
     90    name: '%Boolean%',
     91    source: 'Boolean',
     92  },
     93  {
     94    name: '%DataView%',
     95    source: 'DataView',
     96  },
     97  {
     98    name: '%Date%',
     99    source: 'Date',
    100  },
    101  {
    102    name: '%decodeURI%',
    103    source: 'decodeURI',
    104  },
    105  {
    106    name: '%decodeURIComponent%',
    107    source: 'decodeURIComponent',
    108  },
    109  {
    110    name: '%encodeURI%',
    111    source: 'encodeURI',
    112  },
    113  {
    114    name: '%encodeURIComponent%',
    115    source: 'encodeURIComponent',
    116  },
    117  {
    118    name: '%Error%',
    119    source: 'Error',
    120  },
    121  {
    122    name: '%eval%',
    123    source: 'eval',
    124  },
    125  {
    126    name: '%EvalError%',
    127    source: 'EvalError',
    128  },
    129  {
    130    name: '%FinalizationRegistry%',
    131    source: 'FinalizationRegistry',
    132  },
    133  {
    134    name: '%Float32Array%',
    135    source: 'Float32Array',
    136  },
    137  {
    138    name: '%Float64Array%',
    139    source: 'Float64Array',
    140  },
    141  {
    142    // Not currently accessible to ECMAScript user code
    143    name: '%ForInIteratorPrototype%',
    144    source: '',
    145  },
    146  {
    147    name: '%Function%',
    148    source: 'Function',
    149  },
    150  {
    151    name: '%GeneratorFunction%',
    152    source: '(function* () {}).constructor',
    153  },
    154  {
    155    name: '%GeneratorPrototype%',
    156    source: 'Object.getPrototypeOf(function * () {}).prototype',
    157  },
    158  {
    159    name: '%Int8Array%',
    160    source: 'Int8Array',
    161  },
    162  {
    163    name: '%Int16Array%',
    164    source: 'Int16Array',
    165  },
    166  {
    167    name: '%Int32Array%',
    168    source: 'Int32Array',
    169  },
    170  {
    171    name: '%isFinite%',
    172    source: 'isFinite',
    173  },
    174  {
    175    name: '%isNaN%',
    176    source: 'isNaN',
    177  },
    178  {
    179    name: '%Iterator%',
    180    source: 'typeof Iterator !== "undefined" ? Iterator : Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())).constructor',
    181  },
    182  {
    183    name: '%IteratorHelperPrototype%',
    184    source: 'Object.getPrototypeOf(Iterator.from([]).drop(0))',
    185  },
    186  {
    187    name: '%JSON%',
    188    source: 'JSON',
    189  },
    190  {
    191    name: '%Map%',
    192    source: 'Map',
    193  },
    194  {
    195    name: '%MapIteratorPrototype%',
    196    source: 'Object.getPrototypeOf(new Map()[Symbol.iterator]())',
    197  },
    198  {
    199    name: '%Math%',
    200    source: 'Math',
    201  },
    202  {
    203    name: '%Number%',
    204    source: 'Number',
    205  },
    206  {
    207    name: '%Object%',
    208    source: 'Object',
    209  },
    210  {
    211    name: '%parseFloat%',
    212    source: 'parseFloat',
    213  },
    214  {
    215    name: '%parseInt%',
    216    source: 'parseInt',
    217  },
    218  {
    219    name: '%Promise%',
    220    source: 'Promise',
    221  },
    222  {
    223    name: '%Proxy%',
    224    source: 'Proxy',
    225  },
    226  {
    227    name: '%RangeError%',
    228    source: 'RangeError',
    229  },
    230  {
    231    name: '%ReferenceError%',
    232    source: 'ReferenceError',
    233  },
    234  {
    235    name: '%Reflect%',
    236    source: 'Reflect',
    237  },
    238  {
    239    name: '%RegExp%',
    240    source: 'RegExp',
    241  },
    242  {
    243    name: '%RegExpStringIteratorPrototype%',
    244    source: 'Object.getPrototypeOf(RegExp.prototype[Symbol.matchAll](""))',
    245  },
    246  {
    247    name: '%Set%',
    248    source: 'Set',
    249  },
    250  {
    251    name: '%SetIteratorPrototype%',
    252    source: 'Object.getPrototypeOf(new Set()[Symbol.iterator]())',
    253  },
    254  {
    255    name: '%SharedArrayBuffer%',
    256    source: 'SharedArrayBuffer',
    257  },
    258  {
    259    name: '%String%',
    260    source: 'String',
    261  },
    262  {
    263    name: '%StringIteratorPrototype%',
    264    source: 'Object.getPrototypeOf(new String()[Symbol.iterator]())',
    265  },
    266  {
    267    name: '%Symbol%',
    268    source: 'Symbol',
    269  },
    270  {
    271    name: '%SyntaxError%',
    272    source: 'SyntaxError',
    273  },
    274  {
    275    name: '%ThrowTypeError%',
    276    source: '(function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()',
    277  },
    278  {
    279    name: '%TypedArray%',
    280    source: 'Object.getPrototypeOf(Uint8Array)',
    281  },
    282  {
    283    name: '%TypeError%',
    284    source: 'TypeError',
    285  },
    286  {
    287    name: '%Uint8Array%',
    288    source: 'Uint8Array',
    289  },
    290  {
    291    name: '%Uint8ClampedArray%',
    292    source: 'Uint8ClampedArray',
    293  },
    294  {
    295    name: '%Uint16Array%',
    296    source: 'Uint16Array',
    297  },
    298  {
    299    name: '%Uint32Array%',
    300    source: 'Uint32Array',
    301  },
    302  {
    303    name: '%URIError%',
    304    source: 'URIError',
    305  },
    306  {
    307    name: '%WeakMap%',
    308    source: 'WeakMap',
    309  },
    310  {
    311    name: '%WeakRef%',
    312    source: 'WeakRef',
    313  },
    314  {
    315    name: '%WeakSet%',
    316    source: 'WeakSet',
    317  },
    318  {
    319    name: '%WrapForValidIteratorPrototype%',
    320    source: 'Object.getPrototypeOf(Iterator.from({ [Symbol.iterator](){ return {}; } }))',
    321  },
    322 
    323  // Extensions to well-known intrinsic objects.
    324  //
    325  // https://tc39.es/ecma262/#sec-additional-properties-of-the-global-object
    326  {
    327    name: "%escape%",
    328    source: "escape",
    329  },
    330  {
    331    name: "%unescape%",
    332    source: "unescape",
    333  },
    334 
    335  // Extensions to well-known intrinsic objects.
    336  //
    337  // https://tc39.es/ecma402/#sec-402-well-known-intrinsic-objects
    338  {
    339    name: "%Intl%",
    340    source: "Intl",
    341  },
    342  {
    343    name: "%Intl.Collator%",
    344    source: "Intl.Collator",
    345  },
    346  {
    347    name: "%Intl.DateTimeFormat%",
    348    source: "Intl.DateTimeFormat",
    349  },
    350  {
    351    name: "%Intl.DisplayNames%",
    352    source: "Intl.DisplayNames",
    353  },
    354  {
    355    name: "%Intl.DurationFormat%",
    356    source: "Intl.DurationFormat",
    357  },
    358  {
    359    name: "%Intl.ListFormat%",
    360    source: "Intl.ListFormat",
    361  },
    362  {
    363    name: "%Intl.Locale%",
    364    source: "Intl.Locale",
    365  },
    366  {
    367    name: "%Intl.NumberFormat%",
    368    source: "Intl.NumberFormat",
    369  },
    370  {
    371    name: "%Intl.PluralRules%",
    372    source: "Intl.PluralRules",
    373  },
    374  {
    375    name: "%Intl.RelativeTimeFormat%",
    376    source: "Intl.RelativeTimeFormat",
    377  },
    378  {
    379    name: "%Intl.Segmenter%",
    380    source: "Intl.Segmenter",
    381  },
    382  {
    383    name: "%IntlSegmentIteratorPrototype%",
    384    source: "Object.getPrototypeOf(new Intl.Segmenter().segment()[Symbol.iterator]())",
    385  },
    386  {
    387    name: "%IntlSegmentsPrototype%",
    388    source: "Object.getPrototypeOf(new Intl.Segmenter().segment())",
    389  },
    390 
    391  // Extensions to well-known intrinsic objects.
    392  //
    393  // https://tc39.es/proposal-temporal/#sec-well-known-intrinsic-objects
    394  {
    395    name: "%Temporal%",
    396    source: "Temporal",
    397  },
    398 ];
    399 
    400 WellKnownIntrinsicObjects.forEach((wkio) => {
    401  var actual;
    402 
    403  try {
    404    actual = new Function("return " + wkio.source)();
    405  } catch (exception) {
    406    // Nothing to do here.
    407  }
    408 
    409  wkio.value = actual;
    410 });
    411 
    412 /**
    413 * Returns a well-known intrinsic object, if the implementation provides it.
    414 * Otherwise, throws.
    415 * @param {string} key - the specification's name for the intrinsic, for example
    416 *   "%Array%"
    417 * @returns {object} the well-known intrinsic object.
    418 */
    419 function getWellKnownIntrinsicObject(key) {
    420  for (var ix = 0; ix < WellKnownIntrinsicObjects.length; ix++) {
    421    if (WellKnownIntrinsicObjects[ix].name === key) {
    422      var value = WellKnownIntrinsicObjects[ix].value;
    423      if (value !== undefined)
    424        return value;
    425      throw new Test262Error('this implementation could not obtain ' + key);
    426    }
    427  }
    428  throw new Test262Error('unknown well-known intrinsic ' + key);
    429 }