tor-browser

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

assert-throws-same-realm.js (806B)


      1 // Copyright (C) 2021 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    Functions that throw instances of the realm specified constructor function
      7    do not satisfy the assertion with cross realms collisions.
      8 ---*/
      9 
     10 var intrinsicTypeError = TypeError; 
     11 var threw = false;
     12 var realmGlobal = $262.createRealm().global;
     13 
     14 try {
     15  assert.throws(TypeError, function() {
     16    throw new realmGlobal.TypeError();
     17  });
     18 } catch (err) {
     19  threw = true;
     20  if (err.constructor !== Test262Error) {
     21    throw new Error(
     22      'Expected a Test262Error but a "' + err.constructor.name + 
     23      '" was thrown.'
     24    );
     25  }
     26 }
     27 
     28 if (threw === false) {
     29  throw new Error('Expected a Test262Error, but no error was thrown.');
     30 }
     31 
     32 reportCompare(0, 0);