Bug 1757833 - Add mochitest for compressed bytecode caching r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D145346
This commit is contained in:
Bryan Thrall 2022-05-17 16:29:04 +00:00
Родитель 91ba7a42fa
Коммит f4b0ea4ace
1 изменённых файлов: 24 добавлений и 0 удалений

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

@ -231,6 +231,30 @@
}, "Do not save bytecode on compilation errors");
promise_test(async function() {
// (see above)
await SpecialPowers.pushPrefEnv({set: [
['dom.script_loader.bytecode_cache.enabled', true],
['dom.expose_test_interfaces', true],
['dom.script_loader.bytecode_cache.strategy', -1],
['browser.cache.jsbc_compression_level', 2]
]});
// Load the test page, and verify that the code path taken by the
// nsScriptLoadRequest corresponds to the code path which is loading a
// source and saving it as compressed bytecode.
var stateMachineResult = WaitForScriptTagEvent(`file_js_cache.html`);
assert_equals(await stateMachineResult, `bytecode_saved`,
`[1-script] ScriptLoadRequest status after the first visit`);
// Reload the same test page, and verify that the code path taken by
// the nsScriptLoadRequest corresponds to the code path which is
// loading compressed bytecode, decompressing it, and executing it.
stateMachineResult = WaitForScriptTagEvent(`file_js_cache.html`);
assert_equals(await stateMachineResult, `bytecode_exec`,
`[2-script] ScriptLoadRequest status after the second visit`);
}, "Check the JS bytecode cache can save and load compressed bytecode");
done();
</script>
</head>