tor-browser

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

fake-errors.js (671B)


      1 // |reftest| skip-if(!Error.isError) -- Error.isError is not enabled unconditionally
      2 // Copyright (C) 2024 Jordan Harband.  All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-error.iserror
      7 description: >
      8  Returns false on non-Error objects pretending to be an Error
      9 features: [Error.isError]
     10 ---*/
     11 
     12 var fakeError = {
     13  __proto__: Error.prototype,
     14  constructor: Error,
     15  message: '',
     16  stack: new Error().stack
     17 };
     18 
     19 if (typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol') {
     20  fakeError[Symbol.toStringTag] = 'Error';
     21 }
     22 
     23 assert.sameValue(Error.isError(fakeError), false);
     24 
     25 reportCompare(0, 0);