function initRootRealm(parentUnsafeRec, self, options) {
    // note: 'self' is the instance of the Realm.

    // todo: investigate attacks via Array.species
    // todo: this accepts newShims='string', but it should reject that
    const { shims: newShims, transforms, sloppyGlobals, errorHandler } = options;
    const allShims = arrayConcat(parentUnsafeRec.allShims, newShims);

    // The unsafe record is created already repaired.
    const unsafeRec = createNewUnsafeRec(allShims);

    const { unsafeGlobal } = unsafeRec;
    unsafeGlobal.addEventListener('error', err => {
      if (errorHandler) errorHandler(err);
    });

    // eslint-disable-next-line no-use-before-define
    const Realm = createRealmFacade(unsafeRec, BaseRealm);

    // Add a Realm descriptor to sharedGlobalDescs, so it can be defined onto the
    // safeGlobal like the rest of the globals.
    unsafeRec.sharedGlobalDescs.Realm = {
      value: Realm,
      writable: true,
      configurable: true
    };

    // Creating the realmRec provides the global object, eval() and Function()
    // to the realm.
    const realmRec = createRealmRec(unsafeRec, transforms, sloppyGlobals);

    // Apply all shims in the new RootRealm. We don't do this for compartments.
    const { safeEvalWhichTakesEndowments } = realmRec;
    for (const shim of allShims) {
      safeEvalWhichTakesEndowments(shim);
    }

    // The realmRec acts as a private field on the realm instance.
    registerRealmRecForRealmInstance(self, realmRec);
  }
/**
   * A root realm uses a fresh set of new intrinics. Here we first create
   * a new unsafe record, which inherits the shims. Then we proceed with
   * the creation of the realm record, and we apply the shims.
   */
A root realm uses a fresh set of new intrinics. Here we first create
a new unsafe record, which inherits the shims. Then we proceed with
the creation of the realm record, and we apply the shims.
A root realm uses a fresh set of new intrinics . Here we first create a new unsafe record which inherits the shims . Then we proceed with the creation of the realm record and we apply the shims .
function initRootRealm(parentUnsafeRec, self, options) {
    const { shims: newShims, transforms, sloppyGlobals, errorHandler } = options;
    const allShims = arrayConcat(parentUnsafeRec.allShims, newShims);
    const unsafeRec = createNewUnsafeRec(allShims);
    const { unsafeGlobal } = unsafeRec;
    unsafeGlobal.addEventListener('error', err => {
      if (errorHandler) errorHandler(err);
    });
    const Realm = createRealmFacade(unsafeRec, BaseRealm);
    unsafeRec.sharedGlobalDescs.Realm = {
      value: Realm,
      writable: true,
      configurable: true
    };
    const realmRec = createRealmRec(unsafeRec, transforms, sloppyGlobals);
    const { safeEvalWhichTakesEndowments } = realmRec;
    for (const shim of allShims) {
      safeEvalWhichTakesEndowments(shim);
    }
    registerRealmRecForRealmInstance(self, realmRec);
  }
function initRootRealm ( parentUnsafeRec , self , options ) { const { shims : newShims , transforms , sloppyGlobals , errorHandler } = options ; const allShims = arrayConcat ( parentUnsafeRec . allShims , newShims ) ; const unsafeRec = createNewUnsafeRec ( allShims ) ; const { unsafeGlobal } = unsafeRec ; unsafeGlobal . addEventListener ( 'error' , err => { if ( errorHandler ) errorHandler ( err ) ; } ) ; const Realm = createRealmFacade ( unsafeRec , BaseRealm ) ; unsafeRec . sharedGlobalDescs . Realm = { value : Realm , writable : true , configurable : true } ; const realmRec = createRealmRec ( unsafeRec , transforms , sloppyGlobals ) ; const { safeEvalWhichTakesEndowments } = realmRec ; for ( const shim of allShims ) { safeEvalWhichTakesEndowments ( shim ) ; } registerRealmRecForRealmInstance ( self , realmRec ) ; }
A root realm uses a fresh set of new intrinics.
A root realm uses a fresh set of new intrinics .
// note: 'self' is the instance of the Realm. // todo: investigate attacks via Array.species // todo: this accepts newShims='string', but it should reject that // The unsafe record is created already repaired. // eslint-disable-next-line no-use-before-define // Add a Realm descriptor to sharedGlobalDescs, so it can be defined onto the // safeGlobal like the rest of the globals. // Creating the realmRec provides the global object, eval() and Function() // to the realm. // Apply all shims in the new RootRealm. We don't do this for compartments. // The realmRec acts as a private field on the realm instance.