Bug 1362119 - part 1 - Moving dom/base/Script{Loader,Element}.* in dom/script, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 08 May 2017 08:24:22 +0200
changeset 357012 0788c41e592b476d8261074ff8335e975a713b3a
parent 357011 c4e9e9eab87d0bbadba8151731eabf0a7788f877
child 357013 692529b223ec44199999aaf201a6a14fce674398
push id90008
push useramarchesini@mozilla.com
push dateMon, 08 May 2017 11:33:44 +0000
treeherdermozilla-inbound@1054eb4b2782 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1362119
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1362119 - part 1 - Moving dom/base/Script{Loader,Element}.* in dom/script, r=ehsan This patch does these things: 1. it moves nsScriptElement, nsScriptLoader, ScriptSettings, nsIScriptElement and nsIScriptLoaderObserver in dom/script 2. it renames nsScriptElement to mozilla::dom::ScriptElement 3. it renames nsScriptLaoder to mozilla::dom::ScriptLoader
dom/base/ImportManager.cpp
dom/base/ImportManager.h
dom/base/Location.cpp
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
dom/base/moz.build
dom/base/nsContentPermissionHelper.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentSink.h
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsFrameMessageManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsIDocument.h
dom/base/nsIScriptElement.h
dom/base/nsIScriptLoaderObserver.idl
dom/base/nsInProcessTabChildGlobal.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsScriptElement.cpp
dom/base/nsScriptElement.h
dom/base/nsScriptLoader.cpp
dom/base/nsScriptLoader.h
dom/base/test/test_script_loader_js_cache.html
dom/console/Console.cpp
dom/events/DOMEventTargetHelper.cpp
dom/html/HTMLScriptElement.cpp
dom/html/HTMLScriptElement.h
dom/html/nsGenericHTMLElement.cpp
dom/html/nsHTMLContentSink.cpp
dom/messagechannel/MessagePort.cpp
dom/moz.build
dom/script/ScriptElement.cpp
dom/script/ScriptElement.h
dom/script/ScriptLoader.cpp
dom/script/ScriptLoader.h
dom/script/ScriptSettings.cpp
dom/script/ScriptSettings.h
dom/script/moz.build
dom/script/nsIScriptElement.h
dom/script/nsIScriptLoaderObserver.idl
dom/svg/SVGScriptElement.cpp
dom/svg/SVGScriptElement.h
dom/workers/ScriptLoader.cpp
dom/workers/ServiceWorkerManager.cpp
dom/workers/ServiceWorkerScriptCache.cpp
dom/worklet/Worklet.cpp
dom/xml/nsXMLContentSink.cpp
dom/xml/nsXMLFragmentContentSink.cpp
dom/xslt/xslt/txMozillaXMLOutput.cpp
dom/xul/XULDocument.cpp
dom/xul/XULDocument.h
dom/xul/nsXULContentSink.cpp
js/xpconnect/loader/ChromeScriptLoader.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/src/XPCJSContext.cpp
js/xpconnect/src/XPCJSRuntime.cpp
parser/html/nsHtml5DocumentBuilder.cpp
parser/html/nsHtml5OplessBuilder.cpp
parser/html/nsHtml5TreeOpExecutor.cpp
parser/html/nsParserUtils.cpp
parser/htmlparser/nsParser.cpp
--- a/dom/base/ImportManager.cpp
+++ b/dom/base/ImportManager.cpp
@@ -1,29 +1,29 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ImportManager.h"
 
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/EventListenerManager.h"
 #include "HTMLLinkElement.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsIChannel.h"
 #include "nsIContentPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptObjectPrincipal.h"
-#include "nsScriptLoader.h"
 #include "nsNetUtil.h"
 
 //-----------------------------------------------------------------------------
 // AutoError
 //-----------------------------------------------------------------------------
 
 class AutoError {
 public:
@@ -151,17 +151,17 @@ ImportLoader::Updater::UpdateMainReferre
       ScriptLoader()->AddParserBlockingScriptExecutionBlocker();
     newMainReferrer->OwnerDoc()->BlockDOMContentLoaded();
   }
 
   if (mLoader->mDocument) {
     // Our nearest predecessor has changed. So let's add the ScriptLoader to the
     // new one if there is any. And remove it from the old one.
     RefPtr<ImportManager> manager = mLoader->Manager();
-    nsScriptLoader* loader = mLoader->mDocument->ScriptLoader();
+    ScriptLoader* loader = mLoader->mDocument->ScriptLoader();
     ImportLoader*& pred = mLoader->mBlockingPredecessor;
     ImportLoader* newPred = manager->GetNearestPredecessor(newMainReferrer);
     if (pred) {
       if (newPred) {
         newPred->AddBlockedScriptLoader(loader);
       }
       pred->RemoveBlockedScriptLoader(loader);
     }
@@ -334,30 +334,30 @@ ImportLoader::DispatchEventIfFinished(ns
     DispatchLoadEvent(aNode);
   }
   if (mStopped) {
     DispatchErrorEvent(aNode);
   }
 }
 
 void
-ImportLoader::AddBlockedScriptLoader(nsScriptLoader* aScriptLoader)
+ImportLoader::AddBlockedScriptLoader(ScriptLoader* aScriptLoader)
 {
   if (mBlockedScriptLoaders.Contains(aScriptLoader)) {
     return;
   }
 
   aScriptLoader->AddParserBlockingScriptExecutionBlocker();
 
   // Let's keep track of the pending script loaders.
   mBlockedScriptLoaders.AppendElement(aScriptLoader);
 }
 
 bool
-ImportLoader::RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader)
+ImportLoader::RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader)
 {
   aScriptLoader->RemoveParserBlockingScriptExecutionBlocker();
   return mBlockedScriptLoaders.RemoveElement(aScriptLoader);
 }
 
 void
 ImportLoader::AddLinkElement(nsINode* aNode)
 {
--- a/dom/base/ImportManager.h
+++ b/dom/base/ImportManager.h
@@ -40,18 +40,18 @@
 #define mozilla_dom_ImportManager_h__
 
 #include "nsTArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDOMEventListener.h"
 #include "nsIStreamListener.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsRefPtrHashtable.h"
-#include "nsScriptLoader.h"
 #include "nsURIHashKey.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 class nsIDocument;
 class nsIPrincipal;
 class nsINode;
 class AutoError;
 
 namespace mozilla {
 namespace dom {
@@ -179,18 +179,18 @@ public:
     return mLinks[mMainReferrer];
   }
 
   // An import is not only blocked by its import children, but also
   // by its predecessors. It's enough to find the closest predecessor
   // and wait for that to run its scripts. We keep track of all the
   // ScriptRunners that are waiting for this import. NOTE: updating
   // the main referrer might change this list.
-  void AddBlockedScriptLoader(nsScriptLoader* aScriptLoader);
-  bool RemoveBlockedScriptLoader(nsScriptLoader* aScriptLoader);
+  void AddBlockedScriptLoader(ScriptLoader* aScriptLoader);
+  bool RemoveBlockedScriptLoader(ScriptLoader* aScriptLoader);
   void SetBlockingPredecessor(ImportLoader* aLoader);
 
 private:
   ~ImportLoader() {}
 
   // If a new referrer LinkElement was added, let's
   // see if we are already finished and if so fire
   // the right event.
@@ -225,17 +225,17 @@ private:
   ImportLoader* mBlockingPredecessor;
 
   // List of the LinkElements that are referring to this import
   // we need to keep track of them so we can fire event on them.
   nsTArray<nsCOMPtr<nsINode>> mLinks;
 
   // List of pending ScriptLoaders that are waiting for this import
   // to finish.
-  nsTArray<RefPtr<nsScriptLoader>> mBlockedScriptLoaders;
+  nsTArray<RefPtr<ScriptLoader>> mBlockedScriptLoaders;
 
   // There is always exactly one referrer link that is flagged as
   // the main referrer the primary link. This is the one that is
   // used in the script execution order calculation.
   // ("Branch" according to the spec.)
   uint32_t mMainReferrer;
   bool mReady;
   bool mStopped;
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -27,19 +27,19 @@
 #include "nsReadableUtils.h"
 #include "nsITextToSubURI.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/Likely.h"
 #include "nsCycleCollectionParticipant.h"
 #include "NullPrincipal.h"
-#include "ScriptSettings.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/LocationBinding.h"
+#include "mozilla/dom/ScriptSettings.h"
 
 namespace mozilla {
 namespace dom {
 
 static nsresult
 GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
 {
   aCharset.Truncate();
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -22,17 +22,16 @@ XPIDL_SOURCES += [
     'nsIDOMSerializer.idl',
     'nsIDroppedLinkHandler.idl',
     'nsIFrameLoader.idl',
     'nsIImageLoadingContent.idl',
     'nsIMessageManager.idl',
     'nsIObjectLoadingContent.idl',
     'nsIRemoteWindowContext.idl',
     'nsIScriptChannel.idl',
-    'nsIScriptLoaderObserver.idl',
     'nsISelection.idl',
     'nsISelectionController.idl',
     'nsISelectionDisplay.idl',
     'nsISelectionListener.idl',
     'nsISelectionPrivate.idl',
     'nsISimpleContentPolicy.idl',
     'nsISlowScriptDebug.idl',
 ]
@@ -87,17 +86,16 @@ EXPORTS += [
     'nsIDocumentObserver.h',
     'nsIDOMClassInfo.h',
     'nsIGlobalObject.h',
     'nsImageLoadingContent.h',
     'nsIMutationObserver.h',
     'nsINode.h',
     'nsINodeList.h',
     'nsIScriptContext.h',
-    'nsIScriptElement.h',
     'nsIScriptGlobalObject.h',
     'nsIScriptNameSpaceManager.h',
     'nsIScriptObjectPrincipal.h',
     'nsIScriptTimeoutHandler.h',
     'nsIStyleSheetLinkingElement.h',
     'nsITimeoutHandler.h',
     'nsJSEnvironment.h',
     'nsJSUtils.h',
@@ -108,17 +106,16 @@ EXPORTS += [
     'nsNodeUtils.h',
     'nsPIDOMWindow.h',
     'nsPIDOMWindowInlines.h',
     'nsPIWindowRoot.h',
     'nsPropertyTable.h',
     'nsRange.h',
     'nsReferencedElement.h',
     'nsSandboxFlags.h',
-    'nsScriptLoader.h',
     'nsStructuredCloneContainer.h',
     'nsStubAnimationObserver.h',
     'nsStubDocumentObserver.h',
     'nsStubMutationObserver.h',
     'nsStyledElement.h',
     'nsTextFragment.h',
     'nsTraversal.h',
     'nsTreeSanitizer.h',
@@ -193,17 +190,16 @@ EXPORTS.mozilla.dom += [
     'NodeInfoInlines.h',
     'NodeIterator.h',
     'PartialSHistory.h',
     'Pose.h',
     'ProcessGlobal.h',
     'ResponsiveImageSelector.h',
     'SameProcessMessageQueue.h',
     'ScreenOrientation.h',
-    'ScriptSettings.h',
     'ShadowRoot.h',
     'StructuredCloneHolder.h',
     'StructuredCloneTags.h',
     'StyleSheetList.h',
     'SubtleCrypto.h',
     'TabGroup.h',
     'Text.h',
     'Timeout.h',
@@ -310,18 +306,16 @@ UNIFIED_SOURCES += [
     'nsNodeUtils.cpp',
     'nsOpenURIInFrameParams.cpp',
     'nsPlainTextSerializer.cpp',
     'nsPropertyTable.cpp',
     'nsQueryContentEventResult.cpp',
     'nsRange.cpp',
     'nsReferencedElement.cpp',
     'nsScreen.cpp',
-    'nsScriptElement.cpp',
-    'nsScriptLoader.cpp',
     'nsScriptNameSpaceManager.cpp',
     'nsStructuredCloneContainer.cpp',
     'nsStubAnimationObserver.cpp',
     'nsStubDocumentObserver.cpp',
     'nsStubMutationObserver.cpp',
     'nsStyledElement.cpp',
     'nsStyleLinkElement.cpp',
     'nsSyncLoadService.cpp',
@@ -338,17 +332,16 @@ UNIFIED_SOURCES += [
     'nsXMLNameSpaceMap.cpp',
     'PartialSHistory.cpp',
     'Pose.cpp',
     'PostMessageEvent.cpp',
     'ProcessGlobal.cpp',
     'ResponsiveImageSelector.cpp',
     'SameProcessMessageQueue.cpp',
     'ScreenOrientation.cpp',
-    'ScriptSettings.cpp',
     'ShadowRoot.cpp',
     'StructuredCloneHolder.cpp',
     'StyleSheetList.cpp',
     'SubtleCrypto.cpp',
     'TabGroup.cpp',
     'Text.cpp',
     'TextInputProcessor.cpp',
     'ThirdPartyUtil.cpp',
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -27,17 +27,16 @@
 #include "nsIMutableArray.h"
 #include "nsContentPermissionHelper.h"
 #include "nsJSUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsWeakPtr.h"
-#include "ScriptSettings.h"
 
 using mozilla::Unused;          // <snicker>
 using namespace mozilla::dom;
 using namespace mozilla;
 
 #define kVisibilityChange "visibilitychange"
 
 class VisibilityChangeListener final : public nsIDOMEventListener
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Base class for the XML and HTML content sinks, which construct a
  * DOM based on information from the parser.
  */
 
 #include "nsContentSink.h"
-#include "nsScriptLoader.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/SRILogHelper.h"
 #include "nsStyleLinkElement.h"
 #include "nsIDocShell.h"
 #include "nsILoadContext.h"
 #include "nsCPrefetchService.h"
@@ -44,16 +43,17 @@
 #include "nsWidgetsCID.h"
 #include "nsIDOMNode.h"
 #include "mozAutoDocUpdate.h"
 #include "nsIWebNavigation.h"
 #include "nsGenericHTMLElement.h"
 #include "nsHTMLDNSPrefetch.h"
 #include "nsIObserverService.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsParserConstants.h"
 #include "nsSandboxFlags.h"
 
 using namespace mozilla;
 
 LazyLogModule gContentSinkLogModuleInfo("nscontentsink");
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsContentSink)
--- a/dom/base/nsContentSink.h
+++ b/dom/base/nsContentSink.h
@@ -31,23 +31,26 @@
 class nsIDocument;
 class nsIURI;
 class nsIChannel;
 class nsIDocShell;
 class nsIAtom;
 class nsIChannel;
 class nsIContent;
 class nsNodeInfoManager;
-class nsScriptLoader;
 class nsIApplicationCache;
 
 namespace mozilla {
 namespace css {
 class Loader;
 } // namespace css
+
+namespace dom {
+class ScriptLoader;
+} // namespace dom
 } // namespace mozilla
 
 #ifdef DEBUG
 
 extern mozilla::LazyLogModule gContentSinkLogModuleInfo;
 
 #define SINK_TRACE_CALLS              0x1
 #define SINK_TRACE_REFLOW             0x2
@@ -271,17 +274,17 @@ protected:
 protected:
 
   nsCOMPtr<nsIDocument>         mDocument;
   RefPtr<nsParserBase>        mParser;
   nsCOMPtr<nsIURI>              mDocumentURI;
   nsCOMPtr<nsIDocShell>         mDocShell;
   RefPtr<mozilla::css::Loader> mCSSLoader;
   RefPtr<nsNodeInfoManager>   mNodeInfoManager;
-  RefPtr<nsScriptLoader>      mScriptLoader;
+  RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
 
   // back off timer notification after count
   int32_t mBackoffCount;
 
   // Time of last notification
   // Note: mLastNotificationTime is only valid once mLayoutStarted is true.
   PRTime mLastNotificationTime;
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2021,17 +2021,17 @@ nsDocument::Init()
   // we use the default compartment for this document, instead of creating
   // wrapper in some random compartment when the document is exposed to js
   // via some events.
   nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(xpc::PrivilegedJunkScope());
   NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
   mScopeObject = do_GetWeakReference(global);
   MOZ_ASSERT(mScopeObject);
 
-  mScriptLoader = new nsScriptLoader(this);
+  mScriptLoader = new dom::ScriptLoader(this);
 
   mozilla::HoldJSObjects(this);
 
   return NS_OK;
 }
 
 void
 nsIDocument::DeleteAllProperties()
@@ -5006,17 +5006,17 @@ nsDocument::GetWindowInternal() const
       // mScriptGlobalObject is always the inner window, let's get the outer.
       win = inner->GetOuterWindow();
     }
   }
 
   return win;
 }
 
-nsScriptLoader*
+ScriptLoader*
 nsDocument::ScriptLoader()
 {
   return mScriptLoader;
 }
 
 bool
 nsDocument::InternalAllowXULXBL()
 {
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -26,17 +26,16 @@
 #include "nsIContent.h"
 #include "nsIPrincipal.h"
 #include "nsIParser.h"
 #include "nsBindingManager.h"
 #include "nsInterfaceHashtable.h"
 #include "nsJSThingHashtable.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
-#include "nsScriptLoader.h"
 #include "nsIRadioGroupContainer.h"
 #include "nsILayoutHistoryState.h"
 #include "nsIRequest.h"
 #include "nsILoadGroup.h"
 #include "nsTObserverArray.h"
 #include "nsStubMutationObserver.h"
 #include "nsIChannel.h"
 #include "nsCycleCollectionParticipant.h"
@@ -55,16 +54,17 @@
 #include "nsISecurityEventSink.h"
 #include "nsIChannelEventSink.h"
 #include "imgIRequest.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PendingAnimationTracker.h"
 #include "mozilla/dom/DOMImplementation.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/StyleSheetList.h"
 #include "nsDataHashtable.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Attributes.h"
 #include "nsIDOMXPathEvaluator.h"
 #include "jsfriendapi.h"
 #include "ImportManager.h"
 #include "mozilla/LinkedList.h"
@@ -737,17 +737,17 @@ public:
 
   virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) override;
 
   virtual nsIGlobalObject* GetScopeObject() const override;
   void SetScopeObject(nsIGlobalObject* aGlobal) override;
   /**
    * Get the script loader for this document
    */
-  virtual nsScriptLoader* ScriptLoader() override;
+  virtual mozilla::dom::ScriptLoader* ScriptLoader() override;
 
   /**
    * Add/Remove an element to the document's id and name hashes
    */
   virtual void AddToIdTable(Element* aElement, nsIAtom* aId) override;
   virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId) override;
   virtual void AddToNameTable(Element* aElement, nsIAtom* aName) override;
   virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) override;
@@ -1487,17 +1487,17 @@ public:
   // this nodeinfo comes from.
   static bool IsWebComponentsEnabled(mozilla::dom::NodeInfo* aNodeInfo);
   // Check whether web components are enabled for the given window.
   static bool IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow);
 
   RefPtr<mozilla::EventListenerManager> mListenerManager;
   RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
   RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
-  RefPtr<nsScriptLoader> mScriptLoader;
+  RefPtr<mozilla::dom::ScriptLoader> mScriptLoader;
   nsDocHeaderData* mHeaderData;
   /* mIdentifierMap works as follows for IDs:
    * 1) Attribute changes affect the table immediately (removing and adding
    *    entries as needed).
    * 2) Removals from the DOM affect the table immediately
    * 3) Additions to the DOM always update existing entries for names, and add
    *    new ones for IDs.
    */
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -13,17 +13,17 @@
 #include "nsDOMClassInfoID.h"
 #include "nsError.h"
 #include "nsIXPConnect.h"
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "nsJSUtils.h"
 #include "nsJSPrincipals.h"
 #include "nsNetUtil.h"
-#include "nsScriptLoader.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsFrameLoader.h"
 #include "nsIInputStream.h"
 #include "nsIXULRuntime.h"
 #include "nsIScriptError.h"
 #include "nsIConsoleService.h"
 #include "nsIMemoryReporter.h"
 #include "nsIProtocolHandler.h"
 #include "nsIScriptSecurityManager.h"
@@ -1635,19 +1635,19 @@ nsMessageManagerScriptExecutor::TryCache
       if (avail64 > UINT32_MAX) {
         return;
       }
       nsCString buffer;
       uint32_t avail = (uint32_t)std::min(avail64, (uint64_t)UINT32_MAX);
       if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
         return;
       }
-      nsScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
-                                     EmptyString(), nullptr,
-                                     dataStringBuf, dataStringLength);
+      ScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), avail,
+                                   EmptyString(), nullptr,
+                                   dataStringBuf, dataStringLength);
     }
 
     JS::SourceBufferHolder srcBuf(dataStringBuf, dataStringLength,
                                   JS::SourceBufferHolder::GiveOwnership);
 
     if (!dataStringBuf || dataStringLength == 0) {
       return;
     }
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -59,17 +59,17 @@
 // Helper Classes
 #include "nsJSUtils.h"
 #include "jsapi.h"              // for JSAutoRequest
 #include "jswrapper.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsReadableUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsJSEnvironment.h"
-#include "ScriptSettings.h"
+#include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Unused.h"
 
 // Other Classes
 #include "mozilla/dom/BarProps.h"
 #include "nsContentCID.h"
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -87,17 +87,16 @@ class nsIRequest;
 class nsIRunnable;
 class nsIStreamListener;
 class nsIStructuredCloneContainer;
 class nsIURI;
 class nsIVariant;
 class nsViewManager;
 class nsPresContext;
 class nsRange;
-class nsScriptLoader;
 class nsSMILAnimationController;
 class nsSVGElement;
 class nsTextNode;
 class nsWindowSizes;
 class nsDOMCaretPosition;
 class nsViewportInfo;
 class nsIGlobalObject;
 struct nsCSSSelectorList;
@@ -149,16 +148,17 @@ class Link;
 class Location;
 class MediaQueryList;
 class GlobalObject;
 class NodeFilter;
 class NodeIterator;
 enum class OrientationType : uint8_t;
 class ProcessingInstruction;
 class Promise;
+class ScriptLoader;
 class StyleSheetList;
 class SVGDocument;
 class SVGSVGElement;
 class Touch;
 class TouchList;
 class TreeWalker;
 class XPathEvaluator;
 class XPathExpression;
@@ -1363,17 +1363,17 @@ public:
   {
     nsPIDOMWindowInner* window = GetInnerWindow();
     return window ? window->WindowID() : 0;
   }
 
   /**
    * Get the script loader for this document
    */
-  virtual nsScriptLoader* ScriptLoader() = 0;
+  virtual mozilla::dom::ScriptLoader* ScriptLoader() = 0;
 
   /**
    * Add/Remove an element to the document's id and name hashes
    */
   virtual void AddToIdTable(Element* aElement, nsIAtom* aId) = 0;
   virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId) = 0;
   virtual void AddToNameTable(Element* aElement, nsIAtom* aName) = 0;
   virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) = 0;
--- a/dom/base/nsInProcessTabChildGlobal.cpp
+++ b/dom/base/nsInProcessTabChildGlobal.cpp
@@ -6,23 +6,23 @@
 
 #include "nsInProcessTabChildGlobal.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsComponentManagerUtils.h"
-#include "nsScriptLoader.h"
 #include "nsFrameLoader.h"
 #include "xpcpublic.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsDOMClassInfoID.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/SameProcessMessageQueue.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 
 bool
 nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
                                                  const nsAString& aMessage,
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -32,17 +32,16 @@
 #include "nsIAtom.h"
 #include "nsContentUtils.h"
 #include "mozilla/EventDispatcher.h"
 #include "nsIContent.h"
 #include "nsCycleCollector.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsIXULRuntime.h"
 #include "nsTextFormatter.h"
