tor-browser

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

proto-from-ctor-realm.js (2787B)


      1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options
      2 // Copyright (C) 2023 Ron Buckton. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-suppressederror-constructor
      7 description: Default [[Prototype]] value derived from realm of the NewTarget.
      8 info: |
      9  SuppressedError ( error, suppressed, message )
     10 
     11  1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     12  2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%SuppressedError.prototype%", « [[ErrorData]] »).
     13  ...
     14  6. Return O.
     15 
     16  OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
     17 
     18  ...
     19  2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
     20  3. Return ObjectCreate(proto, internalSlotsList).
     21 
     22  GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
     23 
     24  ...
     25  3. Let proto be ? Get(constructor, 'prototype').
     26  4. If Type(proto) is not Object, then
     27    a. Let realm be ? GetFunctionRealm(constructor).
     28    b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
     29  5. Return proto.
     30 features: [explicit-resource-management, cross-realm, Reflect, Symbol]
     31 ---*/
     32 
     33 var other = $262.createRealm().global;
     34 var newTarget = new other.Function();
     35 var err;
     36 
     37 newTarget.prototype = undefined;
     38 err = Reflect.construct(SuppressedError, [[]], newTarget);
     39 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is undefined');
     40 
     41 newTarget.prototype = null;
     42 err = Reflect.construct(SuppressedError, [[]], newTarget);
     43 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is null');
     44 
     45 newTarget.prototype = true;
     46 err = Reflect.construct(SuppressedError, [[]], newTarget);
     47 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is a Boolean');
     48 
     49 newTarget.prototype = '';
     50 err = Reflect.construct(SuppressedError, [[]], newTarget);
     51 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is a String');
     52 
     53 newTarget.prototype = Symbol();
     54 err = Reflect.construct(SuppressedError, [[]], newTarget);
     55 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is a Symbol');
     56 
     57 newTarget.prototype = -1;
     58 err = Reflect.construct(SuppressedError, [[]], newTarget);
     59 assert.sameValue(Object.getPrototypeOf(err), other.SuppressedError.prototype, 'newTarget.prototype is a Number');
     60 
     61 reportCompare(0, 0);