From 77e8ba7eaf3ca00f25d0507cf17de2f50741f335 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 25 Aug 2020 07:06:43 +0000 Subject: Issue #618 - Implement async attribute for inline module scripts. (uplift) This commit does several things: - Moves the pref check from ScriptLoader to ns[I]Document so it can be called on the document. - Changes the atrribute freezing function to a better name that takes the document as a parameter. - Sets the proper async/defer attributes on HTML script elements based on keywords and whether they are module scripts or not. --- dom/base/nsDocument.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'dom/base/nsDocument.cpp') diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index d0634b0f9..de793bfab 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -12745,3 +12745,16 @@ nsIDocument::GetSelection(ErrorResult& aRv) return nsGlobalWindow::Cast(window)->GetSelection(aRv); } + +bool +nsIDocument::ModuleScriptsEnabled() +{ + static bool sEnabledForContent = false; + static bool sCachedPref = false; + if (!sCachedPref) { + sCachedPref = true; + Preferences::AddBoolVarCache(&sEnabledForContent, "dom.moduleScripts.enabled", false); + } + + return nsContentUtils::IsChromeDoc(this) || sEnabledForContent; +} \ No newline at end of file -- cgit v1.2.3