Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp

Module bytecode should use different MIME type, to avoid mixing up script/module
bytecodes for single JS file.

This patch adds a static method that simply returns the current bytecode MIME
type.
The later patch adds a new MIME type for module bytecode and modify the
ScriptLoader::BytecodeMimeTypeFor method to return corresponding MIME type.

Differential Revision: https://phabricator.services.mozilla.com/D140292
This commit is contained in:
Tooru Fujisawa
2022-03-15 04:24:50 +00:00
parent 02ac05b229
commit 6afe674b41
3 changed files with 11 additions and 4 deletions

View File

@@ -305,7 +305,7 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
if (cic) {
nsAutoCString altDataType;
cic->GetAlternativeDataType(altDataType);
if (altDataType.Equals(nsContentUtils::JSBytecodeMimeType())) {
if (altDataType.Equals(ScriptLoader::BytecodeMimeTypeFor(mRequest))) {
mRequest->SetBytecode();
TRACE_FOR_TEST(mRequest->mLoadContext->GetScriptElement(),
"scriptloader_load_bytecode");