tor-browser

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

nightly-only.js (824B)


      1 // Some experimental features are enabled only on nightly builds, and disabled
      2 // on beta and release. Tests for these features should not simply disable
      3 // themselves on all but nightly builds, because if we neglect to update such
      4 // tests once the features cease to be experimental, we'll silently skip the
      5 // tests on beta and release, even though they should run.
      6 
      7 // Call the function f. On beta and release, expect it to throw an error that is
      8 // an instance of error.
      9 function nightlyOnly(error, f) {
     10  if (getBuildConfiguration("release_or_beta")) {
     11    try {
     12      f();
     13      throw new Error("use of feature expected to fail on release and beta, but succeeded; please update test");
     14    } catch (e) {
     15      if (!(e instanceof error)) {
     16        throw e;
     17      }
     18      // All is well.
     19    }
     20  } else {
     21    f();
     22  }
     23 }