tor-browser

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

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


      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-disposablestack
      7 description: Default [[Prototype]] value derived from realm of the newTarget
      8 info: |
      9  DisposableStack( )
     10 
     11  ...
     12  2. Let disposableStack be ? OrdinaryCreateFromConstructor(NewTarget, "%DisposableStack.prototype%", « [[DisposableState]], [[DisposeCapability]] »).
     13  3. Set disposableStack.[[DisposableState]] to pending.
     14  4. Set disposableStack.[[DisposeCapability]] to NewDisposeCapability().
     15  5. Return disposableStack.
     16 
     17  OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
     18 
     19  ...
     20  2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
     21  3. Return ObjectCreate(proto, internalSlotsList).
     22 
     23  GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
     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 stack;
     36 
     37 newTarget.prototype = undefined;
     38 stack = Reflect.construct(DisposableStack, [], newTarget);
     39 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is undefined');
     40 
     41 newTarget.prototype = null;
     42 stack = Reflect.construct(DisposableStack, [], newTarget);
     43 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is null');
     44 
     45 newTarget.prototype = true;
     46 stack = Reflect.construct(DisposableStack, [], newTarget);
     47 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Boolean');
     48 
     49 newTarget.prototype = '';
     50 stack = Reflect.construct(DisposableStack, [], newTarget);
     51 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a String');
     52 
     53 newTarget.prototype = Symbol();
     54 stack = Reflect.construct(DisposableStack, [], newTarget);
     55 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Symbol');
     56 
     57 newTarget.prototype = 1;
     58 stack = Reflect.construct(DisposableStack, [], newTarget);
     59 assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Number');
     60 
     61 
     62 reportCompare(0, 0);