Bug 1969895 - Do not try encoding JSON modules. a=RyanVM
Original Revision: https://phabricator.services.mozilla.com/D252181 Differential Revision: https://phabricator.services.mozilla.com/D252260
This commit is contained in:
committed by
rvandermeulen@mozilla.com
parent
bc8ea6d91e
commit
59706292b9
@@ -2643,6 +2643,12 @@ void ScriptLoader::CalculateBytecodeCacheFlag(ScriptLoadRequest* aRequest) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aRequest->IsModuleRequest() &&
|
||||||
|
aRequest->AsModuleRequest()->mModuleType != JS::ModuleType::JavaScript) {
|
||||||
|
aRequest->MarkSkippedBytecodeEncoding();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We need the nsICacheInfoChannel to exist to be able to open the alternate
|
// We need the nsICacheInfoChannel to exist to be able to open the alternate
|
||||||
// data output stream. This pointer would only be non-null if the bytecode was
|
// data output stream. This pointer would only be non-null if the bytecode was
|
||||||
// activated at the time the channel got created in StartLoad.
|
// activated at the time the channel got created in StartLoad.
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ support-files = [
|
|||||||
"page_bytecode_cache_asm_js.js",
|
"page_bytecode_cache_asm_js.js",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
["browser_bytecode_json_module.js"]
|
||||||
|
support-files = [
|
||||||
|
"page_bytecode_cache_json_module.html",
|
||||||
|
"page_bytecode_cache_json_module.json",
|
||||||
|
]
|
||||||
|
|
||||||
["browser_cancel_keydown_keypress_event.js"]
|
["browser_cancel_keydown_keypress_event.js"]
|
||||||
support-files = ["prevent_return_key.html"]
|
support-files = ["prevent_return_key.html"]
|
||||||
|
|
||||||
|
|||||||
36
dom/tests/browser/browser_bytecode_json_module.js
Normal file
36
dom/tests/browser/browser_bytecode_json_module.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const PAGE_URL =
|
||||||
|
"https://example.com/browser/dom/tests/browser/page_bytecode_cache_json_module.html";
|
||||||
|
|
||||||
|
async function waitForIdle() {
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
await new Promise(resolve => Services.tm.idleDispatchToMainThread(resolve));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add_task(async function () {
|
||||||
|
// Eagerly generate bytecode cache.
|
||||||
|
await SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
["dom.script_loader.bytecode_cache.enabled", true],
|
||||||
|
["dom.script_loader.bytecode_cache.strategy", -1],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await BrowserTestUtils.withNewTab(
|
||||||
|
{
|
||||||
|
gBrowser,
|
||||||
|
url: PAGE_URL,
|
||||||
|
waitForLoad: true,
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
// TODO: Once the bytecode-encoding events are refactored,
|
||||||
|
// listen to the events (bug 1902951).
|
||||||
|
await waitForIdle();
|
||||||
|
ok(true, "No crash should happen");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await SpecialPowers.popPrefEnv();
|
||||||
|
});
|
||||||
11
dom/tests/browser/page_bytecode_cache_json_module.html
Normal file
11
dom/tests/browser/page_bytecode_cache_json_module.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>JSON module test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>JSON module test</h1>
|
||||||
|
<script>
|
||||||
|
import("./page_bytecode_cache_json_module.json", { with: { type: "json"} });
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
35
dom/tests/browser/page_bytecode_cache_json_module.json
Normal file
35
dom/tests/browser/page_bytecode_cache_json_module.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"dummy": [
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache",
|
||||||
|
"dummy text to exceed the minimal source length for bytecode cache"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -310,4 +310,5 @@ export default [
|
|||||||
// Support for Import attributes is only available in ESLint v9.19
|
// Support for Import attributes is only available in ESLint v9.19
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1944290
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1944290
|
||||||
"netwerk/test/mochitests/test_import_json_module.mjs",
|
"netwerk/test/mochitests/test_import_json_module.mjs",
|
||||||
|
"dom/tests/browser/page_bytecode_cache_json_module.html",
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user