-#include "ScriptSettings.h"
 #ifdef XP_WIN
 #include <process.h>
 #define getpid _getpid
 #else
 #include <unistd.h> // for getpid()
 #endif
 #include "xpcpublic.h"
 
@@ -55,16 +54,17 @@
 #include "prmem.h"
 #include "WrapperFactory.h"
 #include "nsGlobalWindow.h"
 #include "nsScriptNameSpaceManager.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/DOMExceptionBinding.h"
 #include "mozilla/dom/ErrorEvent.h"
+#include "mozilla/dom/ScriptSettings.h"
 #include "nsAXPCNativeCallContext.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 #include "mozilla/SystemGroup.h"
 
 #include "nsJSPrincipals.h"
 
 #ifdef XP_MACOSX
 // AssertMacros.h defines 'check' and conflicts with AccessCheck.h
--- a/dom/base/test/test_script_loader_js_cache.html
+++ b/dom/base/test/test_script_loader_js_cache.html
@@ -1,25 +1,25 @@
 <!DOCTYPE html>
 <html>
 <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=900784 -->
 <!-- The JS bytecode cache is not supposed to be observable. To make it
-     observable, the nsScriptLoader is instrumented to trigger events on the
+     observable, the ScriptLoader is instrumented to trigger events on the
      script tag. These events are followed to reconstruct the code path taken by
      the script loader and associate a simple name which is checked in these
      test cases.
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for saving and loading bytecode in/from the necko cache</title>
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <script type="application/javascript">
     // This is the state machine of the trace events produced by the
-    // nsScriptLoader. This state machine is used to give a name to each
+    // ScriptLoader. This state machine is used to give a name to each
     // code path, such that we can assert each code path with a single word.
     var scriptLoaderStateMachine = {
       "scriptloader_load_source": {
         "scriptloader_encode_and_execute": {
           "scriptloader_bytecode_saved": "bytecode_saved",
           "scriptloader_bytecode_failed": "bytecode_failed"
         },
         "scriptloader_execute": "source_exec"
@@ -107,17 +107,17 @@
         document.body.removeChild(iframe);
       });
       return statePromise;
     }
 
     promise_test(async function() {
       // Setting dom.expose_test_interfaces pref causes the
       // nsScriptLoadRequest to fire event on script tags, with information
-      // about its internal state. The nsScriptLoader source send events to
+      // about its internal state. The ScriptLoader source send events to
       // trace these and resolve a promise with the path taken by the
       // script loader.
       //
       // Setting dom.script_loader.force_bytecode_cache causes the
       // nsScriptLoadRequest to force all the conditions necessary to make a
       // script be saved as bytecode in the alternate data storage provided
       // by the channel (necko cache).
       await SpecialPowers.pushPrefEnv({set: [
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -7,27 +7,27 @@
 #include "mozilla/dom/Console.h"
 #include "mozilla/dom/ConsoleBinding.h"
 
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/Performance.h"
+#include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/WorkletGlobalScope.h"
 #include "mozilla/Maybe.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDocument.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsGlobalWindow.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
-#include "ScriptSettings.h"
 #include "WorkerPrivate.h"
 #include "WorkerRunnable.h"
 #include "WorkerScope.h"
 #include "xpcpublic.h"
 #include "nsContentUtils.h"
 #include "nsDocShell.h"
 #include "nsProxyRelease.h"
 #include "mozilla/ConsoleTimelineMarker.h"
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsContentUtils.h"
 #include "nsIDocument.h"
 #include "mozilla/Sprintf.h"
 #include "nsGlobalWindow.h"
-#include "ScriptSettings.h"
+#include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/Likely.h"
 
 namespace mozilla {
 
 using namespace dom;
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -33,17 +33,17 @@ JSObject*
 HTMLScriptElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLScriptElementBinding::Wrap(aCx, this, aGivenProto);
 }
 
 HTMLScriptElement::HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                                      FromParser aFromParser)
   : nsGenericHTMLElement(aNodeInfo)
-  , nsScriptElement(aFromParser)
+  , ScriptElement(aFromParser)
 {
   AddMutationObserver(this);
 }
 
 HTMLScriptElement::~HTMLScriptElement()
 {
 }
 
--- a/dom/html/HTMLScriptElement.h
+++ b/dom/html/HTMLScriptElement.h
@@ -3,26 +3,26 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLScriptElement_h
 #define mozilla_dom_HTMLScriptElement_h
 
 #include "nsIDOMHTMLScriptElement.h"
-#include "nsScriptElement.h"
 #include "nsGenericHTMLElement.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/dom/ScriptElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLScriptElement final : public nsGenericHTMLElement,
                                 public nsIDOMHTMLScriptElement,
-                                public nsScriptElement
+                                public ScriptElement
 {
 public:
   using Element::GetText;
   using Element::SetText;
 
   HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                     FromParser aFromParser);
 
@@ -92,16 +92,17 @@ public:
   void SetAsync(bool aValue, ErrorResult& rv);
   bool NoModule();
   void SetNoModule(bool aValue, ErrorResult& rv);
 
 protected:
   virtual ~HTMLScriptElement();
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
-  // nsScriptElement
+
+  // ScriptElement
   virtual bool HasScriptContent() override;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HTMLScriptElement_h
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -44,17 +44,16 @@
 #include "nsViewManager.h"
 #include "nsIWidget.h"
 #include "nsRange.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIDocShell.h"
 #include "nsNameSpaceManager.h"
 #include "nsError.h"
-#include "nsScriptLoader.h"
 #include "nsIPrincipal.h"
 #include "nsContainerFrame.h"
 #include "nsStyleUtil.h"
 
 #include "nsPresState.h"
 #include "nsILayoutHistoryState.h"
 
 #include "nsHTMLParts.h"
@@ -86,16 +85,17 @@
 #include "nsTextNode.h"
 #include "HTMLBRElement.h"
 #include "HTMLMenuElement.h"
 #include "nsDOMMutationObserver.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/FromParser.h"
 #include "mozilla/dom/Link.h"
 #include "mozilla/BloomFilter.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 #include "nsVariant.h"
 #include "nsDOMTokenList.h"
 #include "nsThreadUtils.h"
 #include "nsTextFragment.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/TouchEvent.h"
 #include "mozilla/ErrorResult.h"
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -14,20 +14,20 @@
 
 #include "nsContentSink.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIHTMLContentSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsScriptLoader.h"
 #include "nsIURI.h"
 #include "nsIContentViewer.h"
 #include "mozilla/dom/NodeInfo.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsToken.h"
 #include "nsIAppShell.h"
 #include "nsCRT.h"
 #include "prtime.h"
 #include "mozilla/Logging.h"
 #include "nsNodeUtils.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -11,29 +11,29 @@
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MessageChannel.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/MessagePortChild.h"
 #include "mozilla/dom/PMessagePort.h"
+#include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerScope.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/MessagePortTimelineMarker.h"
 #include "mozilla/TimelineConsumers.h"
 #include "mozilla/TimelineMarker.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsPresContext.h"
-#include "ScriptSettings.h"
 #include "SharedMessagePortMessage.h"
 
 #include "nsIBFCacheEntry.h"
 #include "nsIDocument.h"
 #include "nsIDOMFileList.h"
 #include "nsIPresShell.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -99,16 +99,17 @@ DIRS += [
     'manifest',
     'vr',
     'u2f',
     'console',
     'performance',
     'webbrowserpersist',
     'xhr',
     'worklet',
+    'script',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     DIRS += ['plugins/ipc/hangui']
 
 if CONFIG['MOZ_SECUREELEMENT']:
     DIRS += ['secureelement']
 
rename from dom/base/nsScriptElement.cpp
rename to dom/script/ScriptElement.cpp
--- a/dom/base/nsScriptElement.cpp
+++ b/dom/script/ScriptElement.cpp
@@ -1,66 +1,66 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsScriptElement.h"
+#include "ScriptElement.h"
+#include "ScriptLoader.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/Element.h"
 #include "nsContentUtils.h"
 #include "nsPresContext.h"
-#include "nsScriptLoader.h"
 #include "nsIParser.h"
 #include "nsGkAtoms.h"
 #include "nsContentSink.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMETHODIMP
-nsScriptElement::ScriptAvailable(nsresult aResult,
-                                 nsIScriptElement *aElement,
-                                 bool aIsInline,
-                                 nsIURI *aURI,
-                                 int32_t aLineNo)
+ScriptElement::ScriptAvailable(nsresult aResult,
+                               nsIScriptElement *aElement,
+                               bool aIsInline,
+                               nsIURI *aURI,
+                               int32_t aLineNo)
 {
   if (!aIsInline && NS_FAILED(aResult)) {
     nsCOMPtr<nsIParser> parser = do_QueryReferent(mCreatorParser);
     if (parser) {
       parser->PushDefinedInsertionPoint();
     }
     nsresult rv = FireErrorEvent();
     if (parser) {
       parser->PopDefinedInsertionPoint();
     }
     return rv;
   }
   return NS_OK;
 }
 
 /* virtual */ nsresult
-nsScriptElement::FireErrorEvent()
+ScriptElement::FireErrorEvent()
 {
   nsCOMPtr<nsIContent> cont =
     do_QueryInterface((nsIScriptElement*) this);
 
   return nsContentUtils::DispatchTrustedEvent(cont->OwnerDoc(),
                                               cont,
                                               NS_LITERAL_STRING("error"),
                                               false /* bubbles */,
                                               false /* cancelable */);
 }
 
 NS_IMETHODIMP
-nsScriptElement::ScriptEvaluated(nsresult aResult,
-                                 nsIScriptElement *aElement,
-                                 bool aIsInline)
+ScriptElement::ScriptEvaluated(nsresult aResult,
+                               nsIScriptElement *aElement,
+                               bool aIsInline)
 {
   nsresult rv = NS_OK;
   if (!aIsInline) {
     nsCOMPtr<nsIContent> cont =
       do_QueryInterface((nsIScriptElement*) this);
 
     RefPtr<nsPresContext> presContext =
       nsContentUtils::GetContextForContent(cont);
@@ -73,54 +73,54 @@ nsScriptElement::ScriptEvaluated(nsresul
 
     EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
   }
 
   return rv;
 }
 
 void
-nsScriptElement::CharacterDataChanged(nsIDocument *aDocument,
-                                      nsIContent* aContent,
-                                      CharacterDataChangeInfo* aInfo)
+ScriptElement::CharacterDataChanged(nsIDocument *aDocument,
+                                    nsIContent* aContent,
+                                    CharacterDataChangeInfo* aInfo)
 {
   MaybeProcessScript();
 }
 
 void
-nsScriptElement::AttributeChanged(nsIDocument* aDocument,
-                                  Element* aElement,
-                                  int32_t aNameSpaceID,
-                                  nsIAtom* aAttribute,
-                                  int32_t aModType,
-                                  const nsAttrValue* aOldValue)
+ScriptElement::AttributeChanged(nsIDocument* aDocument,
+                                Element* aElement,
+                                int32_t aNameSpaceID,
+                                nsIAtom* aAttribute,
+                                int32_t aModType,
+                                const nsAttrValue* aOldValue)
 {
   MaybeProcessScript();
 }
 
 void
-nsScriptElement::ContentAppended(nsIDocument* aDocument,
-                                 nsIContent* aContainer,
-                                 nsIContent* aFirstNewContent,
-                                 int32_t aNewIndexInContainer)
+ScriptElement::ContentAppended(nsIDocument* aDocument,
+                               nsIContent* aContainer,
+                               nsIContent* aFirstNewContent,
+                               int32_t aNewIndexInContainer)
 {
   MaybeProcessScript();
 }
 
 void
-nsScriptElement::ContentInserted(nsIDocument *aDocument,
-                                 nsIContent* aContainer,
-                                 nsIContent* aChild,
-                                 int32_t aIndexInContainer)
+ScriptElement::ContentInserted(nsIDocument *aDocument,
+                               nsIContent* aContainer,
+                               nsIContent* aChild,
+                               int32_t aIndexInContainer)
 {
   MaybeProcessScript();
 }
 
 bool
-nsScriptElement::MaybeProcessScript()
+ScriptElement::MaybeProcessScript()
 {
   nsCOMPtr<nsIContent> cont =
     do_QueryInterface((nsIScriptElement*) this);
 
   NS_ASSERTION(cont->DebugGetSlots()->mMutationObservers.Contains(this),
                "You forgot to add self as observer");
 
   if (mAlreadyStarted || !mDoneAddingChildren ||
@@ -140,11 +140,11 @@ nsScriptElement::MaybeProcessScript()
       nsCOMPtr<nsIDocument> parserDoc = do_QueryInterface(sink->GetTarget());
       if (ownerDoc != parserDoc) {
         // Willful violation of HTML5 as of 2010-12-01
         return false;
       }
     }
   }
 
-  RefPtr<nsScriptLoader> loader = ownerDoc->ScriptLoader();
+  RefPtr<ScriptLoader> loader = ownerDoc->ScriptLoader();
   return loader->ProcessScriptElement(this);
 }
rename from dom/base/nsScriptElement.h
rename to dom/script/ScriptElement.h
--- a/dom/base/nsScriptElement.h
+++ b/dom/script/ScriptElement.h
@@ -1,42 +1,45 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsScriptElement_h
-#define nsScriptElement_h
+#ifndef mozilla_dom_ScriptElement_h
+#define mozilla_dom_ScriptElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsIScriptLoaderObserver.h"
 #include "nsIScriptElement.h"
 #include "nsStubMutationObserver.h"
 
+namespace mozilla {
+namespace dom {
+
 /**
  * Baseclass useful for script elements (such as <xhtml:script> and
  * <svg:script>). Currently the class assumes that only the 'src'
  * attribute and the children of the class affect what script to execute.
  */
 
-class nsScriptElement : public nsIScriptElement,
-                        public nsStubMutationObserver
+class ScriptElement : public nsIScriptElement,
+                      public nsStubMutationObserver
 {
 public:
   // nsIScriptLoaderObserver
   NS_DECL_NSISCRIPTLOADEROBSERVER
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
 
-  explicit nsScriptElement(mozilla::dom::FromParser aFromParser)
+  explicit ScriptElement(FromParser aFromParser)
     : nsIScriptElement(aFromParser)
   {
   }
 
   virtual nsresult FireErrorEvent() override;
 
 protected:
   // Internal methods
@@ -44,9 +47,12 @@ protected:
   /**
    * Check if this element contains any script, linked or inline
    */
   virtual bool HasScriptContent() = 0;
 
   virtual bool MaybeProcessScript() override;
 };
 
-#endif // nsScriptElement_h
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_ScriptElement_h
rename from dom/base/nsScriptLoader.cpp
rename to dom/script/ScriptLoader.cpp
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * A class that handles loading and evaluation of <script> elements.
  */
 
-#include "nsScriptLoader.h"
+#include "ScriptLoader.h"
 
 #include "prsystem.h"
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "js/Utility.h"
 #include "xpcpublic.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIContent.h"
@@ -54,51 +54,52 @@
 #include "nsContentTypeParser.h"
 #include "nsINetworkPredictor.h"
 #include "ImportManager.h"
 #include "mozilla/dom/EncodingUtils.h"
 #include "mozilla/ConsoleReportCollector.h"
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "nsIScriptError.h"
 #include "nsIOutputStream.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
-
 using JS::SourceBufferHolder;
 
+namespace mozilla {
+namespace dom {
+
 static LazyLogModule gCspPRLog("CSP");
 static LazyLogModule gScriptLoaderLog("ScriptLoader");
 
 #define LOG_VERBOSE(args)                                                     \
   MOZ_LOG(gScriptLoaderLog, mozilla::LogLevel::Verbose, args)
 #define LOG(args)                                                             \
   MOZ_LOG(gScriptLoaderLog, mozilla::LogLevel::Debug, args)
 #define LOG_WARN(args)                                                        \
   MOZ_LOG(gScriptLoaderLog, mozilla::LogLevel::Warning, args)
 #define LOG_ERROR(args)                                                       \
   MOZ_LOG(gScriptLoaderLog, mozilla::LogLevel::Error, args)
 
 #define LOG_ENABLED() MOZ_LOG_TEST(gScriptLoaderLog, mozilla::LogLevel::Debug)
 
-// These are the Alternate Data MIME type used by the nsScriptLoader to
+// These are the Alternate Data MIME type used by the ScriptLoader to
 // register and read bytecode out of the nsCacheInfoChannel.
 static NS_NAMED_LITERAL_CSTRING(
   kBytecodeMimeType, "javascript/moz-bytecode-" NS_STRINGIFY(MOZ_BUILDID));
 static NS_NAMED_LITERAL_CSTRING(kNullMimeType, "javascript/null");
 
 void
-ImplCycleCollectionUnlink(nsScriptLoadRequestList& aField);
+ImplCycleCollectionUnlink(ScriptLoadRequestList& aField);
 
 void
 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            nsScriptLoadRequestList& aField,
+                            ScriptLoadRequestList& aField,
                             const char* aName,
                             uint32_t aFlags = 0);
 
 // This macro is used to wrap a tracing mechanism which is scheduling events
 // which are then used by the JavaScript code of test cases to track the code
 // path to verify the optimizations are working as expected.
 #define TRACE_FOR_TEST(elem, str)                               \
   PR_BEGIN_MACRO                                                \
@@ -139,114 +140,114 @@ TestingDispatchEvent(nsIScriptElement* a
   }
 
   RefPtr<AsyncEventDispatcher> dispatcher =
     new AsyncEventDispatcher(target, aEventType, true, false);
   return dispatcher->PostDOMEvent();
 }
 
 //////////////////////////////////////////////////////////////
-// nsScriptLoadRequest
+// ScriptLoadRequest
 //////////////////////////////////////////////////////////////
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoadRequest)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptLoadRequest)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoadRequest)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoadRequest)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsScriptLoadRequest)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptLoadRequest)
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(ScriptLoadRequest)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ScriptLoadRequest)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheInfo)
   tmp->DropBytecodeCacheReferences();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ScriptLoadRequest)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheInfo)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ScriptLoadRequest)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScript)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-nsScriptLoadRequest::~nsScriptLoadRequest()
+ScriptLoadRequest::~ScriptLoadRequest()
 {
   // We should always clean up any off-thread script parsing resources.
   MOZ_ASSERT(!mOffThreadToken);
 
   // But play it safe in release builds and try to clean them up here
   // as a fail safe.
   MaybeCancelOffThreadScript();
 
   if (mScript) {
     DropBytecodeCacheReferences();
   }
 }
 
 void
-nsScriptLoadRequest::SetReady()
+ScriptLoadRequest::SetReady()
 {
   MOZ_ASSERT(mProgress != Progress::Ready);
   mProgress = Progress::Ready;
 }
 
 void
-nsScriptLoadRequest::Cancel()
+ScriptLoadRequest::Cancel()
 {
   MaybeCancelOffThreadScript();
   mIsCanceled = true;
 }
 
 void
-nsScriptLoadRequest::MaybeCancelOffThreadScript()
+ScriptLoadRequest::MaybeCancelOffThreadScript()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mOffThreadToken) {
     return;
   }
 
   JSContext* cx = danger::GetJSContext();
-  // Follow the same conditions as nsScriptLoader::AttemptAsyncScriptCompile
+  // Follow the same conditions as ScriptLoader::AttemptAsyncScriptCompile
   if (IsModuleRequest()) {
     JS::CancelOffThreadModule(cx, mOffThreadToken);
   } else if (IsSource()) {
     JS::CancelOffThreadScript(cx, mOffThreadToken);
   } else {
     MOZ_ASSERT(IsBytecode());
     JS::CancelOffThreadScriptDecoder(cx, mOffThreadToken);
   }
   mOffThreadToken = nullptr;
 }
 
 //////////////////////////////////////////////////////////////
-// nsModuleLoadRequest
+// ModuleLoadRequest
 //////////////////////////////////////////////////////////////
 
 // A load request for a module, created for every top level module script and
-// every module import.  Load request can share an nsModuleScript if there are
+// every module import.  Load request can share an ModuleScript if there are
 // multiple imports of the same module.
 
-class nsModuleLoadRequest final : public nsScriptLoadRequest
+class ModuleLoadRequest final : public ScriptLoadRequest
 {
-  ~nsModuleLoadRequest() {}
-
-  nsModuleLoadRequest(const nsModuleLoadRequest& aOther) = delete;
-  nsModuleLoadRequest(nsModuleLoadRequest&& aOther) = delete;
+  ~ModuleLoadRequest() = default;
+
+  ModuleLoadRequest(const ModuleLoadRequest& aOther) = delete;
+  ModuleLoadRequest(ModuleLoadRequest&& aOther) = delete;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
-
-  nsModuleLoadRequest(nsIScriptElement* aElement,
-                      uint32_t aVersion,
-                      CORSMode aCORSMode,
-                      const SRIMetadata& aIntegrity,
-                      nsScriptLoader* aLoader);
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
+
+  ModuleLoadRequest(nsIScriptElement* aElement,
+                    uint32_t aVersion,
+                    CORSMode aCORSMode,
+                    const SRIMetadata& aIntegrity,
+                    ScriptLoader* aLoader);
 
   bool IsTopLevel() const {
     return mIsTopLevel;
   }
 
   void SetReady() override;
   void Cancel() override;
 
@@ -257,160 +258,160 @@ public:
   // Is this a request for a top level module script or an import?
   bool mIsTopLevel;
 
   // The base URL used for resolving relative module imports.
   nsCOMPtr<nsIURI> mBaseURL;
 
   // Pointer to the script loader, used to trigger actions when the module load
   // finishes.
-  RefPtr<nsScriptLoader> mLoader;
+  RefPtr<ScriptLoader> mLoader;
 
   // The importing module, or nullptr for top level module scripts.  Used to
   // implement the ancestor list checked when fetching module dependencies.
-  RefPtr<nsModuleLoadRequest> mParent;
+  RefPtr<ModuleLoadRequest> mParent;
 
   // Set to a module script object after a successful load or nullptr on
   // failure.
-  RefPtr<nsModuleScript> mModuleScript;
+  RefPtr<ModuleScript> mModuleScript;
 
   // A promise that is completed on successful load of this module and all of
   // its dependencies, indicating that the module is ready for instantiation and
   // evaluation.
   MozPromiseHolder<GenericPromise> mReady;
 
   // Array of imported modules.
-  nsTArray<RefPtr<nsModuleLoadRequest>> mImports;
+  nsTArray<RefPtr<ModuleLoadRequest>> mImports;
 };
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsModuleLoadRequest)
-NS_INTERFACE_MAP_END_INHERITING(nsScriptLoadRequest)
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest,
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest)
+NS_INTERFACE_MAP_END_INHERITING(ScriptLoadRequest)
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED(ModuleLoadRequest, ScriptLoadRequest,
                                    mBaseURL,
                                    mLoader,
                                    mParent,
                                    mModuleScript,
                                    mImports)
 
