| 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 |
'relaxed-simd', |
| 29 |
wasmRelaxedSimdEnabled(), |
| 30 |
`(module (func (result v128) |
| 31 |
unreachable |
| 32 |
i16x8.relaxed_laneselect |
| 33 |
))` |
| 34 |
], |
| 35 |
]; |
| 36 |
|
| 37 |
for (let [name, enabled, test] of nightlyOnlyFeatures) { |
| 38 |
if (enabled) { |
| 39 |
assertEq(nightly, true, `${name} must be enabled only on nightly`); |
| 40 |
wasmEvalText(test); |
| 41 |
} else { |
| 42 |
assertErrorMessage(() => wasmEvalText(test), WebAssembly.CompileError, /./); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
// These are features that are enabled in beta/release but may be disabled at |
| 47 |
// run-time for other reasons. The best we can do for these features is to say |
| 48 |
// that if one claims to be supported then it must work, and otherwise there |
| 49 |
// must be a CompileError. |
| 50 |
|
| 51 |
let releasedFeaturesMaybeDisabledAnyway = [ |
| 52 |
// SIMD will be disabled dynamically on x86/x64 if the hardware isn't SSE4.1+. |
| 53 |
['simd', wasmSimdEnabled(), `(module (func (result v128) i32.const 0 i8x16.splat))`] |
| 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 |
[ |
| 69 |
'multi-memory', |
| 70 |
wasmMultiMemoryEnabled(), |
| 71 |
`(module (memory 0) (memory 0))`, |
| 72 |
], |
| 73 |
[ |
| 74 |
'exnref', |
| 75 |
wasmExnRefEnabled(), |
| 76 |
`(module (func try_table end))` |
| 77 |
], |
| 78 |
[ |
| 79 |
'memory64', |
| 80 |
wasmMemory64Enabled(), |
| 81 |
`(module (memory i64 0))`, |
| 82 |
], |
| 83 |
[ |
| 84 |
'js-string-builtins', |
| 85 |
wasmJSStringBuiltinsEnabled(), |
| 86 |
`(module |
| 87 |
(import "wasm:js-string" "concat" |
| 88 |
(func |
| 89 |
(param externref externref) |
| 90 |
(result (ref extern))) |
| 91 |
) |
| 92 |
)`, |
| 93 |
{builtins: ['js-string']} |
| 94 |
] |
| 95 |
]; |
| 96 |
|
| 97 |
for (let [name, enabled, test, options] of releasedFeatures) { |
| 98 |
if (release_or_beta) { |
| 99 |
assertEq(enabled, true, `${name} must be enabled on release and beta`); |
| 100 |
wasmEvalText(test, {}, options); |
| 101 |
} |
| 102 |
} |