tor-browser

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

features.js (2887B)


      1 // Test that if a feature is 'experimental' then we must be in a nightly build,
      2 // and if a feature is 'released' then it must be enabled on release and beta.
      3 //
      4 // An experimental feature is allowed to be disabled by platform/feature flags,
      5 // we only require that it can never be enabled on release/beta builds.
      6 //
      7 // A released feature is allowed to be disabled on nightly. This is useful for
      8 // if we're testing out a new compiler/configuration where a released feature
      9 // is not supported yet. We only require that on release/beta, the feature must
     10 // be enabled.
     11 //
     12 // As features are advanced, this test must be manually updated.
     13 //
     14 // NOTE0: The |jit-test| directive must be updated with all opt-in shell flags
     15 //        for experimental features for this to work correctly.
     16 // NOTE1: This test relies on feature functions accurately guarding use of the
     17 //        feature to work correctly. All features should have a 'disabled.js'
     18 //        test to verify this. Basic testing for this is included with each
     19 //        feature in this test for sanity.
     20 // NOTE2: Keep this file in sync with:
     21 //        `dom/worklet/tests/worklet_audioWorklet_WASM_features.js`.
     22 
     23 let release_or_beta = getBuildConfiguration("release_or_beta");
     24 let nightly = !release_or_beta;
     25 
     26 let nightlyOnlyFeatures = [
     27 ];
     28 
     29 for (let [name, enabled, test] of nightlyOnlyFeatures) {
     30  if (enabled) {
     31    assertEq(nightly, true, `${name} must be enabled only on nightly`);
     32    wasmEvalText(test);
     33  } else {
     34    assertErrorMessage(() => wasmEvalText(test), WebAssembly.CompileError, /./);
     35  }
     36 }
     37 
     38 // These are features that are enabled in beta/release but may be disabled at
     39 // run-time for other reasons.  The best we can do for these features is to say
     40 // that if one claims to be supported then it must work, and otherwise there
     41 // must be a CompileError.
     42 
     43 let releasedFeaturesMaybeDisabledAnyway = [
     44  // SIMD will be disabled dynamically on x86/x64 if the hardware isn't SSE4.1+.
     45  ['simd', wasmSimdEnabled(), `(module (func (result v128) i32.const 0 i8x16.splat))`],
     46  [
     47    'relaxed-simd',
     48    wasmRelaxedSimdEnabled(),
     49    `(module (func (result v128)
     50      unreachable
     51      i16x8.relaxed_laneselect
     52    ))`
     53  ],
     54 ];
     55 
     56 for (let [name, enabled, test] of releasedFeaturesMaybeDisabledAnyway) {
     57  if (release_or_beta) {
     58    if (enabled) {
     59      wasmEvalText(test);
     60    } else {
     61      assertErrorMessage(() => wasmEvalText(test), WebAssembly.CompileError, /./);
     62    }
     63  }
     64 }
     65 
     66 let releasedFeatures = [
     67  ['threads', wasmThreadsEnabled(), `(module (memory 1 1 shared))`],
     68  ['branch-hinting', wasmBranchHintingEnabled(),
     69    `(func
     70      i32.const 0
     71      (@metadata.code.branch_hint "\\00") if
     72    end)`],
     73 ];
     74 
     75 for (let [name, enabled, test, options] of releasedFeatures) {
     76  if (release_or_beta) {
     77    assertEq(enabled, true, `${name} must be enabled on release and beta`);
     78    wasmEvalText(test, {}, options);
     79  }
     80 }