-NS_IMPL_ADDREF_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
-NS_IMPL_RELEASE_INHERITED(nsModuleLoadRequest, nsScriptLoadRequest)
-
-nsModuleLoadRequest::nsModuleLoadRequest(nsIScriptElement* aElement,
-                                         uint32_t aVersion,
-                                         CORSMode aCORSMode,
-                                         const SRIMetadata &aIntegrity,
-                                         nsScriptLoader* aLoader)
-  : nsScriptLoadRequest(nsScriptKind::Module,
-                        aElement,
-                        aVersion,
-                        aCORSMode,
-                        aIntegrity),
+NS_IMPL_ADDREF_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
+NS_IMPL_RELEASE_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
+
+ModuleLoadRequest::ModuleLoadRequest(nsIScriptElement* aElement,
+                                     uint32_t aVersion,
+                                     CORSMode aCORSMode,
+                                     const SRIMetadata &aIntegrity,
+                                     ScriptLoader* aLoader)
+  : ScriptLoadRequest(ScriptKind::Module,
+                      aElement,
+                      aVersion,
+                      aCORSMode,
+                      aIntegrity),
     mIsTopLevel(true),
     mLoader(aLoader)
 {}
 
-inline nsModuleLoadRequest*
-nsScriptLoadRequest::AsModuleRequest()
+inline ModuleLoadRequest*
+ScriptLoadRequest::AsModuleRequest()
 {
   MOZ_ASSERT(IsModuleRequest());
-  return static_cast<nsModuleLoadRequest*>(this);
+  return static_cast<ModuleLoadRequest*>(this);
 }
 
-void nsModuleLoadRequest::Cancel()
+void ModuleLoadRequest::Cancel()
 {
-  nsScriptLoadRequest::Cancel();
+  ScriptLoadRequest::Cancel();
   mModuleScript = nullptr;
-  mProgress = nsScriptLoadRequest::Progress::Ready;
+  mProgress = ScriptLoadRequest::Progress::Ready;
   for (size_t i = 0; i < mImports.Length(); i++) {
     mImports[i]->Cancel();
   }
   mReady.RejectIfExists(NS_ERROR_FAILURE, __func__);
 }
 
 void
-nsModuleLoadRequest::SetReady()
+ModuleLoadRequest::SetReady()
 {
 #ifdef DEBUG
   for (size_t i = 0; i < mImports.Length(); i++) {
     MOZ_ASSERT(mImports[i]->IsReadyToRun());
   }
 #endif
 
-  nsScriptLoadRequest::SetReady();
+  ScriptLoadRequest::SetReady();
   mReady.ResolveIfExists(true, __func__);
 }
 
 void
-nsModuleLoadRequest::ModuleLoaded()
+ModuleLoadRequest::ModuleLoaded()
 {
   // A module that was found to be marked as fetching in the module map has now
   // been loaded.
 
   mModuleScript = mLoader->GetFetchedModule(mURI);
   mLoader->StartFetchingModuleDependencies(this);
 }
 
 void
-nsModuleLoadRequest::DependenciesLoaded()
+ModuleLoadRequest::DependenciesLoaded()
 {
   // The module and all of its dependencies have been successfully fetched and
   // compiled.
 
   if (!mLoader->InstantiateModuleTree(this)) {
     LoadFailed();
     return;
   }
 
   SetReady();
   mLoader->ProcessLoadedModuleTree(this);
   mLoader = nullptr;
   mParent = nullptr;
 }
 
 void
-nsModuleLoadRequest::LoadFailed()
+ModuleLoadRequest::LoadFailed()
 {
   Cancel();
   mLoader->ProcessLoadedModuleTree(this);
   mLoader = nullptr;
   mParent = nullptr;
 }
 
 //////////////////////////////////////////////////////////////
-// nsModuleScript
+// ModuleScript
 //////////////////////////////////////////////////////////////
 
 // A single module script.  May be used to satisfy multiple load requests.
 
-class nsModuleScript final : public nsISupports
+class ModuleScript final : public nsISupports
 {
   enum InstantiationState {
     Uninstantiated,
     Instantiated,
     Errored
   };
 
-  RefPtr<nsScriptLoader> mLoader;
+  RefPtr<ScriptLoader> mLoader;
   nsCOMPtr<nsIURI> mBaseURL;
   JS::Heap<JSObject*> mModuleRecord;
   JS::Heap<JS::Value> mException;
   InstantiationState mInstantiationState;
 
-  ~nsModuleScript();
+  ~ModuleScript();
 
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsModuleScript)
-
-  nsModuleScript(nsScriptLoader* aLoader,
-                 nsIURI* aBaseURL,
-                 JS::Handle<JSObject*> aModuleRecord);
-
-  nsScriptLoader* Loader() const { return mLoader; }
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ModuleScript)
+
+  ModuleScript(ScriptLoader* aLoader,
+               nsIURI* aBaseURL,
+               JS::Handle<JSObject*> aModuleRecord);
+
+  ScriptLoader* Loader() const { return mLoader; }
   JSObject* ModuleRecord() const { return mModuleRecord; }
   JS::Value Exception() const { return mException; }
   nsIURI* BaseURL() const { return mBaseURL; }
 
   void SetInstantiationResult(JS::Handle<JS::Value> aMaybeException);
   bool IsUninstantiated() const {
     return mInstantiationState == Uninstantiated;
   }
@@ -419,41 +420,41 @@ public:
   }
   bool InstantiationFailed() const {
     return mInstantiationState == Errored;
   }
 
   void UnlinkModuleRecord();
 };
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsModuleScript)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ModuleScript)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsModuleScript)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_CLASS(ModuleScript)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ModuleScript)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoader)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mBaseURL)
   tmp->UnlinkModuleRecord();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ModuleScript)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLoader)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsModuleScript)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ModuleScript)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mModuleRecord)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mException)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsModuleScript)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsModuleScript)
-
-nsModuleScript::nsModuleScript(nsScriptLoader *aLoader, nsIURI* aBaseURL,
-                               JS::Handle<JSObject*> aModuleRecord)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleScript)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ModuleScript)
+
+ModuleScript::ModuleScript(ScriptLoader *aLoader, nsIURI* aBaseURL,
+                           JS::Handle<JSObject*> aModuleRecord)
  : mLoader(aLoader),
    mBaseURL(aBaseURL),
    mModuleRecord(aModuleRecord),
    mInstantiationState(Uninstantiated)
 {
   MOZ_ASSERT(mLoader);
   MOZ_ASSERT(mBaseURL);
   MOZ_ASSERT(mModuleRecord);
@@ -461,192 +462,192 @@ nsModuleScript::nsModuleScript(nsScriptL
 
   // Make module's host defined field point to this module script object.
   // This is cleared in the UnlinkModuleRecord().
   JS::SetModuleHostDefinedField(mModuleRecord, JS::PrivateValue(this));
   HoldJSObjects(this);
 }
 
 void
-nsModuleScript::UnlinkModuleRecord()
+ModuleScript::UnlinkModuleRecord()
 {
   // Remove module's back reference to this object request if present.
   if (mModuleRecord) {
     MOZ_ASSERT(JS::GetModuleHostDefinedField(mModuleRecord).toPrivate() ==
                this);
     JS::SetModuleHostDefinedField(mModuleRecord, JS::UndefinedValue());
   }
   mModuleRecord = nullptr;
   mException.setUndefined();
 }
 
-nsModuleScript::~nsModuleScript()
+ModuleScript::~ModuleScript()
 {
   if (mModuleRecord) {
     // The object may be destroyed without being unlinked first.
     UnlinkModuleRecord();
   }
   DropJSObjects(this);
 }
 
 void
-nsModuleScript::SetInstantiationResult(JS::Handle<JS::Value> aMaybeException)
+ModuleScript::SetInstantiationResult(JS::Handle<JS::Value> aMaybeException)
 {
   MOZ_ASSERT(mInstantiationState == Uninstantiated);
   MOZ_ASSERT(mModuleRecord);
   MOZ_ASSERT(mException.isUndefined());
 
   if (aMaybeException.isUndefined()) {
     mInstantiationState = Instantiated;
   } else {
     mModuleRecord = nullptr;
     mException = aMaybeException;
     mInstantiationState = Errored;
   }
 }
 
 //////////////////////////////////////////////////////////////
 
-// nsScriptLoadRequestList
+// ScriptLoadRequestList
 //////////////////////////////////////////////////////////////
 
-nsScriptLoadRequestList::~nsScriptLoadRequestList()
+ScriptLoadRequestList::~ScriptLoadRequestList()
 {
   Clear();
 }
 
 void
-nsScriptLoadRequestList::Clear()
+ScriptLoadRequestList::Clear()
 {
   while (!isEmpty()) {
-    RefPtr<nsScriptLoadRequest> first = StealFirst();
+    RefPtr<ScriptLoadRequest> first = StealFirst();
     first->Cancel();
     // And just let it go out of scope and die.
   }
 }
 
 #ifdef DEBUG
 bool
-nsScriptLoadRequestList::Contains(nsScriptLoadRequest* aElem) const
+ScriptLoadRequestList::Contains(ScriptLoadRequest* aElem) const
 {
-  for (const nsScriptLoadRequest* req = getFirst();
+  for (const ScriptLoadRequest* req = getFirst();
        req; req = req->getNext()) {
     if (req == aElem) {
       return true;
     }
   }
 
   return false;
 }
 #endif // DEBUG
 
 inline void
-ImplCycleCollectionUnlink(nsScriptLoadRequestList& aField)
+ImplCycleCollectionUnlink(ScriptLoadRequestList& aField)
 {
   while (!aField.isEmpty()) {
-    RefPtr<nsScriptLoadRequest> first = aField.StealFirst();
+    RefPtr<ScriptLoadRequest> first = aField.StealFirst();
   }
 }
 
 inline void
 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            nsScriptLoadRequestList& aField,
+                            ScriptLoadRequestList& aField,
                             const char* aName,
                             uint32_t aFlags)
 {
-  for (nsScriptLoadRequest* request = aField.getFirst();
+  for (ScriptLoadRequest* request = aField.getFirst();
        request; request = request->getNext())
   {
     CycleCollectionNoteChild(aCallback, request, aName, aFlags);
   }
 }
 
 //////////////////////////////////////////////////////////////
-// nsScriptLoader::PreloadInfo
+// ScriptLoader::PreloadInfo
 //////////////////////////////////////////////////////////////
 
 inline void
-ImplCycleCollectionUnlink(nsScriptLoader::PreloadInfo& aField)
+ImplCycleCollectionUnlink(ScriptLoader::PreloadInfo& aField)
 {
   ImplCycleCollectionUnlink(aField.mRequest);
 }
 
 inline void
 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            nsScriptLoader::PreloadInfo& aField,
+                            ScriptLoader::PreloadInfo& aField,
                             const char* aName,
                             uint32_t aFlags = 0)
 {
   ImplCycleCollectionTraverse(aCallback, aField.mRequest, aName, aFlags);
 }
 
 //////////////////////////////////////////////////////////////
-// nsScriptLoader
+// ScriptLoader
 //////////////////////////////////////////////////////////////
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoader)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptLoader)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION(nsScriptLoader,
+NS_IMPL_CYCLE_COLLECTION(ScriptLoader,
                          mNonAsyncExternalScriptInsertedRequests,
                          mLoadingAsyncRequests,
                          mLoadedAsyncRequests,
                          mDeferRequests,
                          mXSLTRequests,
                          mParserBlockingRequest,
                          mPreloads,
                          mPendingChildLoaders,
                          mFetchedModules)
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoader)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoader)
-
-nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptLoader)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptLoader)
+
+ScriptLoader::ScriptLoader(nsIDocument *aDocument)
   : mDocument(aDocument),
     mParserBlockingBlockerCount(0),
     mBlockerCount(0),
     mNumberOfProcessors(0),
     mEnabled(true),
     mDeferEnabled(false),
     mDocumentParsingDone(false),
     mBlockingDOMContentLoaded(false),
     mLoadEventFired(false),
     mReporter(new ConsoleReportCollector())
 {
 }
 
-nsScriptLoader::~nsScriptLoader()
+ScriptLoader::~ScriptLoader()
 {
   mObservers.Clear();
 
   if (mParserBlockingRequest) {
     mParserBlockingRequest->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
-  for (nsScriptLoadRequest* req = mXSLTRequests.getFirst(); req;
+  for (ScriptLoadRequest* req = mXSLTRequests.getFirst(); req;
        req = req->getNext()) {
     req->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
-  for (nsScriptLoadRequest* req = mDeferRequests.getFirst(); req;
+  for (ScriptLoadRequest* req = mDeferRequests.getFirst(); req;
        req = req->getNext()) {
     req->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
-  for (nsScriptLoadRequest* req = mLoadingAsyncRequests.getFirst(); req;
+  for (ScriptLoadRequest* req = mLoadingAsyncRequests.getFirst(); req;
        req = req->getNext()) {
     req->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
-  for (nsScriptLoadRequest* req = mLoadedAsyncRequests.getFirst(); req;
+  for (ScriptLoadRequest* req = mLoadedAsyncRequests.getFirst(); req;
        req = req->getNext()) {
     req->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
-  for(nsScriptLoadRequest* req = mNonAsyncExternalScriptInsertedRequests.getFirst();
+  for(ScriptLoadRequest* req = mNonAsyncExternalScriptInsertedRequests.getFirst();
       req;
       req = req->getNext()) {
     req->FireScriptAvailable(NS_ERROR_ABORT);
   }
 
   // Unblock the kids, in case any of them moved to a different document
   // subtree in the meantime and therefore aren't actually going away.
   for (uint32_t j = 0; j < mPendingChildLoaders.Length(); ++j) {
@@ -703,21 +704,21 @@ IsScriptEventHandler(nsIContent* aScript
 
     return true;
   }
 
   return false;
 }
 
 nsresult
-nsScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
-                                   nsISupports *aContext,
-                                   nsIURI *aURI,
-                                   const nsAString &aType,
-                                   bool aIsPreLoad)
+ScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
+                                 nsISupports *aContext,
+                                 nsIURI *aURI,
+                                 const nsAString &aType,
+                                 bool aIsPreLoad)
 {
   nsContentPolicyType contentPolicyType = aIsPreLoad
                                           ? nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD
                                           : nsIContentPolicy::TYPE_INTERNAL_SCRIPT;
 
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
   nsresult rv = NS_CheckContentLoadPolicy(contentPolicyType,
                                           aURI,
@@ -734,132 +735,132 @@ nsScriptLoader::CheckContentPolicy(nsIDo
     }
     return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
   }
 
   return NS_OK;
 }
 
 bool
-nsScriptLoader::ModuleScriptsEnabled()
+ScriptLoader::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
+ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest *aRequest) const
 {
   // Returns whether we have fetched, or are currently fetching, a module script
   // for the request's URL.
   return mFetchingModules.Contains(aRequest->mURI) ||
          mFetchedModules.Contains(aRequest->mURI);
 }
 
 bool
-nsScriptLoader::IsFetchingModule(nsModuleLoadRequest *aRequest) const
+ScriptLoader::IsFetchingModule(ModuleLoadRequest *aRequest) const
 {
   bool fetching = mFetchingModules.Contains(aRequest->mURI);
   MOZ_ASSERT_IF(fetching, !mFetchedModules.Contains(aRequest->mURI));
   return fetching;
 }
 
 void
-nsScriptLoader::SetModuleFetchStarted(nsModuleLoadRequest *aRequest)
+ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest *aRequest)
 {
   // Update the module map to indicate that a module is currently being fetched.
 
   MOZ_ASSERT(aRequest->IsLoading());
   MOZ_ASSERT(!ModuleMapContainsModule(aRequest));
   mFetchingModules.Put(aRequest->mURI, nullptr);
 }
 
 void
-nsScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadRequest *aRequest,
-                                                               nsresult aResult)
+ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
+                                                             nsresult aResult)
 {
   // Update module map with the result of fetching a single module script.  The
   // module script pointer is nullptr on error.
 
   MOZ_ASSERT(!aRequest->IsReadyToRun());
 
   RefPtr<GenericPromise::Private> promise;
   MOZ_ALWAYS_TRUE(mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise)));
   mFetchingModules.Remove(aRequest->mURI);
 
-  RefPtr<nsModuleScript> ms(aRequest->mModuleScript);
+  RefPtr<ModuleScript> ms(aRequest->mModuleScript);
   MOZ_ASSERT(NS_SUCCEEDED(aResult) == (ms != nullptr));
   mFetchedModules.Put(aRequest->mURI, ms);
 
   if (promise) {
     if (ms) {
       promise->Resolve(true, __func__);
     } else {
       promise->Reject(aResult, __func__);
     }
   }
 }
 
 RefPtr<GenericPromise>
-nsScriptLoader::WaitForModuleFetch(nsModuleLoadRequest *aRequest)
+ScriptLoader::WaitForModuleFetch(ModuleLoadRequest *aRequest)
 {
   MOZ_ASSERT(ModuleMapContainsModule(aRequest));
 
   RefPtr<GenericPromise::Private> promise;
   if (mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise))) {
     if (!promise) {
       promise = new GenericPromise::Private(__func__);
       mFetchingModules.Put(aRequest->mURI, promise);
     }
     return promise;
   }
 
-  RefPtr<nsModuleScript> ms;
+  RefPtr<ModuleScript> ms;
   MOZ_ALWAYS_TRUE(mFetchedModules.Get(aRequest->mURI, getter_AddRefs(ms)));
   if (!ms || ms->InstantiationFailed()) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   return GenericPromise::CreateAndResolve(true, __func__);
 }
 
-nsModuleScript*
-nsScriptLoader::GetFetchedModule(nsIURI* aURL) const
+ModuleScript*
+ScriptLoader::GetFetchedModule(nsIURI* aURL) const
 {
   bool found;
-  nsModuleScript* ms = mFetchedModules.GetWeak(aURL, &found);
+  ModuleScript* ms = mFetchedModules.GetWeak(aURL, &found);
   MOZ_ASSERT(found);
   return ms;
 }
 
 nsresult
-nsScriptLoader::ProcessFetchedModuleSource(nsModuleLoadRequest* aRequest)
+ScriptLoader::ProcessFetchedModuleSource(ModuleLoadRequest* aRequest)
 {
   MOZ_ASSERT(!aRequest->mModuleScript);
 
   nsresult rv = CreateModuleScript(aRequest);
   SetModuleFetchFinishedAndResumeWaitingRequests(aRequest, rv);
 
   aRequest->mScriptText.clearAndFree();
 
   if (NS_SUCCEEDED(rv)) {
     StartFetchingModuleDependencies(aRequest);
   }
 
   return rv;
 }
 
 nsresult
-nsScriptLoader::CreateModuleScript(nsModuleLoadRequest* aRequest)
+ScriptLoader::CreateModuleScript(ModuleLoadRequest* aRequest)
 {
   MOZ_ASSERT(!aRequest->mModuleScript);
   MOZ_ASSERT(aRequest->mBaseURL);
 
   nsCOMPtr<nsIScriptGlobalObject> globalObject = GetScriptGlobalObject();
   if (!globalObject) {
     return NS_ERROR_FAILURE;
   }
@@ -903,27 +904,27 @@ nsScriptLoader::CreateModuleScript(nsMod
         nsAutoString inlineData;
         SourceBufferHolder srcBuf = GetScriptSource(aRequest, inlineData);
         rv = nsJSUtils::CompileModule(cx, srcBuf, global, options, &module);
       }
     }
     MOZ_ASSERT(NS_SUCCEEDED(rv) == (module != nullptr));
     if (module) {
       aRequest->mModuleScript =
-        new nsModuleScript(this, aRequest->mBaseURL, module);
+        new ModuleScript(this, aRequest->mBaseURL, module);
     }
   }
 
   context->SetProcessingScriptTag(oldProcessingScriptTag);
 
   return rv;
 }
 
 static bool
-ThrowTypeError(JSContext* aCx, nsModuleScript* aScript,
+ThrowTypeError(JSContext* aCx, ModuleScript* aScript,
                const nsString& aMessage)
 {
   JS::Rooted<JSObject*> module(aCx, aScript->ModuleRecord());
   JS::Rooted<JSScript*> script(aCx, JS::GetModuleScript(aCx, module));
   JS::Rooted<JSString*> filename(aCx);
   filename = JS_NewStringCopyZ(aCx, JS_GetScriptFilename(script));
   if (!filename) {
     return false;
@@ -940,41 +941,41 @@ ThrowTypeError(JSContext* aCx, nsModuleS
     return false;
   }
 
   JS_SetPendingException(aCx, error);
   return false;
 }
 
 static bool
-HandleResolveFailure(JSContext* aCx, nsModuleScript* aScript,
+HandleResolveFailure(JSContext* aCx, ModuleScript* aScript,
                      const nsAString& aSpecifier)
 {
   // TODO: How can we get the line number of the failed import?
 
   nsAutoString message(NS_LITERAL_STRING("Error resolving module specifier: "));
   message.Append(aSpecifier);
 
   return ThrowTypeError(aCx, aScript, message);
 }
 
 static bool
-HandleModuleNotFound(JSContext* aCx, nsModuleScript* aScript,
+HandleModuleNotFound(JSContext* aCx, ModuleScript* aScript,
                      const nsAString& aSpecifier)
 {
   // TODO: How can we get the line number of the failed import?
 
   nsAutoString message(NS_LITERAL_STRING("Resolved module not found in map: "));
   message.Append(aSpecifier);
 
   return ThrowTypeError(aCx, aScript, message);
 }
 
 static already_AddRefed<nsIURI>
-ResolveModuleSpecifier(nsModuleScript* aScript,
+ResolveModuleSpecifier(ModuleScript* aScript,
                        const nsAString& aSpecifier)
 {
   // The following module specifiers are allowed by the spec:
   //  - a valid absolute URL
   //  - a valid relative URL that starts with "/", "./" or "../"
   //
   // Bareword module specifiers are currently disallowed as these may be given
   // special meanings in the future.
@@ -999,17 +1000,17 @@ ResolveModuleSpecifier(nsModuleScript* a
   if (NS_SUCCEEDED(rv)) {
     return uri.forget();
   }
 
   return nullptr;
 }
 
 static nsresult
-RequestedModuleIsInAncestorList(nsModuleLoadRequest* aRequest, nsIURI* aURL, bool* aResult)
+RequestedModuleIsInAncestorList(ModuleLoadRequest* aRequest, nsIURI* aURL, bool* aResult)
 {
   const size_t ImportDepthLimit = 100;
 
   *aResult = false;
   size_t depth = 0;
   while (aRequest) {
     if (depth++ == ImportDepthLimit) {
       return NS_ERROR_FAILURE;
@@ -1025,19 +1026,19 @@ RequestedModuleIsInAncestorList(nsModule
 
     aRequest = aRequest->mParent;
   }
 
   return NS_OK;
 }
 
 static nsresult
-ResolveRequestedModules(nsModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls)
+ResolveRequestedModules(ModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls)
 {
-  nsModuleScript* ms = aRequest->mModuleScript;
+  ModuleScript* ms = aRequest->mModuleScript;
 
   AutoJSAPI jsapi;
   if (!jsapi.Init(ms->ModuleRecord())) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JSObject*> moduleRecord(cx, ms->ModuleRecord());
@@ -1055,17 +1056,17 @@ ResolveRequestedModules(nsModuleLoadRequ
     }
 
     nsAutoJSString specifier;
     if (!specifier.init(cx, val)) {
       return NS_ERROR_FAILURE;
     }
 
     // Let url be the result of resolving a module specifier given module script and requested.
-    nsModuleScript* ms = aRequest->mModuleScript;
+    ModuleScript* ms = aRequest->mModuleScript;
     nsCOMPtr<nsIURI> uri = ResolveModuleSpecifier(ms, specifier);
     if (!uri) {
       HandleResolveFailure(cx, ms, specifier);
       return NS_ERROR_FAILURE;
     }
 
     bool isAncestor;
     nsresult rv = RequestedModuleIsInAncestorList(aRequest, uri, &isAncestor);
@@ -1074,22 +1075,22 @@ ResolveRequestedModules(nsModuleLoadRequ
       aUrls.AppendElement(uri.forget());
     }
   }
 
   return NS_OK;
 }
 
 void
-nsScriptLoader::StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest)
+ScriptLoader::StartFetchingModuleDependencies(ModuleLoadRequest* aRequest)
 {
   MOZ_ASSERT(aRequest->mModuleScript);
   MOZ_ASSERT(!aRequest->mModuleScript->InstantiationFailed());
   MOZ_ASSERT(!aRequest->IsReadyToRun());
-  aRequest->mProgress = nsModuleLoadRequest::Progress::FetchingImports;
+  aRequest->mProgress = ModuleLoadRequest::Progress::FetchingImports;
 
   nsCOMArray<nsIURI> urls;
   nsresult rv = ResolveRequestedModules(aRequest, urls);
   if (NS_FAILED(rv)) {
     aRequest->LoadFailed();
     return;
   }
 
@@ -1107,28 +1108,28 @@ nsScriptLoader::StartFetchingModuleDepen
       StartFetchingModuleAndDependencies(aRequest, urls[i]);
     importsReady.AppendElement(childReady);
   }
 
   // Wait for all imports to become ready.
   RefPtr<GenericPromise::AllPromiseType> allReady =
     GenericPromise::All(AbstractThread::GetCurrent(), importsReady);
   allReady->Then(AbstractThread::GetCurrent(), __func__, aRequest,
-                 &nsModuleLoadRequest::DependenciesLoaded,
-                 &nsModuleLoadRequest::LoadFailed);
+                 &ModuleLoadRequest::DependenciesLoaded,
+                 &ModuleLoadRequest::LoadFailed);
 }
 
 RefPtr<GenericPromise>
-nsScriptLoader::StartFetchingModuleAndDependencies(nsModuleLoadRequest* aRequest,
-                                                   nsIURI* aURI)
+ScriptLoader::StartFetchingModuleAndDependencies(ModuleLoadRequest* aRequest,
+                                                 nsIURI* aURI)
 {
   MOZ_ASSERT(aURI);
 
-  RefPtr<nsModuleLoadRequest> childRequest =
-    new nsModuleLoadRequest(aRequest->mElement, aRequest->mJSVersion,
+  RefPtr<ModuleLoadRequest> childRequest =
+    new ModuleLoadRequest(aRequest->mElement, aRequest->mJSVersion,
                             aRequest->mCORSMode, aRequest->mIntegrity, this);
 
   childRequest->mIsTopLevel = false;
   childRequest->mURI = aURI;
   childRequest->mIsInline = false;
   childRequest->mReferrerPolicy = aRequest->mReferrerPolicy;
   childRequest->mParent = aRequest;
 
@@ -1149,17 +1150,17 @@ HostResolveImportedModule(JSContext* aCx
 {
   MOZ_ASSERT(argc == 2);
   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
   JS::Rooted<JSObject*> module(aCx, &args[0].toObject());
   JS::Rooted<JSString*> specifier(aCx, args[1].toString());
 
   // Let referencing module script be referencingModule.[[HostDefined]].
   JS::Value value = JS::GetModuleHostDefinedField(module);
-  auto script = static_cast<nsModuleScript*>(value.toPrivate());
+  auto script = static_cast<ModuleScript*>(value.toPrivate());
   MOZ_ASSERT(script->ModuleRecord() == module);
 
   // Let url be the result of resolving a module specifier given referencing
   // module script and specifier. If the result is failure, throw a TypeError
   // exception and abort these steps.
   nsAutoJSString string;
   if (!string.init(aCx, specifier)) {
     return false;
@@ -1168,17 +1169,17 @@ HostResolveImportedModule(JSContext* aCx
   nsCOMPtr<nsIURI> uri = ResolveModuleSpecifier(script, string);
   if (!uri) {
     return HandleResolveFailure(aCx, script, string);
   }
 
   // Let resolved module script be the value of the entry in module map whose
   // key is url. If no such entry exists, throw a TypeError exception and abort
   // these steps.
-  nsModuleScript* ms = script->Loader()->GetFetchedModule(uri);
+  ModuleScript* ms = script->Loader()->GetFetchedModule(uri);
   if (!ms) {
     return HandleModuleNotFound(aCx, script, string);
   }
 
   if (ms->InstantiationFailed()) {
     JS::Rooted<JS::Value> exception(aCx, ms->Exception());
     JS_SetPendingException(aCx, exception);
     return false;
@@ -1202,36 +1203,36 @@ EnsureModuleResolveHook(JSContext* aCx)
     return NS_ERROR_FAILURE;
   }
 
   JS::SetModuleResolveHook(aCx, func);
   return NS_OK;
 }
 
 void
-nsScriptLoader::ProcessLoadedModuleTree(nsModuleLoadRequest* aRequest)
+ScriptLoader::ProcessLoadedModuleTree(ModuleLoadRequest* aRequest)
 {
   if (aRequest->IsTopLevel()) {
     MaybeMoveToLoadedList(aRequest);
     ProcessPendingRequests();
   }
 
   if (aRequest->mWasCompiledOMT) {
     mDocument->UnblockOnload(false);
   }
 }
 
 bool
-nsScriptLoader::InstantiateModuleTree(nsModuleLoadRequest* aRequest)
+ScriptLoader::InstantiateModuleTree(ModuleLoadRequest* aRequest)
 {
   // Perform eager instantiation of the loaded module tree.
 
   MOZ_ASSERT(aRequest);
 
-  nsModuleScript* ms = aRequest->mModuleScript;
+  ModuleScript* ms = aRequest->mModuleScript;
   MOZ_ASSERT(ms);
   if (!ms->ModuleRecord()) {
     return false;
   }
 
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(ms->ModuleRecord()))) {
     return false;
@@ -1250,24 +1251,24 @@ nsScriptLoader::InstantiateModuleTree(ns
       return false;
     }
     MOZ_ASSERT(!exception.isUndefined());
   }
 
   // Mark this module and any uninstantiated dependencies found via depth-first
   // search as instantiated and record any error.
 
-  mozilla::Vector<nsModuleLoadRequest*, 1> requests;
+  mozilla::Vector<ModuleLoadRequest*, 1> requests;
   if (!requests.append(aRequest)) {
     return false;
   }
 
   while (!requests.empty()) {
-    nsModuleLoadRequest* request = requests.popCopy();
-    nsModuleScript* ms = request->mModuleScript;
+    ModuleLoadRequest* request = requests.popCopy();
+    ModuleScript* ms = request->mModuleScript;
     if (!ms->IsUninstantiated()) {
       continue;
     }
 
     ms->SetInstantiationResult(exception);
 
     for (auto import : request->mImports) {
       if (import->mModuleScript->IsUninstantiated() &&
@@ -1291,56 +1292,56 @@ IsBytecodeCacheEnabled()
     Preferences::AddBoolVarCache(&sExposeTestInterfaceEnabled,
                                  "dom.script_loader.bytecode_cache.enabled",
                                  false);
   }
   return sExposeTestInterfaceEnabled;
 }
 
 nsresult
-nsScriptLoader::RestartLoad(nsScriptLoadRequest *aRequest)
+ScriptLoader::RestartLoad(ScriptLoadRequest *aRequest)
 {
   MOZ_ASSERT(aRequest->IsBytecode());
   aRequest->mScriptBytecode.clearAndFree();
   TRACE_FOR_TEST(aRequest->mElement, "scriptloader_fallback");
 
   // Start a new channel from which we explicitly request to stream the source
   // instead of the bytecode.
-  aRequest->mProgress = nsScriptLoadRequest::Progress::Loading_Source;
+  aRequest->mProgress = ScriptLoadRequest::Progress::Loading_Source;
   nsresult rv = StartLoad(aRequest);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // Close the current channel and this ScriptLoadHandler as we created a new
   // one for the same request.
   return NS_BINDING_RETARGETED;
 }
 
 nsresult
-nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest)
+ScriptLoader::StartLoad(ScriptLoadRequest *aRequest)
 {
   MOZ_ASSERT(aRequest->IsLoading());
   NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
-  aRequest->mDataType = nsScriptLoadRequest::DataType::Unknown;
+  aRequest->mDataType = ScriptLoadRequest::DataType::Unknown;
 
   // If this document is sandboxed without 'allow-scripts', abort.
   if (mDocument->HasScriptsBlockedBySandbox()) {
     return NS_OK;
   }
 
   if (aRequest->IsModuleRequest()) {
     // Check whether the module has been fetched or is currently being fetched,
     // and if so wait for it.
-    nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+    ModuleLoadRequest* request = aRequest->AsModuleRequest();
     if (ModuleMapContainsModule(request)) {
       WaitForModuleFetch(request)
         ->Then(AbstractThread::GetCurrent(), __func__, request,
-               &nsModuleLoadRequest::ModuleLoaded,
-               &nsModuleLoadRequest::LoadFailed);
+               &ModuleLoadRequest::ModuleLoaded,
+               &ModuleLoadRequest::LoadFailed);
       return NS_OK;
     }
 
     // Otherwise put the URL in the module map and mark it as fetching.
     SetModuleFetchStarted(request);
   }
 
   nsContentPolicyType contentPolicyType = aRequest->IsPreload()
@@ -1468,43 +1469,43 @@ nsScriptLoader::StartLoad(nsScriptLoadRe
     nsAutoCString sourceUri;
     if (mDocument->GetDocumentURI()) {
       mDocument->GetDocumentURI()->GetAsciiSpec(sourceUri);
     }
     sriDataVerifier = new SRICheckDataVerifier(aRequest->mIntegrity, sourceUri,
                                                mReporter);
   }
 
-  RefPtr<nsScriptLoadHandler> handler =
-      new nsScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
+  RefPtr<ScriptLoadHandler> handler =
+      new ScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
 
   nsCOMPtr<nsIIncrementalStreamLoader> loader;
   rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return channel->AsyncOpen2(loader);
 }
 
 bool
-nsScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi,
-                                             nsIURI * const &aURI) const
+ScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi,
+                                           nsIURI * const &aURI) const
 {
   bool same;
   return NS_SUCCEEDED(aPi.mRequest->mURI->Equals(aURI, &same)) &&
          same;
 }
 
-class nsScriptRequestProcessor : public Runnable
+class ScriptRequestProcessor : public Runnable
 {
 private:
-  RefPtr<nsScriptLoader> mLoader;
-  RefPtr<nsScriptLoadRequest> mRequest;
+  RefPtr<ScriptLoader> mLoader;
+  RefPtr<ScriptLoadRequest> mRequest;
 public:
-  nsScriptRequestProcessor(nsScriptLoader* aLoader,
-                           nsScriptLoadRequest* aRequest)
+  ScriptRequestProcessor(ScriptLoader* aLoader,
+                         ScriptLoadRequest* aRequest)
     : mLoader(aLoader)
     , mRequest(aRequest)
   {}
   NS_IMETHOD Run() override
   {
     return mLoader->ProcessRequest(mRequest);
   }
 };
@@ -1566,34 +1567,33 @@ CSPAllowsInlineScript(nsIScriptElement *
   bool allowInlineScript = false;
   rv = csp->GetAllowsInline(nsIContentPolicy::TYPE_SCRIPT,
                             nonce, parserCreated, scriptText,
                             aElement->GetScriptLineNumber(),
                             &allowInlineScript);
   return allowInlineScript;
 }
 
-nsScriptLoadRequest*
-nsScriptLoader::CreateLoadRequest(nsScriptKind aKind,
-                                  nsIScriptElement* aElement,
-                                  uint32_t aVersion, CORSMode aCORSMode,
-                                  const SRIMetadata &aIntegrity)
+ScriptLoadRequest*
+ScriptLoader::CreateLoadRequest(ScriptKind aKind,
+                                nsIScriptElement* aElement,
+                                uint32_t aVersion, CORSMode aCORSMode,
+                                const SRIMetadata &aIntegrity)
 {
-  if (aKind == nsScriptKind::Classic) {
-    return new nsScriptLoadRequest(aKind, aElement, aVersion, aCORSMode,
-                                   aIntegrity);
+  if (aKind == ScriptKind::Classic) {
+    return new ScriptLoadRequest(aKind, aElement, aVersion, aCORSMode,
+                                 aIntegrity);
   }
 
-  MOZ_ASSERT(aKind == nsScriptKind::Module);
-  return new nsModuleLoadRequest(aElement, aVersion, aCORSMode, aIntegrity,
-                                 this);
+  MOZ_ASSERT(aKind == ScriptKind::Module);
+  return new ModuleLoadRequest(aElement, aVersion, aCORSMode, aIntegrity, this);
 }
 
 bool
-nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
+ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
 {
   // We need a document to evaluate scripts.
   NS_ENSURE_TRUE(mDocument, false);
 
   // Check to see if scripts has been turned off.
   if (!mEnabled || !mDocument->IsScriptEnabled()) {
     return false;
   }
@@ -1609,20 +1609,20 @@ nsScriptLoader::ProcessScriptElement(nsI
 
   JSVersion version = JSVERSION_DEFAULT;
 
   // Check the type attribute to determine language and version.
   // If type exists, it trumps the deprecated 'language='
   nsAutoString type;
   bool hasType = aElement->GetScriptType(type);
 
-  nsScriptKind scriptKind = nsScriptKind::Classic;
+  ScriptKind scriptKind = ScriptKind::Classic;
   if (!type.IsEmpty()) {
     if (ModuleScriptsEnabled() && type.LowerCaseEqualsASCII("module")) {
-      scriptKind = nsScriptKind::Module;
+      scriptKind = ScriptKind::Module;
     } else {
       NS_ENSURE_TRUE(ParseTypeAttribute(type, &version), false);
     }
   } else if (!hasType) {
     // no 'type=' element
     // "language" is a deprecated attribute of HTML, so we check it only for
     // HTML script elements.
     if (scriptContent->IsHTMLElement()) {
@@ -1636,25 +1636,25 @@ nsScriptLoader::ProcessScriptElement(nsI
     }
   }
 
   // "In modern user agents that support module scripts, the script element with
   // the nomodule attribute will be ignored".
   // "The nomodule attribute must not be specified on module scripts (and will
   // be ignored if it is)."
   if (ModuleScriptsEnabled() &&
-      scriptKind == nsScriptKind::Classic &&
+      scriptKind == ScriptKind::Classic &&
       scriptContent->IsHTMLElement() &&
       scriptContent->HasAttr(kNameSpaceID_None, nsGkAtoms::nomodule)) {
     return false;
   }
 
   // Step 15. and later in the HTML5 spec
   nsresult rv = NS_OK;
-  RefPtr<nsScriptLoadRequest> request;
+  RefPtr<ScriptLoadRequest> request;
   if (aElement->GetScriptExternal()) {
     // external script
     nsCOMPtr<nsIURI> scriptURI = aElement->GetScriptURI();
     if (!scriptURI) {
       // Asynchronously report the failure to create a URI object
       NS_DispatchToCurrentThread(
         NewRunnableMethod(aElement,
                           &nsIScriptElement::FireErrorEvent));
@@ -1700,17 +1700,17 @@ nsScriptLoader::ProcessScriptElement(nsI
 
       SRIMetadata sriMetadata;
       {
         nsAutoString integrity;
         scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::integrity,
                                integrity);
         if (!integrity.IsEmpty()) {
           MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
-                  ("nsScriptLoader::ProcessScriptElement, integrity=%s",
+                  ("ScriptLoader::ProcessScriptElement, integrity=%s",
                    NS_ConvertUTF16toUTF8(integrity).get()));
           nsAutoCString sourceUri;
           if (mDocument->GetDocumentURI()) {
             mDocument->GetDocumentURI()->GetAsciiSpec(sourceUri);
           }
           SRICheck::IntegrityMetadata(integrity, sourceUri, mReporter,
                                       &sriMetadata);
         }
@@ -1858,46 +1858,46 @@ nsScriptLoader::ProcessScriptElement(nsI
 
   // Inline scripts ignore ther CORS mode and are always CORS_NONE
   request = CreateLoadRequest(scriptKind, aElement, version, CORS_NONE,
                               SRIMetadata()); // SRI doesn't apply
   request->mJSVersion = version;
   request->mIsInline = true;
   request->mURI = mDocument->GetDocumentURI();
   request->mLineNo = aElement->GetScriptLineNumber();
-  request->mProgress = nsScriptLoadRequest::Progress::Loading_Source;
-  request->mDataType = nsScriptLoadRequest::DataType::Source;
+  request->mProgress = ScriptLoadRequest::Progress::Loading_Source;
+  request->mDataType = ScriptLoadRequest::DataType::Source;
   TRACE_FOR_TEST_BOOL(request->mElement, "scriptloader_load_source");
 
   if (request->IsModuleRequest()) {
-    nsModuleLoadRequest* modReq = request->AsModuleRequest();
+    ModuleLoadRequest* modReq = request->AsModuleRequest();
     modReq->mBaseURL = mDocument->GetDocBaseURI();
     rv = CreateModuleScript(modReq);
     NS_ENSURE_SUCCESS(rv, false);
     StartFetchingModuleDependencies(modReq);
     if (aElement->GetScriptAsync()) {
       mLoadingAsyncRequests.AppendElement(request);
     } else {
       AddDeferRequest(request);
     }
     return false;
   }
-  request->mProgress = nsScriptLoadRequest::Progress::Ready;
+  request->mProgress = ScriptLoadRequest::Progress::Ready;
   if (aElement->GetParserCreated() == FROM_PARSER_XSLT &&
       (!ReadyToExecuteParserBlockingScripts() || !mXSLTRequests.isEmpty())) {
     // Need to maintain order for XSLT-inserted scripts
     NS_ASSERTION(!mParserBlockingRequest,
         "Parser-blocking scripts and XSLT scripts in the same doc!");
     mXSLTRequests.AppendElement(request);
     return true;
   }
   if (aElement->GetParserCreated() == NOT_FROM_PARSER) {
     NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
         "A script-inserted script is inserted without an update batch?");
-    nsContentUtils::AddScriptRunner(new nsScriptRequestProcessor(this,
+    nsContentUtils::AddScriptRunner(new ScriptRequestProcessor(this,
                                                                  request));
     return false;
   }
   if (aElement->GetParserCreated() == FROM_PARSER_NETWORK &&
       !ReadyToExecuteParserBlockingScripts()) {
     NS_ASSERTION(!mParserBlockingRequest,
         "There can be only one parser-blocking script at a time");
     mParserBlockingRequest = request;
@@ -1917,24 +1917,24 @@ nsScriptLoader::ProcessScriptElement(nsI
       "Not safe to run a parser-inserted script?");
   return ProcessRequest(request) == NS_ERROR_HTMLPARSER_BLOCK;
 }
 
 namespace {
 
 class NotifyOffThreadScriptLoadCompletedRunnable : public Runnable
 {
-  RefPtr<nsScriptLoadRequest> mRequest;
-  RefPtr<nsScriptLoader> mLoader;
+  RefPtr<ScriptLoadRequest> mRequest;
+  RefPtr<ScriptLoader> mLoader;
   RefPtr<DocGroup> mDocGroup;
   void *mToken;
 
 public:
-  NotifyOffThreadScriptLoadCompletedRunnable(nsScriptLoadRequest* aRequest,
-                                             nsScriptLoader* aLoader)
+  NotifyOffThreadScriptLoadCompletedRunnable(ScriptLoadRequest* aRequest,
+                                             ScriptLoader* aLoader)
     : mRequest(aRequest)
     , mLoader(aLoader)
     , mDocGroup(aLoader->GetDocGroup())
     , mToken(nullptr)
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
@@ -1953,26 +1953,26 @@ public:
   }
 
   NS_DECL_NSIRUNNABLE
 };
 
 } /* anonymous namespace */
 
 nsresult
-nsScriptLoader::ProcessOffThreadRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::ProcessOffThreadRequest(ScriptLoadRequest* aRequest)
 {
-  MOZ_ASSERT(aRequest->mProgress == nsScriptLoadRequest::Progress::Compiling);
+  MOZ_ASSERT(aRequest->mProgress == ScriptLoadRequest::Progress::Compiling);
   MOZ_ASSERT(!aRequest->mWasCompiledOMT);
 
   aRequest->mWasCompiledOMT = true;
 
   if (aRequest->IsModuleRequest()) {
     MOZ_ASSERT(aRequest->mOffThreadToken);
-    nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+    ModuleLoadRequest* request = aRequest->AsModuleRequest();
     nsresult rv = ProcessFetchedModuleSource(request);
     if (NS_FAILED(rv)) {
       request->LoadFailed();
     }
     return rv;
   }
 
   aRequest->SetReady();
@@ -2009,18 +2009,18 @@ NotifyOffThreadScriptLoadCompletedRunnab
 
 NS_IMETHODIMP
 NotifyOffThreadScriptLoadCompletedRunnable::Run()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // We want these to be dropped on the main thread, once we return from this
   // function.
-  RefPtr<nsScriptLoadRequest> request = mRequest.forget();
-  RefPtr<nsScriptLoader> loader = mLoader.forget();
+  RefPtr<ScriptLoadRequest> request = mRequest.forget();
+  RefPtr<ScriptLoader> loader = mLoader.forget();
 
   request->mOffThreadToken = mToken;
   nsresult rv = loader->ProcessOffThreadRequest(request);
 
   return rv;
 }
 
 static void
@@ -2028,17 +2028,17 @@ OffThreadScriptLoaderCallback(void *aTok
 {
   RefPtr<NotifyOffThreadScriptLoadCompletedRunnable> aRunnable =
     dont_AddRef(static_cast<NotifyOffThreadScriptLoadCompletedRunnable*>(aCallbackData));
   aRunnable->SetToken(aToken);
   NotifyOffThreadScriptLoadCompletedRunnable::Dispatch(aRunnable.forget());
 }
 
 nsresult
-nsScriptLoader::AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest)
+ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest)
 {
   MOZ_ASSERT_IF(!aRequest->IsModuleRequest(), aRequest->IsReadyToRun());
   MOZ_ASSERT(!aRequest->mWasCompiledOMT);
 
   // Don't off-thread compile inline scripts.
   if (aRequest->mIsInline) {
     return NS_ERROR_FAILURE;
   }
@@ -2098,25 +2098,25 @@ nsScriptLoader::AttemptAsyncScriptCompil
                                    static_cast<void*>(runnable))) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   mDocument->BlockOnload();
 
   // Once the compilation is finished, an event would be added to the event loop
-  // to call nsScriptLoader::ProcessOffThreadRequest with the same request.
-  aRequest->mProgress = nsScriptLoadRequest::Progress::Compiling;
+  // to call ScriptLoader::ProcessOffThreadRequest with the same request.
+  aRequest->mProgress = ScriptLoadRequest::Progress::Compiling;
 
   Unused << runnable.forget();
   return NS_OK;
 }
 
 nsresult
-nsScriptLoader::CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::CompileOffThreadOrProcessRequest(ScriptLoadRequest* aRequest)
 {
   NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
                "Processing requests when running scripts is unsafe.");
   NS_ASSERTION(!aRequest->mOffThreadToken,
                "Candidate for off-thread compile is already parsed off-thread");
   NS_ASSERTION(!aRequest->InCompilingStage(),
                "Candidate for off-thread compile is already in compiling stage.");
 
@@ -2124,17 +2124,17 @@ nsScriptLoader::CompileOffThreadOrProces
   if (NS_SUCCEEDED(rv)) {
     return rv;
   }
 
   return ProcessRequest(aRequest);
 }
 
 SourceBufferHolder
-nsScriptLoader::GetScriptSource(nsScriptLoadRequest* aRequest, nsAutoString& inlineData)
+ScriptLoader::GetScriptSource(ScriptLoadRequest* aRequest, nsAutoString& inlineData)
 {
   // Return a SourceBufferHolder object holding the script's source text.
   // |inlineData| is used to hold the text for inline objects.
 
   // If there's no script text, we try to get it from the element
   if (aRequest->mIsInline) {
     // XXX This is inefficient - GetText makes multiple
     // copies.
@@ -2145,17 +2145,17 @@ nsScriptLoader::GetScriptSource(nsScript
   }
 
   return SourceBufferHolder(aRequest->mScriptText.begin(),
                             aRequest->mScriptText.length(),
                             SourceBufferHolder::NoOwnership);
 }
 
 nsresult
-nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest)
 {
   NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
                "Processing requests when running scripts is unsafe.");
   NS_ASSERTION(aRequest->IsReadyToRun(),
                "Processing a request that is not ready to run.");
 
   NS_ENSURE_ARG(aRequest);
 
@@ -2244,44 +2244,44 @@ nsScriptLoader::ProcessRequest(nsScriptL
   // Free any source data, but keep the bytecode content as we might have to
   // save it later.
   aRequest->mScriptText.clearAndFree();
 
   return rv;
 }
 
 void
-nsScriptLoader::FireScriptAvailable(nsresult aResult,
-                                    nsScriptLoadRequest* aRequest)
+ScriptLoader::FireScriptAvailable(nsresult aResult,
+                                  ScriptLoadRequest* aRequest)
 {
   for (int32_t i = 0; i < mObservers.Count(); i++) {
     nsCOMPtr<nsIScriptLoaderObserver> obs = mObservers[i];
     obs->ScriptAvailable(aResult, aRequest->mElement,
                          aRequest->mIsInline, aRequest->mURI,
                          aRequest->mLineNo);
   }
 
   aRequest->FireScriptAvailable(aResult);
 }
 
 void
-nsScriptLoader::FireScriptEvaluated(nsresult aResult,
-                                    nsScriptLoadRequest* aRequest)
+ScriptLoader::FireScriptEvaluated(nsresult aResult,
+                                  ScriptLoadRequest* aRequest)
 {
   for (int32_t i = 0; i < mObservers.Count(); i++) {
     nsCOMPtr<nsIScriptLoaderObserver> obs = mObservers[i];
     obs->ScriptEvaluated(aResult, aRequest->mElement,
                          aRequest->mIsInline);
   }
 
   aRequest->FireScriptEvaluated(aResult);
 }
 
 already_AddRefed<nsIScriptGlobalObject>
-nsScriptLoader::GetScriptGlobalObject()
+ScriptLoader::GetScriptGlobalObject()
 {
   nsCOMPtr<nsIDocument> master = mDocument->MasterDocument();
   nsPIDOMWindowInner *pwin = master->GetInnerWindow();
   if (!pwin) {
     return nullptr;
   }
 
   nsCOMPtr<nsIScriptGlobalObject> globalObject = do_QueryInterface(pwin);
@@ -2292,20 +2292,20 @@ nsScriptLoader::GetScriptGlobalObject()
   if (NS_FAILED(rv)) {
     return nullptr;
   }
 
   return globalObject.forget();
 }
 
 nsresult
-nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
-                                             nsScriptLoadRequest* aRequest,
-                                             JS::Handle<JSObject*> aScopeChain,
-                                             JS::CompileOptions* aOptions)
+ScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI&jsapi,
+                                           ScriptLoadRequest* aRequest,
+                                           JS::Handle<JSObject*> aScopeChain,
+                                           JS::CompileOptions* aOptions)
 {
   // It's very important to use aRequest->mURI, not the final URI of the channel
   // aRequest ended up getting script data from, as the script filename.
   nsresult rv;
   nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI,
                                                aRequest->mURL, &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -2357,17 +2357,17 @@ nsScriptLoader::FillCompileOptionsForReq
   if (sForceBytecodeCacheEnabled) {
     aOptions->forceAsync = true;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest)
+ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
 {
   MOZ_ASSERT(aRequest->IsReadyToRun());
 
   // We need a document to evaluate scripts.
   if (!mDocument) {
     return NS_ERROR_FAILURE;
   }
 
@@ -2424,20 +2424,20 @@ nsScriptLoader::EvaluateScript(nsScriptL
                                   aRequest->mElement);
     }
 
     if (aRequest->IsModuleRequest()) {
       // When a module is already loaded, it is not feched a second time and the
       // mDataType of the request might remain set to DataType::Unknown.
       MOZ_ASSERT(!aRequest->IsBytecode());
       LOG(("ScriptLoadRequest (%p): Evaluate Module", aRequest));
-      nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+      ModuleLoadRequest* request = aRequest->AsModuleRequest();
       MOZ_ASSERT(request->mModuleScript);
       MOZ_ASSERT(!request->mOffThreadToken);
-      nsModuleScript* ms = request->mModuleScript;
+      ModuleScript* ms = request->mModuleScript;
       MOZ_ASSERT(!ms->IsUninstantiated());
       if (ms->InstantiationFailed()) {
         JS::Rooted<JS::Value> exception(aes.cx(), ms->Exception());
         JS_SetPendingException(aes.cx(), exception);
         rv = NS_ERROR_FAILURE;
       } else {
         JS::Rooted<JSObject*> module(aes.cx(), ms->ModuleRecord());
         MOZ_ASSERT(module);
@@ -2518,32 +2518,32 @@ nsScriptLoader::EvaluateScript(nsScriptL
     MaybeTriggerBytecodeEncoding();
   }
 
   context->SetProcessingScriptTag(oldProcessingScriptTag);
   return rv;
 }
 
 void
-nsScriptLoader::RegisterForBytecodeEncoding(nsScriptLoadRequest* aRequest)
+ScriptLoader::RegisterForBytecodeEncoding(ScriptLoadRequest* aRequest)
 {
   MOZ_ASSERT(aRequest->mCacheInfo);
   MOZ_ASSERT(aRequest->mScript);
   mBytecodeEncodingQueue.AppendElement(aRequest);
 }
 
 void
-nsScriptLoader::LoadEventFired()
+ScriptLoader::LoadEventFired()
 {
   mLoadEventFired = true;
   MaybeTriggerBytecodeEncoding();
 }
 
 void
-nsScriptLoader::MaybeTriggerBytecodeEncoding()
+ScriptLoader::MaybeTriggerBytecodeEncoding()
 {
   // We wait for the load event to be fired before saving the bytecode of
   // any script to the cache. It is quite common to have load event
   // listeners trigger more JavaScript execution, that we want to save as
   // part of this start-up bytecode cache.
   if (!mLoadEventFired) {
     return;
   }
@@ -2558,25 +2558,25 @@ nsScriptLoader::MaybeTriggerBytecodeEnco
   if (HasPendingRequests()) {
     return;
   }
 
   // Create a new runnable dedicated to encoding the content of the bytecode
   // of all enqueued scripts. In case of failure, we give-up on encoding the
   // bytecode.
   nsCOMPtr<nsIRunnable> encoder =
-    NewRunnableMethod("nsScriptLoader::EncodeBytecode",
-                      this, &nsScriptLoader::EncodeBytecode);
+    NewRunnableMethod("ScriptLoader::EncodeBytecode",
+                      this, &ScriptLoader::EncodeBytecode);
   if (NS_FAILED(NS_DispatchToCurrentThread(encoder))) {
     GiveUpBytecodeEncoding();
   }
 }
 
 void
-nsScriptLoader::EncodeBytecode()
+ScriptLoader::EncodeBytecode()
 {
   // If any script got added in the previous loop cycle, wait until all
   // remaining script executions are completed, such that we capture most of
   // the initialization.
   if (HasPendingRequests()) {
     return;
   }
 
@@ -2588,27 +2588,27 @@ nsScriptLoader::EncodeBytecode()
 
   nsCOMPtr<nsIScriptContext> context = globalObject->GetScriptContext();
   if (!context) {
     GiveUpBytecodeEncoding();
     return;
   }
 
   AutoEntryScript aes(globalObject, "encode bytecode", true);
-  RefPtr<nsScriptLoadRequest> request;
+  RefPtr<ScriptLoadRequest> request;
   while (!mBytecodeEncodingQueue.isEmpty()) {
     request = mBytecodeEncodingQueue.StealFirst();
     EncodeRequestBytecode(aes.cx(), request);
     request->mScriptBytecode.clearAndFree();
     request->DropBytecodeCacheReferences();
   }
 }
 
 void
-nsScriptLoader::EncodeRequestBytecode(JSContext* aCx, nsScriptLoadRequest* aRequest)
+ScriptLoader::EncodeRequestBytecode(JSContext* aCx, ScriptLoadRequest* aRequest)
 {
   nsresult rv = NS_OK;
   MOZ_ASSERT(aRequest->mCacheInfo);
   auto bytecodeFailed = mozilla::MakeScopeExit([&]() {
     TRACE_FOR_TEST_NONE(aRequest->mElement, "scriptloader_bytecode_failed");
   });
 
   JS::RootedScript script(aCx, aRequest->mScript);
@@ -2651,89 +2651,89 @@ nsScriptLoader::EncodeRequestBytecode(JS
     return;
   }
 
   bytecodeFailed.release();
   TRACE_FOR_TEST_NONE(aRequest->mElement, "scriptloader_bytecode_saved");
 }
 
 void
-nsScriptLoadRequest::DropBytecodeCacheReferences()
+ScriptLoadRequest::DropBytecodeCacheReferences()
 {
   mCacheInfo = nullptr;
   mScript = nullptr;
   DropJSObjects(this);
 }
 
 void
-nsScriptLoader::GiveUpBytecodeEncoding()
+ScriptLoader::GiveUpBytecodeEncoding()
 {
   // Ideally we prefer to properly end the incremental encoder, such that we
   // would not keep a large buffer around.  If we cannot, we fallback on the
   // removal of all request from the current list.
   nsCOMPtr<nsIScriptGlobalObject> globalObject = GetScriptGlobalObject();
   if (globalObject) {
     nsCOMPtr<nsIScriptContext> context = globalObject->GetScriptContext();
     if (context) {
       AutoEntryScript aes(globalObject, "give-up bytecode encoding", true);
       JS::RootedScript script(aes.cx());
       while (!mBytecodeEncodingQueue.isEmpty()) {
-        RefPtr<nsScriptLoadRequest> request = mBytecodeEncodingQueue.StealFirst();
+        RefPtr<ScriptLoadRequest> request = mBytecodeEncodingQueue.StealFirst();
         LOG(("ScriptLoadRequest (%p): Cannot serialize bytecode", request.get()));
         TRACE_FOR_TEST_NONE(request->mElement, "scriptloader_bytecode_failed");
         script.set(request->mScript);
         Unused << JS::FinishIncrementalEncoding(aes.cx(), script);
         request->mScriptBytecode.clearAndFree();
         request->DropBytecodeCacheReferences();
       }
       return;
     }
   }
 
   while (!mBytecodeEncodingQueue.isEmpty()) {
-    RefPtr<nsScriptLoadRequest> request = mBytecodeEncodingQueue.StealFirst();
+    RefPtr<ScriptLoadRequest> request = mBytecodeEncodingQueue.StealFirst();
     LOG(("ScriptLoadRequest (%p): Cannot serialize bytecode", request.get()));
     TRACE_FOR_TEST_NONE(request->mElement, "scriptloader_bytecode_failed");
     // Note: Do not clear the mScriptBytecode buffer, because the incremental
     // encoder owned by the ScriptSource object still has a reference to this
     // buffer. This reference would be removed as soon as the ScriptSource
     // object would be GC.
     request->mCacheInfo = nullptr;
   }
 }
 
 bool
-nsScriptLoader::HasPendingRequests()
+ScriptLoader::HasPendingRequests()
 {
   return mParserBlockingRequest ||
          !mXSLTRequests.isEmpty() ||
          !mLoadedAsyncRequests.isEmpty() ||
          !mNonAsyncExternalScriptInsertedRequests.isEmpty() ||
          !mDeferRequests.isEmpty() ||
          !mPendingChildLoaders.IsEmpty();
 }
 
 void
-nsScriptLoader::ProcessPendingRequestsAsync()
+ScriptLoader::ProcessPendingRequestsAsync()
 {
   if (HasPendingRequests()) {
     nsCOMPtr<nsIRunnable> task = NewRunnableMethod(this,
-                                                   &nsScriptLoader::ProcessPendingRequests);
+                                                   &ScriptLoader::ProcessPendingRequests);
     if (mDocument) {
       mDocument->Dispatch("ScriptLoader", TaskCategory::Other, task.forget());
     } else {
       NS_DispatchToCurrentThread(task.forget());
     }
   }
 }
 
 void
-nsScriptLoader::ProcessPendingRequests()
+ScriptLoader::ProcessPendingRequests()
 {
-  RefPtr<nsScriptLoadRequest> request;
+  RefPtr<ScriptLoadRequest> request;
 
   if (mParserBlockingRequest &&
       mParserBlockingRequest->IsReadyToRun() &&
       ReadyToExecuteParserBlockingScripts()) {
     request.swap(mParserBlockingRequest);
     UnblockParser(request);
     ProcessRequest(request);
     if (request->mWasCompiledOMT) {
@@ -2775,17 +2775,17 @@ nsScriptLoader::ProcessPendingRequests()
            mDeferRequests.getFirst()->IsReadyToRun()) {
       request = mDeferRequests.StealFirst();
       ProcessRequest(request);
     }
   }
 
   while (!mPendingChildLoaders.IsEmpty() &&
          ReadyToExecuteParserBlockingScripts()) {
-    RefPtr<nsScriptLoader> child = mPendingChildLoaders[0];
+    RefPtr<ScriptLoader> child = mPendingChildLoaders[0];
     mPendingChildLoaders.RemoveElementAt(0);
     child->RemoveParserBlockingScriptExecutionBlocker();
   }
 
   if (mDocumentParsingDone && mDocument && !mParserBlockingRequest &&
       mNonAsyncExternalScriptInsertedRequests.isEmpty() &&
       mXSLTRequests.isEmpty() && mDeferRequests.isEmpty() &&
       MaybeRemovedDeferRequests()) {
@@ -2801,26 +2801,26 @@ nsScriptLoader::ProcessPendingRequests()
     // OK to unblock onload synchronously here, since callers must be
     // prepared for the world changing anyway.
     mDocumentParsingDone = false;
     mDocument->UnblockOnload(true);
   }
 }
 
 bool
-nsScriptLoader::ReadyToExecuteParserBlockingScripts()
+ScriptLoader::ReadyToExecuteParserBlockingScripts()
 {
   // Make sure the SelfReadyToExecuteParserBlockingScripts check is first, so
   // that we don't block twice on an ancestor.
   if (!SelfReadyToExecuteParserBlockingScripts()) {
     return false;
   }
 
   for (nsIDocument* doc = mDocument; doc; doc = doc->GetParentDocument()) {
-    nsScriptLoader* ancestor = doc->ScriptLoader();
+    ScriptLoader* ancestor = doc->ScriptLoader();
     if (!ancestor->SelfReadyToExecuteParserBlockingScripts() &&
         ancestor->AddPendingChildLoader(this)) {
       AddParserBlockingScriptExecutionBlocker();
       return false;
     }
   }
 
   if (mDocument && !mDocument->IsMasterDocument()) {
@@ -2858,20 +2858,20 @@ nsScriptLoader::ReadyToExecuteParserBloc
       return false;
     }
   }
 
   return true;
 }
 
 /* static */ nsresult
-nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
-                               uint32_t aLength, const nsAString& aHintCharset,
-                               nsIDocument* aDocument,
-                               char16_t*& aBufOut, size_t& aLengthOut)
+ScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
+                             uint32_t aLength, const nsAString& aHintCharset,
+                             nsIDocument* aDocument,
+                             char16_t*& aBufOut, size_t& aLengthOut)
 {
   if (!aLength) {
     aBufOut = nullptr;
     aLengthOut = 0;
     return NS_OK;
   }
 
   // The encoding info precedence is as follows from high to low:
@@ -2944,21 +2944,21 @@ nsScriptLoader::ConvertToUTF16(nsIChanne
     charset = "?";
   }
   mozilla::Telemetry::Accumulate(mozilla::Telemetry::DOM_SCRIPT_SRC_ENCODING,
     charset);
   return rv;
 }
 
 nsresult
-nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
-                                 nsScriptLoadRequest* aRequest,
-                                 nsresult aChannelStatus,
-                                 nsresult aSRIStatus,
-                                 mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier)
+ScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
+                               ScriptLoadRequest* aRequest,
+                               nsresult aChannelStatus,
+                               nsresult aSRIStatus,
+                               mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier)
 {
   NS_ASSERTION(aRequest, "null request in stream complete handler");
   NS_ENSURE_TRUE(aRequest, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIRequest> channelRequest;
   aLoader->GetRequest(getter_AddRefs(channelRequest));
   nsCOMPtr<nsIChannel> channel;
   channel = do_QueryInterface(channelRequest);
@@ -2984,17 +2984,17 @@ nsScriptLoader::OnStreamComplete(nsIIncr
     if (NS_FAILED(rv)) {
       rv = NS_ERROR_SRI_CORRUPT;
     }
   } else {
     nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
 
     if (loadInfo && loadInfo->GetEnforceSRI()) {
       MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
-              ("nsScriptLoader::OnStreamComplete, required SRI not found"));
+              ("ScriptLoader::OnStreamComplete, required SRI not found"));
       nsCOMPtr<nsIContentSecurityPolicy> csp;
       loadInfo->LoadingPrincipal()->GetCsp(getter_AddRefs(csp));
       nsAutoCString violationURISpec;
       mDocument->GetDocumentURI()->GetAsciiSpec(violationURISpec);
       uint32_t lineNo = aRequest->mElement ? aRequest->mElement->GetScriptLineNumber() : 0;
       csp->LogViolationDetails(
         nsIContentSecurityPolicy::VIOLATION_TYPE_REQUIRE_SRI_FOR_SCRIPT,
         NS_ConvertUTF8toUTF16(violationURISpec),
@@ -3083,39 +3083,39 @@ nsScriptLoader::OnStreamComplete(nsIIncr
       // When loading bytecode, we verify the SRI hash. If it does not match the
       // one from the document we restart the load, forcing us to load the
       // source instead. This test makes sure we do not remove the current
       // request from the following lists when we restart the load.
     } else if (aRequest->mIsDefer) {
       MOZ_ASSERT_IF(aRequest->IsModuleRequest(),
                     aRequest->AsModuleRequest()->IsTopLevel());
       if (aRequest->isInList()) {
-        RefPtr<nsScriptLoadRequest> req = mDeferRequests.Steal(aRequest);
+        RefPtr<ScriptLoadRequest> req = mDeferRequests.Steal(aRequest);
         FireScriptAvailable(rv, req);
       }
     } else if (aRequest->mIsAsync) {
       MOZ_ASSERT_IF(aRequest->IsModuleRequest(),
                     aRequest->AsModuleRequest()->IsTopLevel());
       if (aRequest->isInList()) {
-        RefPtr<nsScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
+        RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
         FireScriptAvailable(rv, req);
       }
     } else if (aRequest->mIsNonAsyncScriptInserted) {
       if (aRequest->isInList()) {
-        RefPtr<nsScriptLoadRequest> req =
+        RefPtr<ScriptLoadRequest> req =
           mNonAsyncExternalScriptInsertedRequests.Steal(aRequest);
         FireScriptAvailable(rv, req);
       }
     } else if (aRequest->mIsXSLT) {
       if (aRequest->isInList()) {
-        RefPtr<nsScriptLoadRequest> req = mXSLTRequests.Steal(aRequest);
+        RefPtr<ScriptLoadRequest> req = mXSLTRequests.Steal(aRequest);
         FireScriptAvailable(rv, req);
       }
     } else if (aRequest->IsModuleRequest()) {
-      nsModuleLoadRequest* modReq = aRequest->AsModuleRequest();
+      ModuleLoadRequest* modReq = aRequest->AsModuleRequest();
       MOZ_ASSERT(!modReq->IsTopLevel());
       MOZ_ASSERT(!modReq->isInList());
       modReq->Cancel();
       FireScriptAvailable(rv, aRequest);
     } else if (mParserBlockingRequest == aRequest) {
       MOZ_ASSERT(!aRequest->isInList());
       mParserBlockingRequest = nullptr;
       UnblockParser(aRequest);
@@ -3136,60 +3136,60 @@ nsScriptLoader::OnStreamComplete(nsIIncr
 
   // Process our request and/or any pending ones
   ProcessPendingRequests();
 
   return NS_OK;
 }
 
 void
-nsScriptLoader::UnblockParser(nsScriptLoadRequest* aParserBlockingRequest)
+ScriptLoader::UnblockParser(ScriptLoadRequest* aParserBlockingRequest)
 {
   aParserBlockingRequest->mElement->UnblockParser();
 }
 
 void
-nsScriptLoader::ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest)
+ScriptLoader::ContinueParserAsync(ScriptLoadRequest* aParserBlockingRequest)
 {
   aParserBlockingRequest->mElement->ContinueParserAsync();
 }
 
 uint32_t
-nsScriptLoader::NumberOfProcessors()
+ScriptLoader::NumberOfProcessors()
 {
   if (mNumberOfProcessors > 0)
     return mNumberOfProcessors;
 
   int32_t numProcs = PR_GetNumberOfProcessors();
   if (numProcs > 0)
     mNumberOfProcessors = numProcs;
   return mNumberOfProcessors;
 }
 
 void
-nsScriptLoader::MaybeMoveToLoadedList(nsScriptLoadRequest* aRequest)
+ScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest)
 {
   MOZ_ASSERT(aRequest->IsReadyToRun());
 
   // If it's async, move it to the loaded list.  aRequest->mIsAsync really
   // _should_ be in a list, but the consequences if it's not are bad enough we
   // want to avoid trying to move it if it's not.
   if (aRequest->mIsAsync) {
     MOZ_ASSERT(aRequest->isInList());
     if (aRequest->isInList()) {
-      RefPtr<nsScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
+      RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
       mLoadedAsyncRequests.AppendElement(req);
     }
   }
 }
 
 nsresult
-nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
-                                     nsIIncrementalStreamLoader* aLoader,
-                                     nsresult aStatus)
+ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
+                                   nsIIncrementalStreamLoader* aLoader,
+                                   nsresult aStatus)
 {
   if (NS_FAILED(aStatus)) {
     return aStatus;
   }
 
   if (aRequest->IsCanceled()) {
     return NS_BINDING_ABORTED;
   }
@@ -3249,17 +3249,17 @@ nsScriptLoader::PrepareLoadedRequest(nsS
                 !aRequest->AsModuleRequest()->IsTopLevel() &&
                 !aRequest->isInList()) ||
                mPreloads.Contains(aRequest, PreloadRequestComparator()) ||
                mParserBlockingRequest,
                "aRequest should be pending!");
 
   if (aRequest->IsModuleRequest()) {
     MOZ_ASSERT(aRequest->IsSource());
-    nsModuleLoadRequest* request = aRequest->AsModuleRequest();
+    ModuleLoadRequest* request = aRequest->AsModuleRequest();
 
     // When loading a module, only responses with a JavaScript MIME type are
     // acceptable.
     nsAutoCString mimeType;
     channel->GetContentType(mimeType);
     NS_ConvertUTF8toUTF16 typeString(mimeType);
     if (!nsContentUtils::IsJavascriptMIMEType(typeString)) {
       return NS_ERROR_FAILURE;
@@ -3280,17 +3280,17 @@ nsScriptLoader::PrepareLoadedRequest(nsS
   // The script is now loaded and ready to run.
   aRequest->SetReady();
 
   // If this is currently blocking the parser, attempt to compile it off-main-thread.
   if (aRequest == mParserBlockingRequest && NumberOfProcessors() > 1) {
     MOZ_ASSERT(!aRequest->IsModuleRequest());
     nsresult rv = AttemptAsyncScriptCompile(aRequest);
     if (rv == NS_OK) {
-      MOZ_ASSERT(aRequest->mProgress == nsScriptLoadRequest::Progress::Compiling,
+      MOZ_ASSERT(aRequest->mProgress == ScriptLoadRequest::Progress::Compiling,
                  "Request should be off-thread compiling now.");
       return NS_OK;
     }
 
     // If off-thread compile errored, return the error.
     if (rv != NS_ERROR_FAILURE) {
       return rv;
     }
@@ -3299,17 +3299,17 @@ nsScriptLoader::PrepareLoadedRequest(nsS
   }
 
   MaybeMoveToLoadedList(aRequest);
 
   return NS_OK;
 }
 
 void
-nsScriptLoader::ParsingComplete(bool aTerminated)
+ScriptLoader::ParsingComplete(bool aTerminated)
 {
   if (mDeferEnabled) {
     // Have to check because we apparently get ParsingComplete
     // without BeginDeferringScripts in some cases
     mDocumentParsingDone = true;
   }
   mDeferEnabled = false;
   if (aTerminated) {
@@ -3325,48 +3325,48 @@ nsScriptLoader::ParsingComplete(bool aTe
   }
 
   // Have to call this even if aTerminated so we'll correctly unblock
   // onload and all.
   ProcessPendingRequests();
 }
 
 void
-nsScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
-                           const nsAString &aType,
-                           const nsAString &aCrossOrigin,
-                           const nsAString& aIntegrity,
-                           bool aScriptFromHead,
-                           const mozilla::net::ReferrerPolicy aReferrerPolicy)
+ScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
+                         const nsAString &aType,
+                         const nsAString &aCrossOrigin,
+                         const nsAString& aIntegrity,
+                         bool aScriptFromHead,
+                         const mozilla::net::ReferrerPolicy aReferrerPolicy)
 {
   NS_ENSURE_TRUE_VOID(mDocument);
   // Check to see if scripts has been turned off.
   if (!mEnabled || !mDocument->IsScriptEnabled()) {
     return;
   }
 
   // TODO: Preload module scripts.
   if (ModuleScriptsEnabled() && aType.LowerCaseEqualsASCII("module")) {
     return;
   }
 
   SRIMetadata sriMetadata;
   if (!aIntegrity.IsEmpty()) {
     MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
-            ("nsScriptLoader::PreloadURI, integrity=%s",
+            ("ScriptLoader::PreloadURI, integrity=%s",
              NS_ConvertUTF16toUTF8(aIntegrity).get()));
     nsAutoCString sourceUri;
     if (mDocument->GetDocumentURI()) {
       mDocument->GetDocumentURI()->GetAsciiSpec(sourceUri);
     }
     SRICheck::IntegrityMetadata(aIntegrity, sourceUri, mReporter, &sriMetadata);
   }
 
-  RefPtr<nsScriptLoadRequest> request =
-    CreateLoadRequest(nsScriptKind::Classic, nullptr, 0,
+  RefPtr<ScriptLoadRequest> request =
+    CreateLoadRequest(ScriptKind::Classic, nullptr, 0,
                       Element::StringToCORSMode(aCrossOrigin), sriMetadata);
   request->mURI = aURI;
   request->mIsInline = false;
   request->mReferrerPolicy = aReferrerPolicy;
   request->mScriptFromHead = aScriptFromHead;
 
   nsresult rv = StartLoad(request);
   if (NS_FAILED(rv)) {
@@ -3374,68 +3374,68 @@ nsScriptLoader::PreloadURI(nsIURI *aURI,
   }
 
   PreloadInfo *pi = mPreloads.AppendElement();
   pi->mRequest = request;
   pi->mCharset = aCharset;
 }
 
 void
-nsScriptLoader::AddDeferRequest(nsScriptLoadRequest* aRequest)
+ScriptLoader::AddDeferRequest(ScriptLoadRequest* aRequest)
 {
   aRequest->mIsDefer = true;
   mDeferRequests.AppendElement(aRequest);
   if (mDeferEnabled && aRequest == mDeferRequests.getFirst() &&
       mDocument && !mBlockingDOMContentLoaded) {
     MOZ_ASSERT(mDocument->GetReadyStateEnum() == nsIDocument::READYSTATE_LOADING);
     mBlockingDOMContentLoaded = true;
     mDocument->BlockDOMContentLoaded();
   }
 }
 
 bool
-nsScriptLoader::MaybeRemovedDeferRequests()
+ScriptLoader::MaybeRemovedDeferRequests()
 {
   if (mDeferRequests.isEmpty() && mDocument &&
       mBlockingDOMContentLoaded) {
     mBlockingDOMContentLoaded = false;
     mDocument->UnblockDOMContentLoaded();
     return true;
   }
   return false;
 }
 
 //////////////////////////////////////////////////////////////
-// nsScriptLoadHandler
+// ScriptLoadHandler
 //////////////////////////////////////////////////////////////
 
-nsScriptLoadHandler::nsScriptLoadHandler(nsScriptLoader *aScriptLoader,
-                                         nsScriptLoadRequest *aRequest,
-                                         mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
+ScriptLoadHandler::ScriptLoadHandler(ScriptLoader *aScriptLoader,
+                                     ScriptLoadRequest *aRequest,
+                                     mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
   : mScriptLoader(aScriptLoader),
     mRequest(aRequest),
     mSRIDataVerifier(aSRIDataVerifier),
     mSRIStatus(NS_OK),
     mDecoder()
 {
   MOZ_ASSERT(mRequest->IsUnknownDataType());
   MOZ_ASSERT(mRequest->IsLoading());
 }
 
-nsScriptLoadHandler::~nsScriptLoadHandler()
+ScriptLoadHandler::~ScriptLoadHandler()
 {}
 
-NS_IMPL_ISUPPORTS(nsScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
+NS_IMPL_ISUPPORTS(ScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
 
 NS_IMETHODIMP
-nsScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
-                                       nsISupports* aContext,
-                                       uint32_t aDataLength,
-                                       const uint8_t* aData,
-                                       uint32_t *aConsumedLength)
+ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
+                                     nsISupports* aContext,
+                                     uint32_t aDataLength,
+                                     const uint8_t* aData,
+                                     uint32_t *aConsumedLength)
 {
   if (mRequest->IsCanceled()) {
     // If request cancelled, ignore any incoming data.
     *aConsumedLength = aDataLength;
     return NS_OK;
   }
 
   nsresult rv = NS_OK;
@@ -3475,19 +3475,19 @@ nsScriptLoadHandler::OnIncrementalData(n
       return channelRequest->Cancel(mScriptLoader->RestartLoad(mRequest));
     }
   }
 
   return rv;
 }
 
 nsresult
-nsScriptLoadHandler::DecodeRawData(const uint8_t* aData,
-                                   uint32_t aDataLength,
-                                   bool aEndOfStream)
+ScriptLoadHandler::DecodeRawData(const uint8_t* aData,
+                                 uint32_t aDataLength,
+                                 bool aEndOfStream)
 {
   int32_t srcLen = aDataLength;
   const char* src = reinterpret_cast<const char *>(aData);
   int32_t dstLen;
   nsresult rv =
     mDecoder->GetMaxLength(src, srcLen, &dstLen);
 
   NS_ENSURE_SUCCESS(rv, rv);
@@ -3511,20 +3511,20 @@ nsScriptLoadHandler::DecodeRawData(const
   haveRead += dstLen;
   MOZ_ASSERT(haveRead <= capacity.value(), "mDecoder produced more data than expected");
   MOZ_ALWAYS_TRUE(mRequest->mScriptText.resizeUninitialized(haveRead));
 
   return NS_OK;
 }
 
 bool
-nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
-                                   const uint8_t* aData,
-                                   uint32_t aDataLength,
-                                   bool aEndOfStream)
+ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
+                                 const uint8_t* aData,
+                                 uint32_t aDataLength,
+                                 bool aEndOfStream)
 {
   // Check if decoder has already been created.
   if (mDecoder) {
     return true;
   }
 
   nsAutoCString charset;
   if (!EnsureDecoder(aLoader, aData, aDataLength, aEndOfStream, charset)) {
@@ -3534,21 +3534,21 @@ nsScriptLoadHandler::EnsureDecoder(nsIIn
     charset = "?";
   }
   mozilla::Telemetry::Accumulate(mozilla::Telemetry::DOM_SCRIPT_SRC_ENCODING,
     charset);
   return true;
 }
 
 bool
-nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
-                                   const uint8_t* aData,
-                                   uint32_t aDataLength,
-                                   bool aEndOfStream,
-                                   nsCString& oCharset)
+ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
+                                 const uint8_t* aData,
+                                 uint32_t aDataLength,
+                                 bool aEndOfStream,
+                                 nsCString& oCharset)
 {
   // JavaScript modules are always UTF-8.
   if (mRequest->IsModuleRequest()) {
     oCharset = "UTF-8";
     mDecoder = EncodingUtils::DecoderForEncoding(oCharset);
     return true;
   }
 
@@ -3581,19 +3581,19 @@ nsScriptLoadHandler::EnsureDecoder(nsIIn
   }
 
   // Check the hint charset from the script element or preload
   // request.
   nsAutoString hintCharset;
   if (!mRequest->IsPreload()) {
     mRequest->mElement->GetScriptCharset(hintCharset);
   } else {
-    nsTArray<nsScriptLoader::PreloadInfo>::index_type i =
+    nsTArray<ScriptLoader::PreloadInfo>::index_type i =
       mScriptLoader->mPreloads.IndexOf(mRequest, 0,
-            nsScriptLoader::PreloadRequestComparator());
+            ScriptLoader::PreloadRequestComparator());
 
     NS_ASSERTION(i != mScriptLoader->mPreloads.NoIndex,
                  "Incorrect preload bookkeeping");
     hintCharset = mScriptLoader->mPreloads[i].mCharset;
   }
 
   if (EncodingUtils::FindEncodingForLabel(hintCharset, oCharset)) {
     mDecoder = EncodingUtils::DecoderForEncoding(oCharset);
@@ -3613,83 +3613,83 @@ nsScriptLoadHandler::EnsureDecoder(nsIIn
   // with the Encoding Standard.
   oCharset = "windows-1252";
   mDecoder = EncodingUtils::DecoderForEncoding(oCharset);
 
   return true;
 }
 
 nsresult
-nsScriptLoadHandler::MaybeDecodeSRI()
+ScriptLoadHandler::MaybeDecodeSRI()
 {
   if (!mSRIDataVerifier || mSRIDataVerifier->IsComplete() || NS_FAILED(mSRIStatus)) {
     return NS_OK;
   }
 
   // Skip until the content is large enough to be decoded.
   if (mRequest->mScriptBytecode.length() <= mSRIDataVerifier->DataSummaryLength()) {
     return NS_OK;
   }
 
   mSRIStatus = mSRIDataVerifier->ImportDataSummary(
     mRequest->mScriptBytecode.length(), mRequest->mScriptBytecode.begin());
 
   if (NS_FAILED(mSRIStatus)) {
     // We are unable to decode the hash contained in the alternate data which
     // contains the bytecode, or it does not use the same algorithm.
-    LOG(("nsScriptLoadHandler::MaybeDecodeSRI, failed to decode SRI, restart request"));
+    LOG(("ScriptLoadHandler::MaybeDecodeSRI, failed to decode SRI, restart request"));
     return mSRIStatus;
   }
 
   mRequest->mBytecodeOffset = mSRIDataVerifier->DataSummaryLength();
   return NS_OK;
 }
 
 nsresult
-nsScriptLoadHandler::EnsureKnownDataType(nsIIncrementalStreamLoader *aLoader)
+ScriptLoadHandler::EnsureKnownDataType(nsIIncrementalStreamLoader *aLoader)
 {
   MOZ_ASSERT(mRequest->IsUnknownDataType());
   MOZ_ASSERT(mRequest->IsLoading());
   if (mRequest->IsLoadingSource()) {
-    mRequest->mDataType = nsScriptLoadRequest::DataType::Source;
+    mRequest->mDataType = ScriptLoadRequest::DataType::Source;
     TRACE_FOR_TEST(mRequest->mElement, "scriptloader_load_source");
     return NS_OK;
   }
 
   nsCOMPtr<nsIRequest> req;
   nsresult rv = aLoader->GetRequest(getter_AddRefs(req));
   MOZ_ASSERT(req, "StreamLoader's request went away prematurely");
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsICacheInfoChannel> cic(do_QueryInterface(req));
   if (cic) {
     nsAutoCString altDataType;
     cic->GetAlternativeDataType(altDataType);
     if (altDataType == kBytecodeMimeType) {
-      mRequest->mDataType = nsScriptLoadRequest::DataType::Bytecode;
+      mRequest->mDataType = ScriptLoadRequest::DataType::Bytecode;
       TRACE_FOR_TEST(mRequest->mElement, "scriptloader_load_bytecode");
     } else {
-      mRequest->mDataType = nsScriptLoadRequest::DataType::Source;
+      mRequest->mDataType = ScriptLoadRequest::DataType::Source;
       TRACE_FOR_TEST(mRequest->mElement, "scriptloader_load_source");
     }
   } else {
-    mRequest->mDataType = nsScriptLoadRequest::DataType::Source;
+    mRequest->mDataType = ScriptLoadRequest::DataType::Source;
     TRACE_FOR_TEST(mRequest->mElement, "scriptloader_load_source");
   }
   MOZ_ASSERT(!mRequest->IsUnknownDataType());
   MOZ_ASSERT(mRequest->IsLoading());
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
-                                      nsISupports* aContext,
-                                      nsresult aStatus,
-                                      uint32_t aDataLength,
-                                      const uint8_t* aData)
+ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
+                                    nsISupports* aContext,
+                                    nsresult aStatus,
+                                    uint32_t aDataLength,
+                                    const uint8_t* aData)
 {
   nsresult rv = NS_OK;
   if (LOG_ENABLED()) {
     nsAutoCString url;
     mRequest->mURI->GetAsciiSpec(url);
     LOG(("ScriptLoadRequest (%p): Stream complete (url = %s)",
          mRequest.get(), url.get()));
   }
@@ -3723,17 +3723,17 @@ nsScriptLoadHandler::OnStreamComplete(ns
         return NS_ERROR_OUT_OF_MEMORY;
       }
 
       LOG(("ScriptLoadRequest (%p): Bytecode length = %u",
            mRequest.get(), unsigned(mRequest->mScriptBytecode.length())));
 
       // If we abort while decoding the SRI, we fallback on explictly requesting
       // the source. Thus, we should not continue in
-      // nsScriptLoader::OnStreamComplete, which removes the request from the
+      // ScriptLoader::OnStreamComplete, which removes the request from the
       // waiting lists.
       rv = MaybeDecodeSRI();
       if (NS_FAILED(rv)) {
         return channelRequest->Cancel(mScriptLoader->RestartLoad(mRequest));
       }
 
       // The bytecode cache always starts with the SRI hash, thus even if there
       // is no SRI data verifier instance, we still want to skip the hash.
@@ -3770,8 +3770,11 @@ nsScriptLoadHandler::OnStreamComplete(ns
 #undef TRACE_FOR_TEST_BOOL
 #undef TRACE_FOR_TEST_NONE
 
 #undef LOG_ENABLED
 #undef LOG_ERROR
 #undef LOG_WARN
 #undef LOG
 #undef LOG_VERBOSE
+
+} // dom namespace
+} // mozilla namespace
rename from dom/base/nsScriptLoader.h
rename to dom/script/ScriptLoader.h
--- a/dom/base/nsScriptLoader.h
+++ b/dom/script/ScriptLoader.h
@@ -3,18 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * A class that handles loading and evaluation of <script> elements.
  */
 
-#ifndef __nsScriptLoader_h__
-#define __nsScriptLoader_h__
+#ifndef mozilla_dom_ScriptLoader_h
+#define mozilla_dom_ScriptLoader_h
 
 #include "nsCOMPtr.h"
 #include "nsRefPtrHashtable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIScriptElement.h"
 #include "nsCOMArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsTArray.h"
@@ -26,55 +26,54 @@
 #include "mozilla/CORSMode.h"
 #include "mozilla/dom/SRIMetadata.h"
 #include "mozilla/dom/SRICheck.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/Vector.h"
 
-class nsModuleLoadRequest;
-class nsModuleScript;
-class nsScriptLoadRequestList;
 class nsIURI;
 
 namespace JS {
   class SourceBufferHolder;
 } // namespace JS
 
 namespace mozilla {
 namespace dom {
+
 class AutoJSAPI;
-} // namespace dom
-} // namespace mozilla
+class ModuleLoadRequest;
+class ModuleScript;
+class ScriptLoadRequestList;
 
 //////////////////////////////////////////////////////////////
 // Per-request data structure
 //////////////////////////////////////////////////////////////
 
-enum class nsScriptKind {
+enum class ScriptKind {
   Classic,
   Module
 };
 
-class nsScriptLoadRequest : public nsISupports,
-                            private mozilla::LinkedListElement<nsScriptLoadRequest>
+class ScriptLoadRequest : public nsISupports,
+                          private mozilla::LinkedListElement<ScriptLoadRequest>
 {
-  typedef LinkedListElement<nsScriptLoadRequest> super;
+  typedef LinkedListElement<ScriptLoadRequest> super;
 
-  // Allow LinkedListElement<nsScriptLoadRequest> to cast us to itself as needed.
-  friend class mozilla::LinkedListElement<nsScriptLoadRequest>;
-  friend class nsScriptLoadRequestList;
+  // Allow LinkedListElement<ScriptLoadRequest> to cast us to itself as needed.
+  friend class mozilla::LinkedListElement<ScriptLoadRequest>;
+  friend class ScriptLoadRequestList;
 
 protected:
-  virtual ~nsScriptLoadRequest();
+  virtual ~ScriptLoadRequest();
 
 public:
-  nsScriptLoadRequest(nsScriptKind aKind,
-                      nsIScriptElement* aElement,
+  ScriptLoadRequest(ScriptKind aKind,
+                    nsIScriptElement* aElement,
                       uint32_t aVersion,
                       mozilla::CORSMode aCORSMode,
                       const mozilla::dom::SRIMetadata &aIntegrity)
     : mKind(aKind),
       mElement(aElement),
       mScriptFromHead(false),
       mProgress(Progress::Loading),
       mDataType(DataType::Unknown),
@@ -95,24 +94,24 @@ public:
       mLineNo(1),
       mCORSMode(aCORSMode),
       mIntegrity(aIntegrity),
       mReferrerPolicy(mozilla::net::RP_Unset)
   {
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsScriptLoadRequest)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ScriptLoadRequest)
 
   bool IsModuleRequest() const
   {
-    return mKind == nsScriptKind::Module;
+    return mKind == ScriptKind::Module;
   }
 
-  nsModuleLoadRequest* AsModuleRequest();
+  ModuleLoadRequest* AsModuleRequest();
 
   void FireScriptAvailable(nsresult aResult)
   {
     mElement->ScriptAvailable(aResult, mElement, mIsInline, mURI, mLineNo);
   }
   void FireScriptEvaluated(nsresult aResult)
   {
     mElement->ScriptEvaluated(aResult, mElement, mIsInline);
@@ -188,17 +187,17 @@ public:
   }
 
   void MaybeCancelOffThreadScript();
   void DropBytecodeCacheReferences();
 
   using super::getNext;
   using super::isInList;
 
-  const nsScriptKind mKind;
+  const ScriptKind mKind;
   nsCOMPtr<nsIScriptElement> mElement;
   bool mScriptFromHead;   // Synchronous head script block loading of other non js/css content.
   Progress mProgress;     // Are we still waiting for a load to complete?
   DataType mDataType;     // Does this contain Source or Bytecode?
   bool mIsInline;         // Is the script inline or loaded?
   bool mHasSourceMapURL;  // Does the HTTP header have a source map url?
   bool mIsDefer;          // True if we live in mDeferRequests.
   bool mIsAsync;          // True if we live in mLoadingAsyncRequests or mLoadedAsyncRequests.
@@ -232,95 +231,95 @@ public:
   const mozilla::dom::SRIMetadata mIntegrity;
   mozilla::net::ReferrerPolicy mReferrerPolicy;
 
   // Holds the Cache information, which is used to register the bytecode
   // on the cache entry, such that we can load it the next time.
   nsCOMPtr<nsICacheInfoChannel> mCacheInfo;
 };
 
-class nsScriptLoadRequestList : private mozilla::LinkedList<nsScriptLoadRequest>
+class ScriptLoadRequestList : private mozilla::LinkedList<ScriptLoadRequest>
 {
-  typedef mozilla::LinkedList<nsScriptLoadRequest> super;
+  typedef mozilla::LinkedList<ScriptLoadRequest> super;
 
 public:
-  ~nsScriptLoadRequestList();
+  ~ScriptLoadRequestList();
 
   void Clear();
 
 #ifdef DEBUG
-  bool Contains(nsScriptLoadRequest* aElem) const;
+  bool Contains(ScriptLoadRequest* aElem) const;
 #endif // DEBUG
 
   using super::getFirst;
   using super::isEmpty;
 
-  void AppendElement(nsScriptLoadRequest* aElem)
+  void AppendElement(ScriptLoadRequest* aElem)
   {
     MOZ_ASSERT(!aElem->isInList());
     NS_ADDREF(aElem);
     insertBack(aElem);
   }
 
   MOZ_MUST_USE
-  already_AddRefed<nsScriptLoadRequest> Steal(nsScriptLoadRequest* aElem)
+  already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem)
   {
     aElem->removeFrom(*this);
     return dont_AddRef(aElem);
   }
 
   MOZ_MUST_USE
-  already_AddRefed<nsScriptLoadRequest> StealFirst()
+  already_AddRefed<ScriptLoadRequest> StealFirst()
   {
     MOZ_ASSERT(!isEmpty());
     return Steal(getFirst());
   }
 
-  void Remove(nsScriptLoadRequest* aElem)
+  void Remove(ScriptLoadRequest* aElem)
   {
     aElem->removeFrom(*this);
     NS_RELEASE(aElem);
   }
 };
 
 //////////////////////////////////////////////////////////////
 // Script loader implementation
 //////////////////////////////////////////////////////////////
 
-class nsScriptLoader final : public nsISupports
+class ScriptLoader final : public nsISupports
 {
   class MOZ_STACK_CLASS AutoCurrentScriptUpdater
   {
   public:
-    AutoCurrentScriptUpdater(nsScriptLoader* aScriptLoader,
+    AutoCurrentScriptUpdater(ScriptLoader* aScriptLoader,
                              nsIScriptElement* aCurrentScript)
       : mOldScript(aScriptLoader->mCurrentScript)
       , mScriptLoader(aScriptLoader)
     {
       mScriptLoader->mCurrentScript = aCurrentScript;
     }
     ~AutoCurrentScriptUpdater()
     {
       mScriptLoader->mCurrentScript.swap(mOldScript);
     }
   private:
     nsCOMPtr<nsIScriptElement> mOldScript;
-    nsScriptLoader* mScriptLoader;
+    ScriptLoader* mScriptLoader;
   };
 
-  friend class nsModuleLoadRequest;
-  friend class nsScriptRequestProcessor;
-  friend class nsScriptLoadHandler;
+  friend class ModuleLoadRequest;
+  friend class ScriptRequestProcessor;
+  friend class ScriptLoadHandler;
   friend class AutoCurrentScriptUpdater;
 
 public:
-  explicit nsScriptLoader(nsIDocument* aDocument);
+  explicit ScriptLoader(nsIDocument* aDocument);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(nsScriptLoader)
+  NS_DECL_CYCLE_COLLECTION_CLASS(ScriptLoader)
 
   /**
    * The loader maintains a weak reference to the document with
    * which it is initialized. This call forces the reference to
    * be dropped.
    */
   void DropDocumentReference()
   {
@@ -463,22 +462,22 @@ public:
     if (NS_SUCCEEDED(rv)) {
       aBufOut.reset(bufOut);
     }
     return rv;
   };
 
   /**
    * Handle the completion of a stream.  This is called by the
-   * nsScriptLoadHandler object which observes the IncrementalStreamLoader
+   * ScriptLoadHandler object which observes the IncrementalStreamLoader
    * loading the script. The streamed content is expected to be stored on the
    * aRequest argument.
    */
   nsresult OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
-                            nsScriptLoadRequest* aRequest,
+                            ScriptLoadRequest* aRequest,
                             nsresult aChannelStatus,
                             nsresult aSRIStatus,
                             mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier);
 
   /**
    * Returns wether any request is queued, and not executed yet.
    */
   bool HasPendingRequests();
@@ -536,75 +535,75 @@ public:
                           const nsAString& aIntegrity,
                           bool aScriptFromHead,
                           const mozilla::net::ReferrerPolicy aReferrerPolicy);
 
   /**
    * Process a request that was deferred so that the script could be compiled
    * off thread.
    */
-  nsresult ProcessOffThreadRequest(nsScriptLoadRequest *aRequest);
+  nsresult ProcessOffThreadRequest(ScriptLoadRequest *aRequest);
 
-  bool AddPendingChildLoader(nsScriptLoader* aChild) {
+  bool AddPendingChildLoader(ScriptLoader* aChild) {
     return mPendingChildLoaders.AppendElement(aChild) != nullptr;
   }
 
   mozilla::dom::DocGroup* GetDocGroup() const
   {
     return mDocument->GetDocGroup();
   }
 
   /**
    * Register the fact that we saw the load event, and that we need to save the
    * bytecode at the next loop cycle unless new scripts are waiting in the
    * pipeline.
    */
   void LoadEventFired();
 
 private:
-  virtual ~nsScriptLoader();
+  virtual ~ScriptLoader();
 
-  nsScriptLoadRequest* CreateLoadRequest(
-    nsScriptKind aKind,
+  ScriptLoadRequest* CreateLoadRequest(
+    ScriptKind aKind,
     nsIScriptElement* aElement,
     uint32_t aVersion,
     mozilla::CORSMode aCORSMode,
     const mozilla::dom::SRIMetadata &aIntegrity);
 
   /**
    * Unblocks the creator parser of the parser-blocking scripts.
    */
-  void UnblockParser(nsScriptLoadRequest* aParserBlockingRequest);
+  void UnblockParser(ScriptLoadRequest* aParserBlockingRequest);
 
   /**
    * Asynchronously resumes the creator parser of the parser-blocking scripts.
    */
-  void ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest);
+  void ContinueParserAsync(ScriptLoadRequest* aParserBlockingRequest);
 
 
   /**
    * Helper function to check the content policy for a given request.
    */
   static nsresult CheckContentPolicy(nsIDocument* aDocument,
                                      nsISupports *aContext,
                                      nsIURI *aURI,
                                      const nsAString &aType,
                                      bool aIsPreLoad);
 
   /**
    * Start a load for aRequest's URI.
    */
-  nsresult StartLoad(nsScriptLoadRequest *aRequest);
+  nsresult StartLoad(ScriptLoadRequest *aRequest);
 
   /**
    * Abort the current stream, and re-start with a new load request from scratch
    * without requesting any alternate data. Returns NS_BINDING_RETARGETED on
    * success, as this error code is used to abort the input stream.
    */
-  nsresult RestartLoad(nsScriptLoadRequest *aRequest);
+  nsresult RestartLoad(ScriptLoadRequest *aRequest);
 
   /**
    * Process any pending requests asynchronously (i.e. off an event) if there
    * are any. Note that this is a no-op if there aren't any currently pending
    * requests.
    *
    * This function is virtual to allow cross-library calls to SetEnabled()
    */
@@ -630,161 +629,161 @@ private:
   /**
    * Return whether this loader is ready to execute scripts in general.
    */
   bool ReadyToExecuteScripts()
   {
     return mEnabled && !mBlockerCount;
   }
 
-  nsresult AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest);
-  nsresult ProcessRequest(nsScriptLoadRequest* aRequest);
-  nsresult CompileOffThreadOrProcessRequest(nsScriptLoadRequest* aRequest);
+  nsresult AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest);
+  nsresult ProcessRequest(ScriptLoadRequest* aRequest);
+  nsresult CompileOffThreadOrProcessRequest(ScriptLoadRequest* aRequest);
   void FireScriptAvailable(nsresult aResult,
-                           nsScriptLoadRequest* aRequest);
+                           ScriptLoadRequest* aRequest);
   void FireScriptEvaluated(nsresult aResult,
-                           nsScriptLoadRequest* aRequest);
-  nsresult EvaluateScript(nsScriptLoadRequest* aRequest);
+                           ScriptLoadRequest* aRequest);
+  nsresult EvaluateScript(ScriptLoadRequest* aRequest);
 
   /**
    * Queue the current script load request to be saved, when the page
    * initialization ends. The page initialization end is defined as being the
    * time when the load event got received, and when no more scripts are waiting
    * to be executed.
    */
-  void RegisterForBytecodeEncoding(nsScriptLoadRequest* aRequest);
+  void RegisterForBytecodeEncoding(ScriptLoadRequest* aRequest);
 
   /**
    * Check if all conditions are met, i-e that the onLoad event fired and that
    * no more script have to be processed.  If all conditions are met, queue an
    * event to encode all the bytecode and save them on the cache.
    */
   void MaybeTriggerBytecodeEncoding();
 
   /**
    * Iterate over all script load request and save the bytecode of executed
    * functions on the cache provided by the channel.
    */
   void EncodeBytecode();
-  void EncodeRequestBytecode(JSContext* aCx, nsScriptLoadRequest* aRequest);
+  void EncodeRequestBytecode(JSContext* aCx, ScriptLoadRequest* aRequest);
 
   void GiveUpBytecodeEncoding();
 
   already_AddRefed<nsIScriptGlobalObject> GetScriptGlobalObject();
   nsresult FillCompileOptionsForRequest(const mozilla::dom::AutoJSAPI& jsapi,
-                                        nsScriptLoadRequest* aRequest,
+                                        ScriptLoadRequest* aRequest,
                                         JS::Handle<JSObject*> aScopeChain,
                                         JS::CompileOptions* aOptions);
 
   uint32_t NumberOfProcessors();
-  nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
+  nsresult PrepareLoadedRequest(ScriptLoadRequest* aRequest,
                                 nsIIncrementalStreamLoader* aLoader,
                                 nsresult aStatus);
 
-  void AddDeferRequest(nsScriptLoadRequest* aRequest);
+  void AddDeferRequest(ScriptLoadRequest* aRequest);
   bool MaybeRemovedDeferRequests();
 
-  void MaybeMoveToLoadedList(nsScriptLoadRequest* aRequest);
+  void MaybeMoveToLoadedList(ScriptLoadRequest* aRequest);
 
-  JS::SourceBufferHolder GetScriptSource(nsScriptLoadRequest* aRequest,
+  JS::SourceBufferHolder GetScriptSource(ScriptLoadRequest* aRequest,
                                          nsAutoString& inlineData);
 
   bool ModuleScriptsEnabled();
 
-  void SetModuleFetchStarted(nsModuleLoadRequest *aRequest);
-  void SetModuleFetchFinishedAndResumeWaitingRequests(nsModuleLoadRequest *aRequest,
+  void SetModuleFetchStarted(ModuleLoadRequest *aRequest);
+  void SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
                                                       nsresult aResult);
 
-  bool IsFetchingModule(nsModuleLoadRequest *aRequest) const;
+  bool IsFetchingModule(ModuleLoadRequest *aRequest) const;
 
-  bool ModuleMapContainsModule(nsModuleLoadRequest *aRequest) const;
-  RefPtr<mozilla::GenericPromise> WaitForModuleFetch(nsModuleLoadRequest *aRequest);
-  nsModuleScript* GetFetchedModule(nsIURI* aURL) const;
+  bool ModuleMapContainsModule(ModuleLoadRequest *aRequest) const;
+  RefPtr<mozilla::GenericPromise> WaitForModuleFetch(ModuleLoadRequest *aRequest);
+  ModuleScript* GetFetchedModule(nsIURI* aURL) const;
 
   friend bool
   HostResolveImportedModule(JSContext* aCx, unsigned argc, JS::Value* vp);
 
-  nsresult CreateModuleScript(nsModuleLoadRequest* aRequest);
-  nsresult ProcessFetchedModuleSource(nsModuleLoadRequest* aRequest);
-  void ProcessLoadedModuleTree(nsModuleLoadRequest* aRequest);
-  bool InstantiateModuleTree(nsModuleLoadRequest* aRequest);
-  void StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest);
+  nsresult CreateModuleScript(ModuleLoadRequest* aRequest);
+  nsresult ProcessFetchedModuleSource(ModuleLoadRequest* aRequest);
+  void ProcessLoadedModuleTree(ModuleLoadRequest* aRequest);
+  bool InstantiateModuleTree(ModuleLoadRequest* aRequest);
+  void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);
 
   RefPtr<mozilla::GenericPromise>
-  StartFetchingModuleAndDependencies(nsModuleLoadRequest* aRequest, nsIURI* aURI);
+  StartFetchingModuleAndDependencies(ModuleLoadRequest* aRequest, nsIURI* aURI);
 
   nsIDocument* mDocument;                   // [WEAK]
   nsCOMArray<nsIScriptLoaderObserver> mObservers;
-  nsScriptLoadRequestList mNonAsyncExternalScriptInsertedRequests;
+  ScriptLoadRequestList mNonAsyncExternalScriptInsertedRequests;
   // mLoadingAsyncRequests holds async requests while they're loading; when they
   // have been loaded they are moved to mLoadedAsyncRequests.
-  nsScriptLoadRequestList mLoadingAsyncRequests;
-  nsScriptLoadRequestList mLoadedAsyncRequests;
-  nsScriptLoadRequestList mDeferRequests;
-  nsScriptLoadRequestList mXSLTRequests;
-  RefPtr<nsScriptLoadRequest> mParserBlockingRequest;
+  ScriptLoadRequestList mLoadingAsyncRequests;
+  ScriptLoadRequestList mLoadedAsyncRequests;
+  ScriptLoadRequestList mDeferRequests;
+  ScriptLoadRequestList mXSLTRequests;
+  RefPtr<ScriptLoadRequest> mParserBlockingRequest;
 
   // List of script load request that are holding a buffer which has to be saved
   // on the cache.
-  nsScriptLoadRequestList mBytecodeEncodingQueue;
+  ScriptLoadRequestList mBytecodeEncodingQueue;
 
   // In mRequests, the additional information here is stored by the element.
   struct PreloadInfo {
-    RefPtr<nsScriptLoadRequest> mRequest;
+    RefPtr<ScriptLoadRequest> mRequest;
     nsString mCharset;
   };
 
-  friend void ImplCycleCollectionUnlink(nsScriptLoader::PreloadInfo& aField);
+  friend void ImplCycleCollectionUnlink(ScriptLoader::PreloadInfo& aField);
   friend void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                                          nsScriptLoader::PreloadInfo& aField,
+                                          ScriptLoader::PreloadInfo& aField,
                                           const char* aName, uint32_t aFlags);
 
   struct PreloadRequestComparator {
-    bool Equals(const PreloadInfo &aPi, nsScriptLoadRequest * const &aRequest)
+    bool Equals(const PreloadInfo &aPi, ScriptLoadRequest * const &aRequest)
         const
     {
       return aRequest == aPi.mRequest;
     }
   };
   struct PreloadURIComparator {
     bool Equals(const PreloadInfo &aPi, nsIURI * const &aURI) const;
   };
   nsTArray<PreloadInfo> mPreloads;
 
   nsCOMPtr<nsIScriptElement> mCurrentScript;
   nsCOMPtr<nsIScriptElement> mCurrentParserInsertedScript;
-  nsTArray< RefPtr<nsScriptLoader> > mPendingChildLoaders;
+  nsTArray< RefPtr<ScriptLoader> > mPendingChildLoaders;
   uint32_t mParserBlockingBlockerCount;
   uint32_t mBlockerCount;
   uint32_t mNumberOfProcessors;
   bool mEnabled;
   bool mDeferEnabled;
   bool mDocumentParsingDone;
   bool mBlockingDOMContentLoaded;
   bool mLoadEventFired;
 
   // Module map
   nsRefPtrHashtable<nsURIHashKey, mozilla::GenericPromise::Private> mFetchingModules;
-  nsRefPtrHashtable<nsURIHashKey, nsModuleScript> mFetchedModules;
+  nsRefPtrHashtable<nsURIHashKey, ModuleScript> mFetchedModules;
 
   nsCOMPtr<nsIConsoleReportCollector> mReporter;
 };
 
-class nsScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver
+class ScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver
 {
 public:
-  explicit nsScriptLoadHandler(nsScriptLoader* aScriptLoader,
-                               nsScriptLoadRequest *aRequest,
-                               mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier);
+  explicit ScriptLoadHandler(ScriptLoader* aScriptLoader,
+                             ScriptLoadRequest *aRequest,
+                             mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIINCREMENTALSTREAMLOADEROBSERVER
 
 private:
-  virtual ~nsScriptLoadHandler();
+  virtual ~ScriptLoadHandler();
 
   /*
    * Once the charset is found by the EnsureDecoder function, we can
    * incrementally convert the charset to the one expected by the JS Parser.
    */
   nsresult DecodeRawData(const uint8_t* aData, uint32_t aDataLength,
                          bool aEndOfStream);
 
@@ -805,20 +804,20 @@ private:
    * does not match the expectation of the document.
    */
   nsresult MaybeDecodeSRI();
 
   // Query the channel to find the data type associated with the input stream.
   nsresult EnsureKnownDataType(nsIIncrementalStreamLoader *aLoader);
 
   // ScriptLoader which will handle the parsed script.
-  RefPtr<nsScriptLoader>        mScriptLoader;
+  RefPtr<ScriptLoader>        mScriptLoader;
 
-  // The nsScriptLoadRequest for this load. Decoded data are accumulated on it.
-  RefPtr<nsScriptLoadRequest>   mRequest;
+  // The ScriptLoadRequest for this load. Decoded data are accumulated on it.
+  RefPtr<ScriptLoadRequest>   mRequest;
 
   // SRI data verifier.
   nsAutoPtr<mozilla::dom::SRICheckDataVerifier> mSRIDataVerifier;
 
   // Status of SRI data operations.
   nsresult                      mSRIStatus;
 
   // Unicode decoder for charset.
@@ -840,12 +839,15 @@ public:
   ~nsAutoScriptLoaderDisabler()
   {
     if (mWasEnabled) {
       mLoader->SetEnabled(true);
     }
   }
 
   bool mWasEnabled;
-  RefPtr<nsScriptLoader> mLoader;
+  RefPtr<ScriptLoader> mLoader;
 };
 
-#endif //__nsScriptLoader_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_ScriptLoader_h
rename from dom/base/ScriptSettings.cpp
rename to dom/script/ScriptSettings.cpp
rename from dom/base/ScriptSettings.h
rename to dom/script/ScriptSettings.h
new file mode 100644
--- /dev/null
+++ b/dom/script/moz.build
@@ -0,0 +1,39 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+with Files("**"):
+    BUG_COMPONENT = ("Core", "DOM")
+
+XPIDL_SOURCES += [
+    'nsIScriptLoaderObserver.idl',
+]
+
+XPIDL_MODULE = 'dom'
+
+EXPORTS += [
+    'nsIScriptElement.h',
+]
+
+EXPORTS.mozilla.dom += [
+    'ScriptElement.h',
+    'ScriptLoader.h',
+    'ScriptSettings.h',
+]
+
+UNIFIED_SOURCES += [
+    'ScriptElement.cpp',
+    'ScriptLoader.cpp',
+    'ScriptSettings.cpp',
+]
+
+LOCAL_INCLUDES += [
+    '/dom/base',
+    '/dom/workers',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul'
rename from dom/base/nsIScriptElement.h
rename to dom/script/nsIScriptElement.h
rename from dom/base/nsIScriptLoaderObserver.idl
rename to dom/script/nsIScriptLoaderObserver.idl
--- a/dom/svg/SVGScriptElement.cpp
+++ b/dom/svg/SVGScriptElement.cpp
@@ -38,17 +38,17 @@ NS_IMPL_ISUPPORTS_INHERITED(SVGScriptEle
                             nsIScriptElement, nsIMutationObserver)
 
 //----------------------------------------------------------------------
 // Implementation
 
 SVGScriptElement::SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                                    FromParser aFromParser)
   : SVGScriptElementBase(aNodeInfo)
-  , nsScriptElement(aFromParser)
+  , ScriptElement(aFromParser)
 {
   AddMutationObserver(this);
 }
 
 SVGScriptElement::~SVGScriptElement()
 {
 }
 
@@ -185,17 +185,17 @@ SVGScriptElement::FreezeUriAsyncDefer()
     // At this point mUri will be null for invalid URLs.
     mExternal = true;
   }
 
   mFrozen = true;
 }
 
 //----------------------------------------------------------------------
-// nsScriptElement methods
+// ScriptElement methods
 
 bool
 SVGScriptElement::HasScriptContent()
 {
   return (mFrozen ? mExternal
                   : mStringAttributes[HREF].IsExplicitlySet() ||
                     mStringAttributes[XLINK_HREF].IsExplicitlySet()) ||
          nsContentUtils::HasNonEmptyTextContent(this);
--- a/dom/svg/SVGScriptElement.h
+++ b/dom/svg/SVGScriptElement.h
@@ -5,31 +5,31 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SVGScriptElement_h
 #define mozilla_dom_SVGScriptElement_h
 
 #include "nsSVGElement.h"
 #include "nsCOMPtr.h"
 #include "nsSVGString.h"
-#include "nsScriptElement.h"
+#include "mozilla/dom/ScriptElement.h"
 
 class nsIDocument;
 
 nsresult NS_NewSVGScriptElement(nsIContent **aResult,
                                 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                 mozilla::dom::FromParser aFromParser);
 
 namespace mozilla {
 namespace dom {
 
 typedef nsSVGElement SVGScriptElementBase;
 
 class SVGScriptElement final : public SVGScriptElementBase,
-                               public nsScriptElement
+                               public ScriptElement
 {
 protected:
   friend nsresult (::NS_NewSVGScriptElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                             mozilla::dom::FromParser aFromParser));
   SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
                    FromParser aFromParser);
 
@@ -42,17 +42,17 @@ public:
 
   // nsIScriptElement
   virtual bool GetScriptType(nsAString& type) override;
   virtual void GetScriptText(nsAString& text) override;
   virtual void GetScriptCharset(nsAString& charset) override;
   virtual void FreezeUriAsyncDefer() override;
   virtual CORSMode GetCORSMode() const override;
 
-  // nsScriptElement
+  // ScriptElement
   virtual bool HasScriptContent() override;
 
   // nsIContent specializations:
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) override;
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify) override;
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -29,17 +29,16 @@
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsDocShellCID.h"
 #include "nsISupportsPrimitives.h"
 #include "nsNetUtil.h"
 #include "nsIPipe.h"
 #include "nsIOutputStream.h"
 #include "nsPrintfCString.h"
-#include "nsScriptLoader.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "xpcpublic.h"
 
 #include "mozilla/Assertions.h"
@@ -53,16 +52,17 @@
 #include "mozilla/dom/ChannelInfo.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/InternalResponse.h"
 #include "mozilla/dom/nsCSPService.h"
 #include "mozilla/dom/nsCSPUtils.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 #include "mozilla/dom/Response.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/SRILogHelper.h"
 #include "mozilla/UniquePtr.h"
 #include "Principal.h"
 #include "WorkerHolder.h"
 #include "WorkerPrivate.h"
 #include "WorkerRunnable.h"
 #include "WorkerScope.h"
@@ -422,17 +422,17 @@ private:
 
   nsString mCacheName;
   OriginAttributes mOriginAttributes;
 };
 
 NS_IMPL_ISUPPORTS0(CacheCreator)
 
 class CacheScriptLoader final : public PromiseNativeHandler
-                                  , public nsIStreamLoaderObserver
+                              , public nsIStreamLoaderObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTREAMLOADEROBSERVER
 
   CacheScriptLoader(WorkerPrivate* aWorkerPrivate, ScriptLoadInfo& aLoadInfo,
                     uint32_t aIndex, bool aIsWorkerScript,
                     ScriptLoaderRunnable* aRunnable)
@@ -1073,24 +1073,24 @@ private:
       Unused << httpChannel->GetResponseHeader(
         NS_LITERAL_CSTRING("referrer-policy"),
         tRPHeaderCValue);
     }
 
     // May be null.
     nsIDocument* parentDoc = mWorkerPrivate->GetDocument();
 
-    // Use the regular nsScriptLoader for this grunt work! Should be just fine
+    // Use the regular ScriptLoader for this grunt work! Should be just fine
     // because we're running on the main thread.
     // Unlike <script> tags, Worker scripts are always decoded as UTF-8,
     // per spec. So we explicitly pass in the charset hint.
-    rv = nsScriptLoader::ConvertToUTF16(aLoadInfo.mChannel, aString, aStringLen,
-                                        NS_LITERAL_STRING("UTF-8"), parentDoc,
-                                        aLoadInfo.mScriptTextBuf,
-                                        aLoadInfo.mScriptTextLength);
+    rv = ScriptLoader::ConvertToUTF16(aLoadInfo.mChannel, aString, aStringLen,
+                                      NS_LITERAL_STRING("UTF-8"), parentDoc,
+                                      aLoadInfo.mScriptTextBuf,
+                                      aLoadInfo.mScriptTextLength);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     if (!aLoadInfo.mScriptTextLength && !aLoadInfo.mScriptTextBuf) {
       nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                       NS_LITERAL_CSTRING("DOM"), parentDoc,
                                       nsContentUtils::eDOM_PROPERTIES,
@@ -1207,20 +1207,20 @@ private:
     loadInfo.mMutedErrorFlag.emplace(!principal->Subsumes(responsePrincipal));
 
     // May be null.
     nsIDocument* parentDoc = mWorkerPrivate->GetDocument();
 
     MOZ_ASSERT(!loadInfo.mScriptTextBuf);
 
     nsresult rv =
-      nsScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
-                                     NS_LITERAL_STRING("UTF-8"), parentDoc,
-                                     loadInfo.mScriptTextBuf,
-                                     loadInfo.mScriptTextLength);
+      ScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
+                                   NS_LITERAL_STRING("UTF-8"), parentDoc,
+                                   loadInfo.mScriptTextBuf,
+                                   loadInfo.mScriptTextLength);
     if (NS_SUCCEEDED(rv) && IsMainWorkerScript()) {
       nsCOMPtr<nsIURI> finalURI;
       rv = NS_NewURI(getter_AddRefs(finalURI), loadInfo.mFullURL, nullptr, nullptr);
       if (NS_SUCCEEDED(rv)) {
         mWorkerPrivate->SetBaseURI(finalURI);
       }
 
 #if defined(DEBUG) || !defined(RELEASE_OR_BETA)
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -17,17 +17,16 @@
 #include "nsIHttpHeaderVisitor.h"
 #include "nsINetworkInterceptController.h"
 #include "nsIMutableArray.h"
 #include "nsIScriptError.h"
 #include "nsISimpleEnumerator.h"
 #include "nsITimer.h"
 #include "nsIUploadChannel2.h"
 #include "nsPIDOMWindow.h"
-#include "nsScriptLoader.h"
 #include "nsServiceManagerUtils.h"
 #include "nsDebug.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIPermissionManager.h"
 
 #include "jsapi.h"
 
 #include "mozilla/BasePrincipal.h"
@@ -46,16 +45,17 @@
 #include "mozilla/dom/NotificationEvent.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 #include "mozilla/dom/Request.h"
 #include "mozilla/dom/RootedDictionary.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/Unused.h"
 #include "mozilla/EnumSet.h"
 
 #include "nsContentPolicyUtils.h"
 #include "nsContentSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsNetUtil.h"
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -6,29 +6,29 @@
 
 #include "ServiceWorkerScriptCache.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/CacheBinding.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/cache/Cache.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseWorkerProxy.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "nsICacheInfoChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIStreamLoader.h"
 #include "nsIThreadRetargetableRequest.h"
 
 #include "nsIPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
-#include "nsScriptLoader.h"
 #include "ServiceWorkerManager.h"
 #include "Workers.h"
 #include "nsStringStream.h"
 
 using mozilla::dom::cache::Cache;
 using mozilla::dom::cache::CacheStorage;
 
 BEGIN_WORKERS_NAMESPACE
@@ -823,19 +823,19 @@ CompareNetwork::OnStreamComplete(nsIStre
         NS_ConvertUTF8toUTF16(mimeType), mManager->URL() });
     mManager->NetworkFinished(NS_ERROR_DOM_SECURITY_ERR);
     return rv;
   }
 
   char16_t* buffer = nullptr;
   size_t len = 0;
 
-  rv = nsScriptLoader::ConvertToUTF16(httpChannel, aString, aLen,
-                                      NS_LITERAL_STRING("UTF-8"), nullptr,
-                                      buffer, len);
+  rv = ScriptLoader::ConvertToUTF16(httpChannel, aString, aLen,
+                                    NS_LITERAL_STRING("UTF-8"), nullptr,
+                                    buffer, len);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mManager->NetworkFinished(rv);
     return rv;
   }
 
   mBuffer.Adopt(buffer, len);
 
   mManager->NetworkFinished(NS_OK);
@@ -877,19 +877,19 @@ CompareCache::OnStreamComplete(nsIStream
   if (NS_WARN_IF(NS_FAILED(aStatus))) {
     mManager->CacheFinished(aStatus, false);
     return aStatus;
   }
 
   char16_t* buffer = nullptr;
   size_t len = 0;
 
-  nsresult rv = nsScriptLoader::ConvertToUTF16(nullptr, aString, aLen,
-                                               NS_LITERAL_STRING("UTF-8"),
-                                               nullptr, buffer, len);
+  nsresult rv = ScriptLoader::ConvertToUTF16(nullptr, aString, aLen,
+                                             NS_LITERAL_STRING("UTF-8"),
+                                             nullptr, buffer, len);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mManager->CacheFinished(rv, false);
     return rv;
   }
 
   mBuffer.Adopt(buffer, len);
 
   mManager->CacheFinished(NS_OK, true);
--- a/dom/worklet/Worklet.cpp
+++ b/dom/worklet/Worklet.cpp
@@ -10,19 +10,19 @@
 
 #include "mozilla/dom/WorkletBinding.h"
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 #include "mozilla/dom/RegisterWorkletBindings.h"
 #include "mozilla/dom/Response.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsIThreadRetargetableRequest.h"
 #include "nsNetUtil.h"
-#include "nsScriptLoader.h"
 #include "xpcprivate.h"
 
 namespace mozilla {
 namespace dom {
 
 // ---------------------------------------------------------------------------
 // WorkletFetchHandler
 
@@ -169,19 +169,19 @@ public:
     if (NS_FAILED(aStatus)) {
       RejectPromises(aStatus);
       return NS_OK;
     }
 
     char16_t* scriptTextBuf;
     size_t scriptTextLength;
     nsresult rv =
-      nsScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
-                                     NS_LITERAL_STRING("UTF-8"), nullptr,
-                                     scriptTextBuf, scriptTextLength);
+      ScriptLoader::ConvertToUTF16(nullptr, aString, aStringLen,
+                                   NS_LITERAL_STRING("UTF-8"), nullptr,
+                                   scriptTextBuf, scriptTextLength);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       RejectPromises(rv);
       return NS_OK;
     }
 
     // Moving the ownership of the buffer
     JS::SourceBufferHolder buffer(scriptTextBuf, scriptTextLength,
                                   JS::SourceBufferHolder::GiveOwnership);
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -30,17 +30,16 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsIContentViewer.h"
 #include "prtime.h"
 #include "mozilla/Logging.h"
 #include "prmem.h"
 #include "nsRect.h"
 #include "nsIWebNavigation.h"
 #include "nsIScriptElement.h"
-#include "nsScriptLoader.h"
 #include "nsStyleLinkElement.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsICookieService.h"
 #include "nsIPrompt.h"
 #include "nsIChannel.h"
 #include "nsIPrincipal.h"
 #include "nsXMLPrettyPrinter.h"
@@ -57,16 +56,17 @@
 #include "nsMimeTypes.h"
 #include "nsHtml5SVGLoadDispatcher.h"
 #include "nsTextNode.h"
 #include "mozilla/dom/CDATASection.h"
 #include "mozilla/dom/Comment.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/ProcessingInstruction.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 // XXX Open Issues:
 // 1) what's not allowed - We need to figure out which HTML tags
 //    (prefixed with a HTML namespace qualifier) are explicitly not
 //    allowed (if any).
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -20,20 +20,20 @@
 #include "nsError.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDocShell.h"
-#include "nsScriptLoader.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/ProcessingInstruction.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 using namespace mozilla::dom;
 
 class nsXMLFragmentContentSink : public nsXMLContentSink,
                                  public nsIFragmentContentSink
 {
 public:
   nsXMLFragmentContentSink();
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "txMozillaXMLOutput.h"
 
 #include "nsIDocument.h"
 #include "nsIDocShell.h"
-#include "nsScriptLoader.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIScriptElement.h"
 #include "nsCharsetSource.h"
 #include "nsIRefreshURI.h"
 #include "nsPIDOMWindow.h"
 #include "nsIContent.h"
 #include "nsContentCID.h"
@@ -26,16 +25,17 @@
 #include "txURIUtils.h"
 #include "nsIHTMLDocument.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDocumentTransformer.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsContentUtils.h"
 #include "txXMLUtils.h"
 #include "nsContentSink.h"
 #include "nsINode.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsError.h"
 #include "nsIFrame.h"
 #include <algorithm>
@@ -225,17 +225,17 @@ txMozillaXMLOutput::endDocument(nsresult
         return rv;
     }
 
     if (mCreatingNewDocument) {
         // This should really be handled by nsIDocument::EndLoad
         MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
                    nsIDocument::READYSTATE_LOADING, "Bad readyState");
         mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE);
-        nsScriptLoader* loader = mDocument->ScriptLoader();
+        ScriptLoader* loader = mDocument->ScriptLoader();
         if (loader) {
             loader->ParsingComplete(false);
         }
     }
 
     if (!mRefreshString.IsEmpty()) {
         nsPIDOMWindowOuter* win = mDocument->GetWindow();
         if (win) {
@@ -414,17 +414,17 @@ txMozillaXMLOutput::processingInstructio
 nsresult
 txMozillaXMLOutput::startDocument()
 {
     if (mNotifier) {
         mNotifier->OnTransformStart();
     }
 
     if (mCreatingNewDocument) {
-        nsScriptLoader* loader = mDocument->ScriptLoader();
+        ScriptLoader* loader = mDocument->ScriptLoader();
         if (loader) {
             loader->BeginDeferringScripts();
         }
     }
 
     return NS_OK;
 }
 
@@ -855,17 +855,17 @@ txMozillaXMLOutput::createResultDocument
         // Could use mOutputFormat.mVersion.get() when we support
         // versions > 1.0.
         static const char16_t kOneDotZero[] = { '1', '.', '0', '\0' };
         mDocument->SetXMLDeclaration(kOneDotZero, mOutputFormat.mEncoding.get(),
                                      standalone);
     }
 
     // Set up script loader of the result document.
-    nsScriptLoader *loader = mDocument->ScriptLoader();
+    ScriptLoader *loader = mDocument->ScriptLoader();
     if (mNotifier) {
         loader->AddObserver(mNotifier);
     }
     else {
         // Don't load scripts, we can't notify the caller when they're loaded.
         loader->SetEnabled(false);
     }
 
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -3339,20 +3339,20 @@ XULDocument::OnStreamComplete(nsIStreamL
         nsCOMPtr<nsIURI> uri = mCurrentScriptProto->mSrcURI;
 
         // XXX should also check nsIHttpChannel::requestSucceeded
 
         MOZ_ASSERT(!mOffThreadCompiling && (mOffThreadCompileStringLength == 0 &&
                                             !mOffThreadCompileStringBuf),
                    "XULDocument can't load multiple scripts at once");
 
-        rv = nsScriptLoader::ConvertToUTF16(channel, string, stringLen,
-                                            EmptyString(), this,
-                                            mOffThreadCompileStringBuf,
-                                            mOffThreadCompileStringLength);
+        rv = ScriptLoader::ConvertToUTF16(channel, string, stringLen,
+                                          EmptyString(), this,
+                                          mOffThreadCompileStringBuf,
+                                          mOffThreadCompileStringLength);
         if (NS_SUCCEEDED(rv)) {
             // Attempt to give ownership of the buffer to the JS engine.  If
             // we hit offthread compilation, however, we will have to take it
             // back below in order to keep the memory alive until compilation
             // completes.
             JS::SourceBufferHolder srcBuf(mOffThreadCompileStringBuf,
                                           mOffThreadCompileStringLength,
                                           JS::SourceBufferHolder::GiveOwnership);
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -16,23 +16,23 @@
 #include "mozilla/StyleSheet.h"
 #include "nsForwardReference.h"
 #include "nsIContent.h"
 #include "nsIDOMXULCommandDispatcher.h"
 #include "nsIDOMXULDocument.h"
 #include "nsCOMArray.h"
 #include "nsIURI.h"
 #include "nsIXULDocument.h"
-#include "nsScriptLoader.h"
 #include "nsIStreamListener.h"
 #include "nsIStreamLoader.h"
 #include "nsICSSLoaderObserver.h"
 #include "nsIXULStore.h"
 
 #include "mozilla/Attributes.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 #include "js/TracingAPI.h"
 #include "js/TypeDecls.h"
 
 class nsIRDFResource;
 class nsIRDFService;
 class nsPIWindowRoot;
 #if 0 // XXXbe save me, scc (need NSCAP_FORWARD_DECL(nsXULPrototypeScript))
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -874,17 +874,17 @@ XULContentSinkImpl::OpenScript(const cha
                   version = nsContentUtils::ParseJavascriptVersion(versionName);
               } else if (rv != NS_ERROR_INVALID_ARG) {
                   return rv;
               }
           } else {
               isJavaScript = false;
           }
       } else if (key.EqualsLiteral("language")) {
-          // Language is deprecated, and the impl in nsScriptLoader ignores the
+          // Language is deprecated, and the impl in ScriptLoader ignores the
           // various version strings anyway.  So we make no attempt to support
           // languages other than JS for language=
           nsAutoString lang(aAttributes[1]);
           if (nsContentUtils::IsJavaScriptLanguage(lang)) {
               isJavaScript = true;
               version = JSVERSION_DEFAULT;
           }
       }
--- a/js/xpconnect/loader/ChromeScriptLoader.cpp
+++ b/js/xpconnect/loader/ChromeScriptLoader.cpp
@@ -4,25 +4,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PrecompiledScript.h"
 
 #include "nsIURI.h"
 #include "nsIChannel.h"
 #include "nsNetUtil.h"
-#include "nsScriptLoader.h"
 #include "nsThreadUtils.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "js/Utility.h"
 
 #include "mozilla/dom/ChromeUtils.h"
 #include "mozilla/dom/Promise.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/HoldDropJSObjects.h"
 #include "mozilla/SystemGroup.h"
 #include "nsCycleCollectionParticipant.h"
 
 using namespace JS;
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -236,17 +236,17 @@ AsyncScriptCompiler::OnStreamComplete(ns
 
     JSContext* cx = jsapi.cx();
 
     if (NS_FAILED(aStatus)) {
         Reject(cx, "Unable to load script");
         return NS_OK;
     }
 
-    nsresult rv = nsScriptLoader::ConvertToUTF16(
+    nsresult rv = ScriptLoader::ConvertToUTF16(
         nullptr, aBuf, aLength, mCharset, nullptr, mScriptText, mScriptLength);
     if (NS_FAILED(rv)) {
         Reject(cx, "Unable to decode script");
         return NS_OK;
     }
 
     if (!StartCompile(cx)) {
         Reject(cx);
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -10,28 +10,28 @@
 
 #include "nsIURI.h"
 #include "nsIIOService.h"
 #include "nsIChannel.h"
 #include "nsIInputStream.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsIFileURL.h"
-#include "nsScriptLoader.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsThreadUtils.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "nsJSPrincipals.h"
 #include "xpcprivate.h" // For xpc::OptionsBase
 #include "jswrapper.h"
 
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/ToJSValue.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/HoldDropJSObjects.h"
 #include "mozilla/ScriptPreloader.h"
 #include "mozilla/scache/StartupCache.h"
 #include "mozilla/scache/StartupCacheUtils.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
 #include "nsStringGlue.h"
 #include "nsCycleCollectionParticipant.h"
@@ -143,18 +143,18 @@ PrepareScript(nsIURI* uri,
     options.setFileAndLine(uriStr, reuseGlobal ? 0 : 1)
            .setVersion(JSVERSION_LATEST)
            .setNoScriptRval(!wantReturnValue);
     if (!charset.IsVoid()) {
         char16_t* scriptBuf = nullptr;
         size_t scriptLength = 0;
 
         nsresult rv =
-            nsScriptLoader::ConvertToUTF16(nullptr, reinterpret_cast<const uint8_t*>(buf), len,
-                                           charset, nullptr, scriptBuf, scriptLength);
+            ScriptLoader::ConvertToUTF16(nullptr, reinterpret_cast<const uint8_t*>(buf), len,
+                                         charset, nullptr, scriptBuf, scriptLength);
 
         JS::SourceBufferHolder srcBuf(scriptBuf, scriptLength,
                                       JS::SourceBufferHolder::GiveOwnership);
 
         if (NS_FAILED(rv)) {
             ReportError(cx, LOAD_ERROR_BADCHARSET, uri);
             return false;
         }
@@ -853,19 +853,19 @@ ScriptPrecompiler::OnStreamComplete(nsII
     AutoSendObserverNotification notifier(this);
 
     // Just notify that we are done with this load.
     NS_ENSURE_SUCCESS(aStatus, NS_OK);
 
     // Convert data to char16_t* and prepare to call CompileOffThread.
     nsAutoString hintCharset;
     nsresult rv =
-        nsScriptLoader::ConvertToUTF16(mChannel, aString, aLength,
-                                       hintCharset, nullptr,
-                                       mScriptBuf, mScriptLength);
+        ScriptLoader::ConvertToUTF16(mChannel, aString, aLength,
+                                     hintCharset, nullptr,
+                                     mScriptBuf, mScriptLength);
 
     NS_ENSURE_SUCCESS(rv, NS_OK);
 
     // Our goal is to cache persistently the compiled script and to avoid quota
     // checks. Since the caching mechanism decide the persistence type based on
     // the principal, we create a new global with the app's principal.
     // We then enter its compartment to compile with its principal.
     AutoSafeJSContext cx;
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -32,23 +32,23 @@
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollector.h"
-#include "nsScriptLoader.h"
 #include "jsapi.h"
 #include "jsprf.h"
 #include "js/MemoryMetrics.h"
 #include "mozilla/dom/GeneratedAtomList.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ProcessHangMonitor.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Unused.h"
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -25,23 +25,23 @@
 #include "nsIDocShell.h"
 #include "nsIRunnable.h"
 #include "amIAddonManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollector.h"
-#include "nsScriptLoader.h"
 #include "jsapi.h"
 #include "jsprf.h"
 #include "js/MemoryMetrics.h"
 #include "mozilla/dom/GeneratedAtomList.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
@@ -2886,18 +2886,18 @@ ReadSourceFromFilename(JSContext* cx, co
         uint32_t bytesRead;
         rv = scriptStream->Read(reinterpret_cast<char*>(ptr), end - ptr, &bytesRead);
         if (NS_FAILED(rv))
             return rv;
         MOZ_ASSERT(bytesRead > 0, "stream promised more bytes before EOF");
         ptr += bytesRead;
     }
 
-    rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf.get(), rawLen, EmptyString(),
-                                        nullptr, *src, *len);
+    rv = ScriptLoader::ConvertToUTF16(scriptChannel, buf.get(), rawLen,
+                                      EmptyString(), nullptr, *src, *len);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!*src)
         return NS_ERROR_FAILURE;
 
     // Historically this method used JS_malloc() which updates the GC memory
     // accounting.  Since ConvertToUTF16() now uses js_malloc() instead we
     // update the accounting manually after the fact.
--- a/parser/html/nsHtml5DocumentBuilder.cpp
+++ b/parser/html/nsHtml5DocumentBuilder.cpp
@@ -3,19 +3,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHtml5DocumentBuilder.h"
 
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsStyleLinkElement.h"
-#include "nsScriptLoader.h"
 #include "nsIHTMLDocument.h"
 #include "nsNameSpaceManager.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder, nsContentSink,
                                    mOwnedElements)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder)
 NS_INTERFACE_MAP_END_INHERITING(nsContentSink)
 
 NS_IMPL_ADDREF_INHERITED(nsHtml5DocumentBuilder, nsContentSink)
--- a/parser/html/nsHtml5OplessBuilder.cpp
+++ b/parser/html/nsHtml5OplessBuilder.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHtml5OplessBuilder.h"
 
-#include "nsScriptLoader.h"
 #include "mozilla/css/Loader.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "nsIDocShell.h"
 #include "nsIHTMLDocument.h"
 
 nsHtml5OplessBuilder::nsHtml5OplessBuilder()
  : nsHtml5DocumentBuilder(true)
 {
 }
 
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -2,20 +2,20 @@
 /* vim: set sw=2 ts=2 et tw=79: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Likely.h"
 #include "mozilla/dom/nsCSPService.h"
+#include "mozilla/dom/ScriptLoader.h"
 
 #include "nsError.h"
 #include "nsHtml5TreeOpExecutor.h"
-#include "nsScriptLoader.h"
 #include "nsIContentViewer.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShell.h"
 #include "nsIDOMDocument.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIWebShellServices.h"
 #include "nsContentUtils.h"
@@ -948,18 +948,18 @@ nsHtml5TreeOpExecutor::PreloadScript(con
                                      const nsAString& aIntegrity,
                                      bool aScriptFromHead)
 {
   nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYet(aURL);
   if (!uri) {
     return;
   }
   mDocument->ScriptLoader()->PreloadURI(uri, aCharset, aType, aCrossOrigin,
-                                        aIntegrity, aScriptFromHead,
-                                        mSpeculationReferrerPolicy);
+                                           aIntegrity, aScriptFromHead,
+                                           mSpeculationReferrerPolicy);
 }
 
 void
 nsHtml5TreeOpExecutor::PreloadStyle(const nsAString& aURL,
                                     const nsAString& aCharset,
                                     const nsAString& aCrossOrigin,
                                     const nsAString& aIntegrity)
 {
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsString.h"
 #include "nsIComponentManager.h"
 #include "nsCOMPtr.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsXPIDLString.h"
-#include "nsScriptLoader.h"
 #include "nsEscape.h"
 #include "nsIParser.h"
 #include "nsIDTD.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsParserCIID.h"
 #include "nsContentUtils.h"
 #include "nsIContentSink.h"
@@ -31,16 +30,17 @@
 #include "nsHTMLParts.h"
 #include "nsContentCID.h"
 #include "nsIScriptableUnescapeHTML.h"
 #include "nsParserUtils.h"
 #include "nsAutoPtr.h"
 #include "nsTreeSanitizer.h"
 #include "nsHtml5Module.h"
 #include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "NullPrincipal.h"
 
 #define XHTML_DIV_TAG "div xmlns=\"http://www.w3.org/1999/xhtml\""
 
 using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(nsParserUtils,
                   nsIScriptableUnescapeHTML,
@@ -143,17 +143,17 @@ nsParserUtils::ParseFragment(const nsASt
   contextNode = do_QueryInterface(aContextElement);
   contextNode->GetOwnerDocument(getter_AddRefs(domDocument));
   document = do_QueryInterface(domDocument);
   NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
 
   nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
 
   // stop scripts
-  RefPtr<nsScriptLoader> loader;
+  RefPtr<ScriptLoader> loader;
   bool scripts_enabled = false;
   if (document) {
     loader = document->ScriptLoader();
     scripts_enabled = loader->GetEnabled();
   }
   if (scripts_enabled) {
     loader->SetEnabled(false);
   }
--- a/parser/htmlparser/nsParser.cpp
+++ b/parser/htmlparser/nsParser.cpp
@@ -23,28 +23,28 @@
 #include "nsCOMPtr.h"
 #include "nsExpatDriver.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIFragmentContentSink.h"
 #include "nsStreamUtils.h"
 #include "nsHTMLTokenizer.h"
-#include "nsScriptLoader.h"
 #include "nsDataHashtable.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsMimeTypes.h"
 #include "mozilla/CondVar.h"
 #include "mozilla/Mutex.h"
 #include "nsCharsetSource.h"
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "nsIHTMLContentSink.h"
 
 #include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/BinarySearch.h"
 
 using namespace mozilla;
 using mozilla::dom::EncodingUtils;
 
 #define NS_PARSER_FLAG_OBSERVERS_ENABLED      0x00000004
 #define NS_PARSER_FLAG_PENDING_CONTINUE_EVENT 0x00000008
 #define NS_PARSER_FLAG_FLUSH_TOKENS           0x00000020