Bug 1851468 - wasm: Set ContextOptions defaults to help consumers that don't read preferences. r=yury

WorkletThread does not read from preferences to initialize JS::ContextOptions
and relies on the default values it has. This lead to a regression from
bug 1832378 where certain wasm features had their field's default change.
This didn't affect other globals because we read preferences from those
and so the default value is ignored.

This commit fixes the default value for wasm features in JS::ContextOptions
as a temporary fix, and adds a quick test in worklets.

Ideally worklets will read from preferences for consistency and to allow
us to force enable/disable features. But that's a bigger change.

Differential Revision: https://phabricator.services.mozilla.com/D187583
This commit is contained in:
Ryan Hunt 2023-09-07 15:30:57 +00:00
Родитель f94a0c60d5
Коммит b3b912f859
5 изменённых файлов: 77 добавлений и 1 удалений

Просмотреть файл

@ -10,6 +10,8 @@ support-files=worklet_test_audioWorkletGlobalScopeRegisterProcessor.js
[test_audioWorklet_WASM.html]
skip-if = release_or_beta # requires dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled
support-files=worklet_audioWorklet_WASM.js
[test_audioWorklet_WASM_Features.html]
support-files=worklet_audioWorklet_WASM_features.js
[test_audioWorklet_insecureContext.html]
scheme = http
skip-if =

Просмотреть файл

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for AudioWorklet + WASM features</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="common.js"></script>
</head>
<body>
<script type="application/javascript">
function runTestInIframe() {
let audioContext = new AudioContext();
audioContext.audioWorklet.addModule("worklet_audioWorklet_WASM_features.js")
.then(() => {
const node = new AudioWorkletNode(audioContext, 'wasm');
node.port.onmessage = e => {
let result = e.data;
ok(result === true, "Compilation succeeded");
SimpleTest.finish();
}
node.connect(audioContext.destination);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,44 @@
class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
constructor(...args) {
super(...args);
this.port.postMessage(testModules());
}
process(inputs, outputs, parameters) {
// Do nothing, output silence
return true;
}
}
function testModule(binary) {
try {
let wasmModule = new WebAssembly.Module(binary);
} catch (error) {
if (error instanceof WebAssembly.CompileError) {
return error.message;
}
return "unknown error";
}
return true;
}
// TODO: test more features
function testModules() {
/*
js -e '
t = wasmTextToBinary(`
(module
(tag)
)
`);
print(t)
'
*/
// eslint-disable-next-line
const exceptionHandlingCode = new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 13, 3, 1, 0, 0,
]);
return testModule(exceptionHandlingCode);
}
registerProcessor("wasm", WasmProcessWorkletProcessor);

Просмотреть файл

@ -123,7 +123,7 @@ enum class WasmFeatureStage {
FEATURE( \
/* capitalized name */ Exceptions, \
/* lower case name */ exceptions, \
/* stage */ WasmFeatureStage::Tentative, \
/* stage */ WasmFeatureStage::Default, \
/* compile predicate */ true, \
/* compiler predicate */ AnyCompilerAvailable(cx), \
/* flag predicate */ true, \

Просмотреть файл

@ -19,6 +19,8 @@
// feature to work correctly. All features should have a 'disabled.js'
// test to verify this. Basic testing for this is included with each
// feature in this test for sanity.
// NOTE2: Keep this file in sync with:
// `dom/worklet/tests/worklet_audioWorklet_WASM_features.js`.
let { release_or_beta } = getBuildConfiguration();
let nightly = !release_or_beta;