mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-22 04:13:06 +09:00
Bug 1330657 - Enable <script type="module"> behind a pref
This commit is contained in:
parent
db68ce927e
commit
408d61b4f0
3 changed files with 20 additions and 3 deletions
|
|
@ -653,6 +653,19 @@ nsScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsScriptLoader::ModuleScriptsEnabled()
|
||||
{
|
||||
static bool sEnabledForContent = false;
|
||||
static bool sCachedPref = false;
|
||||
if (!sCachedPref) {
|
||||
sCachedPref = true;
|
||||
Preferences::AddBoolVarCache(&sEnabledForContent, "dom.moduleScripts.enabled", false);
|
||||
}
|
||||
|
||||
return nsContentUtils::IsChromeDoc(mDocument) || sEnabledForContent;
|
||||
}
|
||||
|
||||
bool
|
||||
nsScriptLoader::ModuleMapContainsModule(nsModuleLoadRequest *aRequest) const
|
||||
{
|
||||
|
|
@ -1448,8 +1461,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
|
||||
nsScriptKind scriptKind = nsScriptKind::Classic;
|
||||
if (!type.IsEmpty()) {
|
||||
// Support type="module" only for chrome documents.
|
||||
if (nsContentUtils::IsChromeDoc(mDocument) && type.LowerCaseEqualsASCII("module")) {
|
||||
if (ModuleScriptsEnabled() && type.LowerCaseEqualsASCII("module")) {
|
||||
scriptKind = nsScriptKind::Module;
|
||||
} else {
|
||||
NS_ENSURE_TRUE(ParseTypeAttribute(type, &version), false);
|
||||
|
|
@ -2768,7 +2780,7 @@ nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
|||
}
|
||||
|
||||
// TODO: Preload module scripts.
|
||||
if (nsContentUtils::IsChromeDoc(mDocument) && aType.LowerCaseEqualsASCII("module")) {
|
||||
if (ModuleScriptsEnabled() && aType.LowerCaseEqualsASCII("module")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue