зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1742437 - re-scope all generic module/script loader files under js/loader; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D138133
This commit is contained in:
Родитель
594ea8b9e7
Коммит
bb2c17bae7
|
@ -31,6 +31,7 @@
|
|||
#include "js/CompileOptions.h"
|
||||
#include "js/friend/PerformanceHint.h"
|
||||
#include "js/Id.h"
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "js/PropertyAndElement.h" // JS_DefineProperty, JS_GetProperty
|
||||
#include "js/PropertyDescriptor.h"
|
||||
#include "js/RealmOptions.h"
|
||||
|
@ -135,7 +136,6 @@
|
|||
#include "mozilla/dom/IntlUtils.h"
|
||||
#include "mozilla/dom/JSExecutionContext.h"
|
||||
#include "mozilla/dom/LSObject.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/LocalStorage.h"
|
||||
#include "mozilla/dom/LocalStorageCommon.h"
|
||||
#include "mozilla/dom/Location.h"
|
||||
|
@ -6126,7 +6126,7 @@ class WindowScriptTimeoutHandler final : public ScriptTimeoutHandler {
|
|||
virtual ~WindowScriptTimeoutHandler() = default;
|
||||
|
||||
// Initiating script for use when evaluating mExpr on the main thread.
|
||||
RefPtr<LoadedScript> mInitiatingScript;
|
||||
RefPtr<JS::loader::LoadedScript> mInitiatingScript;
|
||||
};
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(WindowScriptTimeoutHandler,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
// Microsoft's API Name hackery sucks
|
||||
#undef CreateEvent
|
||||
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
@ -25,7 +26,6 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/EventTargetBinding.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/PopupBlocker.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
@ -1234,12 +1234,13 @@ nsresult EventListenerManager::CompileEventHandlerInternal(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
|
||||
CORS_NONE, aElement->OwnerDoc()->GetReferrerPolicy(),
|
||||
aElement->OwnerDoc()->NodePrincipal());
|
||||
RefPtr<JS::loader::ScriptFetchOptions> fetchOptions =
|
||||
new JS::loader::ScriptFetchOptions(
|
||||
CORS_NONE, aElement->OwnerDoc()->GetReferrerPolicy(),
|
||||
aElement->OwnerDoc()->NodePrincipal());
|
||||
|
||||
RefPtr<EventScript> eventScript =
|
||||
new EventScript(fetchOptions, uri, aElement);
|
||||
RefPtr<JS::loader::EventScript> eventScript =
|
||||
new JS::loader::EventScript(fetchOptions, uri, aElement);
|
||||
|
||||
JS::CompileOptions options(cx);
|
||||
// Use line 0 to make the function body starts from line 1.
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ScriptLoader.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "ScriptTrace.h"
|
||||
#include "LoadedScript.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "ModuleLoaderBase.h"
|
||||
#include "ModuleLoadRequest.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/ContextOptions.h" // JS::ContextOptionsRef
|
||||
|
@ -20,6 +16,10 @@
|
|||
#include "js/PropertyAndElement.h" // JS_DefineProperty
|
||||
#include "js/Realm.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "js/loader/ModuleLoaderBase.h"
|
||||
#include "js/loader/ModuleLoadRequest.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
using JS::SourceText;
|
||||
using namespace JS::loader;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#ifndef mozilla_dom_ModuleLoader_h
|
||||
#define mozilla_dom_ModuleLoader_h
|
||||
|
||||
#include "ModuleLoaderBase.h"
|
||||
#include "mozilla/dom/ScriptLoadContext.h"
|
||||
#include "mozilla/dom/ScriptLoadRequest.h"
|
||||
#include "js/loader/ModuleLoaderBase.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "ScriptLoader.h"
|
||||
|
||||
class nsIURI;
|
||||
|
@ -18,19 +18,24 @@ namespace JS {
|
|||
|
||||
class CompileOptions;
|
||||
|
||||
namespace loader {
|
||||
|
||||
class ModuleLoadRequest;
|
||||
|
||||
} // namespace loader
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ModuleLoadRequest;
|
||||
class ScriptLoader;
|
||||
class SRIMetadata;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// DOM Module loader implementation
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
class ModuleLoader final : public ModuleLoaderBase {
|
||||
class ModuleLoader final : public JS::loader::ModuleLoaderBase {
|
||||
private:
|
||||
virtual ~ModuleLoader();
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* 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 "ScriptLoadRequest.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include "mozilla/dom/Document.h"
|
||||
|
@ -15,15 +14,13 @@
|
|||
|
||||
#include "js/OffThreadScriptCompilation.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
|
||||
#include "ModuleLoadRequest.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsICacheInfoChannel.h"
|
||||
#include "nsIClassOfService.h"
|
||||
#include "nsISupportsPriority.h"
|
||||
#include "ScriptSettings.h"
|
||||
|
||||
using JS::SourceText;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -134,7 +131,7 @@ void ScriptLoadContext::MaybeCancelOffThreadScript() {
|
|||
mOffThreadToken = nullptr;
|
||||
}
|
||||
|
||||
void ScriptLoadContext::SetRequest(ScriptLoadRequest* aRequest) {
|
||||
void ScriptLoadContext::SetRequest(JS::loader::ScriptLoadRequest* aRequest) {
|
||||
MOZ_ASSERT(!mRequest);
|
||||
mRequest = aRequest;
|
||||
}
|
||||
|
@ -172,7 +169,8 @@ void ScriptLoadContext::PrioritizeAsPreload() {
|
|||
|
||||
bool ScriptLoadContext::IsPreload() const {
|
||||
if (mRequest->IsModuleRequest() && !mRequest->IsTopLevel()) {
|
||||
ModuleLoadRequest* root = mRequest->AsModuleRequest()->GetRootModule();
|
||||
JS::loader::ModuleLoadRequest* root =
|
||||
mRequest->AsModuleRequest()->GetRootModule();
|
||||
return root->GetLoadContext()->IsPreload();
|
||||
}
|
||||
|
||||
|
@ -182,7 +180,8 @@ bool ScriptLoadContext::IsPreload() const {
|
|||
|
||||
nsIGlobalObject* ScriptLoadContext::GetWebExtGlobal() const {
|
||||
if (mRequest->IsModuleRequest() && !mRequest->IsTopLevel()) {
|
||||
ModuleLoadRequest* root = mRequest->AsModuleRequest()->GetRootModule();
|
||||
JS::loader::ModuleLoadRequest* root =
|
||||
mRequest->AsModuleRequest()->GetRootModule();
|
||||
return root->GetLoadContext()->GetWebExtGlobal();
|
||||
}
|
||||
|
||||
|
@ -196,7 +195,8 @@ bool ScriptLoadContext::CompileStarted() const {
|
|||
|
||||
nsIScriptElement* ScriptLoadContext::GetScriptElement() const {
|
||||
if (mRequest->IsModuleRequest() && !mRequest->IsTopLevel()) {
|
||||
ModuleLoadRequest* root = mRequest->AsModuleRequest()->GetRootModule();
|
||||
JS::loader::ModuleLoadRequest* root =
|
||||
mRequest->AsModuleRequest()->GetRootModule();
|
||||
return root->GetLoadContext()->GetScriptElement();
|
||||
}
|
||||
nsCOMPtr<nsIScriptElement> scriptElement = do_QueryInterface(mElement);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "js/RootingAPI.h"
|
||||
#include "js/SourceText.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/loader/ScriptKind.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
@ -27,19 +29,21 @@
|
|||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "ScriptKind.h"
|
||||
#include "js/loader/ScriptKind.h"
|
||||
|
||||
class nsICacheInfoChannel;
|
||||
|
||||
namespace JS {
|
||||
class OffThreadToken;
|
||||
namespace loader {
|
||||
class ScriptLoadRequest;
|
||||
}
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Element;
|
||||
class ScriptLoadRequest;
|
||||
|
||||
/*
|
||||
* DOM specific ScriptLoadContext.
|
||||
|
@ -87,7 +91,7 @@ class ScriptLoadContext : public PreloaderBase {
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ScriptLoadContext)
|
||||
|
||||
void SetRequest(ScriptLoadRequest* aRequest);
|
||||
void SetRequest(JS::loader::ScriptLoadRequest* aRequest);
|
||||
|
||||
// PreloaderBase
|
||||
static void PrioritizeAsPreload(nsIChannel* aChannel);
|
||||
|
@ -198,7 +202,7 @@ class ScriptLoadContext : public PreloaderBase {
|
|||
*/
|
||||
nsCOMPtr<nsIGlobalObject> mWebExtGlobal;
|
||||
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
RefPtr<JS::loader::ScriptLoadRequest> mRequest;
|
||||
|
||||
// Non-null if there is a document that this request is blocking from loading.
|
||||
RefPtr<Document> mLoadBlockedDocument;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "ScriptLoader.h"
|
||||
#include "ScriptTrace.h"
|
||||
#include "js/Transcoding.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
@ -24,7 +25,6 @@
|
|||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/SRICheck.h"
|
||||
#include "mozilla/dom/ScriptDecoding.h"
|
||||
#include "mozilla/dom/ScriptLoadRequest.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
|
@ -50,7 +50,7 @@ namespace dom {
|
|||
MOZ_LOG_TEST(ScriptLoader::gScriptLoaderLog, mozilla::LogLevel::Debug)
|
||||
|
||||
ScriptLoadHandler::ScriptLoadHandler(
|
||||
ScriptLoader* aScriptLoader, ScriptLoadRequest* aRequest,
|
||||
ScriptLoader* aScriptLoader, JS::loader::ScriptLoadRequest* aRequest,
|
||||
UniquePtr<SRICheckDataVerifier>&& aSRIDataVerifier)
|
||||
: mScriptLoader(aScriptLoader),
|
||||
mRequest(aRequest),
|
||||
|
@ -76,7 +76,7 @@ nsresult ScriptLoadHandler::DecodeRawDataHelper(const uint8_t* aData,
|
|||
}
|
||||
|
||||
// Reference to the script source buffer which we will update.
|
||||
ScriptLoadRequest::ScriptTextBuffer<Unit>& scriptText =
|
||||
JS::loader::ScriptLoadRequest::ScriptTextBuffer<Unit>& scriptText =
|
||||
mRequest->ScriptText<Unit>();
|
||||
|
||||
uint32_t haveRead = scriptText.length();
|
||||
|
|
|
@ -17,20 +17,23 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace JS::loader {
|
||||
class ScriptLoadRequest;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class Decoder;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class ScriptLoadRequest;
|
||||
class ScriptLoader;
|
||||
class SRICheckDataVerifier;
|
||||
|
||||
class ScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver {
|
||||
public:
|
||||
explicit ScriptLoadHandler(
|
||||
ScriptLoader* aScriptLoader, ScriptLoadRequest* aRequest,
|
||||
ScriptLoader* aScriptLoader, JS::loader::ScriptLoadRequest* aRequest,
|
||||
UniquePtr<SRICheckDataVerifier>&& aSRIDataVerifier);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -96,7 +99,7 @@ class ScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver {
|
|||
RefPtr<ScriptLoader> mScriptLoader;
|
||||
|
||||
// The ScriptLoadRequest for this load. Decoded data are accumulated on it.
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
RefPtr<JS::loader::ScriptLoadRequest> mRequest;
|
||||
|
||||
// SRI data verifier.
|
||||
UniquePtr<SRICheckDataVerifier> mSRIDataVerifier;
|
||||
|
|
|
@ -6,11 +6,8 @@
|
|||
|
||||
#include "ScriptLoader.h"
|
||||
#include "ScriptLoadHandler.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "ScriptTrace.h"
|
||||
#include "LoadedScript.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "ModuleLoadRequest.h"
|
||||
|
||||
#include "prsystem.h"
|
||||
#include "jsapi.h"
|
||||
|
@ -19,6 +16,9 @@
|
|||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/ContextOptions.h" // JS::ContextOptionsRef
|
||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "js/loader/ModuleLoadRequest.h"
|
||||
#include "js/MemoryFunctions.h"
|
||||
#include "js/OffThreadScriptCompilation.h"
|
||||
#include "js/PropertyAndElement.h" // JS_DefineProperty
|
||||
|
@ -92,6 +92,7 @@
|
|||
#include "nsIAsyncOutputStream.h"
|
||||
|
||||
using JS::SourceText;
|
||||
using namespace JS::loader;
|
||||
|
||||
using mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT;
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#define mozilla_dom_ScriptLoader_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "js/loader/ScriptKind.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsIScriptElement.h"
|
||||
|
@ -20,13 +23,10 @@
|
|||
#include "nsIScriptLoaderObserver.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/JSExecutionContext.h" // JSExecutionContext
|
||||
#include "mozilla/dom/ScriptLoadRequest.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "mozilla/MaybeOneOf.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "ScriptKind.h"
|
||||
|
||||
class nsCycleCollectionTraversalCallback;
|
||||
class nsIChannel;
|
||||
|
@ -44,6 +44,16 @@ class CompileOptions;
|
|||
template <typename UnitT>
|
||||
class SourceText;
|
||||
|
||||
namespace loader {
|
||||
|
||||
class LoadedScript;
|
||||
class ScriptLoaderInterface;
|
||||
class ModuleLoadRequest;
|
||||
class ModuleScript;
|
||||
class ScriptLoadRequest;
|
||||
class ScriptLoadRequestList;
|
||||
|
||||
} // namespace loader
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -56,18 +66,11 @@ namespace dom {
|
|||
class AutoJSAPI;
|
||||
class DocGroup;
|
||||
class Document;
|
||||
class LoadedScript;
|
||||
class ScriptLoaderInterface;
|
||||
class ModuleLoader;
|
||||
class ModuleLoadRequest;
|
||||
class ModuleScript;
|
||||
class SRICheckDataVerifier;
|
||||
class SRIMetadata;
|
||||
class ScriptLoadHandler;
|
||||
class ScriptLoadRequest;
|
||||
class ScriptLoadRequestList;
|
||||
class ScriptLoadContext;
|
||||
|
||||
class ScriptLoader;
|
||||
class ScriptRequestProcessor;
|
||||
|
||||
|
@ -96,7 +99,7 @@ class AsyncCompileShutdownObserver final : public nsIObserver {
|
|||
// Script loader implementation
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
class ScriptLoader final : public ScriptLoaderInterface {
|
||||
class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
class MOZ_STACK_CLASS AutoCurrentScriptUpdater {
|
||||
public:
|
||||
AutoCurrentScriptUpdater(ScriptLoader* aScriptLoader,
|
||||
|
@ -117,7 +120,7 @@ class ScriptLoader final : public ScriptLoaderInterface {
|
|||
ScriptLoader* mScriptLoader;
|
||||
};
|
||||
|
||||
friend class ModuleLoadRequest;
|
||||
friend class JS::loader::ModuleLoadRequest;
|
||||
friend class ScriptRequestProcessor;
|
||||
friend class ModuleLoader;
|
||||
friend class ScriptLoadHandler;
|
||||
|
@ -409,7 +412,7 @@ class ScriptLoader final : public ScriptLoaderInterface {
|
|||
* Get the currently active script. This is used as the initiating script when
|
||||
* executing timeout handler scripts.
|
||||
*/
|
||||
static LoadedScript* GetActiveScript(JSContext* aCx);
|
||||
static JS::loader::LoadedScript* GetActiveScript(JSContext* aCx);
|
||||
|
||||
Document* GetDocument() const { return mDocument; }
|
||||
|
||||
|
@ -439,9 +442,9 @@ class ScriptLoader final : public ScriptLoaderInterface {
|
|||
|
||||
bool ProcessInlineScript(nsIScriptElement* aElement, ScriptKind aScriptKind);
|
||||
|
||||
ScriptLoadRequest* LookupPreloadRequest(nsIScriptElement* aElement,
|
||||
ScriptKind aScriptKind,
|
||||
const SRIMetadata& aSRIMetadata);
|
||||
JS::loader::ScriptLoadRequest* LookupPreloadRequest(
|
||||
nsIScriptElement* aElement, ScriptKind aScriptKind,
|
||||
const SRIMetadata& aSRIMetadata);
|
||||
|
||||
void GetSRIMetadata(const nsAString& aIntegrityAttr,
|
||||
SRIMetadata* aMetadataOut);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
#include <utility>
|
||||
#include "LoadedScript.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
|
@ -21,6 +20,8 @@
|
|||
#include "js/Warnings.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "js/friend/ErrorMessages.h"
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "js/loader/ScriptLoadRequest.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
@ -33,7 +34,6 @@
|
|||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptLoadRequest.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
|
@ -55,7 +55,8 @@ JSObject* SourceElementCallback(JSContext* aCx, JS::HandleValue aPrivateValue) {
|
|||
// NOTE: The result of this is only used by DevTools for matching sources, so
|
||||
// it is safe to silently ignore any errors and return nullptr for them.
|
||||
|
||||
LoadedScript* script = static_cast<LoadedScript*>(aPrivateValue.toPrivate());
|
||||
JS::loader::LoadedScript* script =
|
||||
static_cast<JS::loader::LoadedScript*>(aPrivateValue.toPrivate());
|
||||
|
||||
JS::Rooted<JS::Value> elementValue(aCx);
|
||||
{
|
||||
|
|
|
@ -10,34 +10,33 @@
|
|||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace script {
|
||||
|
||||
// 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 \
|
||||
nsresult rv = NS_OK; \
|
||||
rv = \
|
||||
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
NS_ENSURE_SUCCESS(rv, rv); \
|
||||
#define TRACE_FOR_TEST(elem, str) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsresult rv = NS_OK; \
|
||||
rv = mozilla::dom::script::TestingDispatchEvent( \
|
||||
elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
NS_ENSURE_SUCCESS(rv, rv); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define TRACE_FOR_TEST_BOOL(elem, str) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsresult rv = NS_OK; \
|
||||
rv = \
|
||||
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
NS_ENSURE_SUCCESS(rv, false); \
|
||||
#define TRACE_FOR_TEST_BOOL(elem, str) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsresult rv = NS_OK; \
|
||||
rv = mozilla::dom::script::TestingDispatchEvent( \
|
||||
elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
NS_ENSURE_SUCCESS(rv, false); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define TRACE_FOR_TEST_NONE(elem, str) \
|
||||
PR_BEGIN_MACRO \
|
||||
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
#define TRACE_FOR_TEST_NONE(elem, str) \
|
||||
PR_BEGIN_MACRO \
|
||||
mozilla::dom::script::TestingDispatchEvent( \
|
||||
elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
|
||||
PR_END_MACRO
|
||||
|
||||
namespace mozilla::dom::script {
|
||||
|
||||
static nsresult TestingDispatchEvent(nsIScriptElement* aScriptElement,
|
||||
const nsAString& aEventType) {
|
||||
if (!StaticPrefs::dom_expose_test_interfaces()) {
|
||||
|
@ -53,8 +52,6 @@ static nsresult TestingDispatchEvent(nsIScriptElement* aScriptElement,
|
|||
target, aEventType, CanBubble::eYes, ChromeOnlyDispatch::eNo);
|
||||
return dispatcher->PostDOMEvent();
|
||||
}
|
||||
} // namespace script
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom::script
|
||||
|
||||
#endif // mozilla_dom_ScriptTrace_h
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "js/PropertyAndElement.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Value.h"
|
||||
#include "js/loader/ModuleMapKey.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -20,7 +21,6 @@
|
|||
#include "mozilla/dom/BindingCallContext.h"
|
||||
#include "mozilla/dom/ByteStreamHelpers.h"
|
||||
#include "mozilla/dom/BodyStream.h"
|
||||
#include "mozilla/dom/ModuleMapKey.h"
|
||||
#include "mozilla/dom/QueueWithSizes.h"
|
||||
#include "mozilla/dom/QueuingStrategyBinding.h"
|
||||
#include "mozilla/dom/ReadIntoRequest.h"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef mozilla_dom_UnderlyingSinkCallbackHelpers_h
|
||||
#define mozilla_dom_UnderlyingSinkCallbackHelpers_h
|
||||
|
||||
#include "js/loader/ModuleMapKey.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/ModuleMapKey.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/UnderlyingSinkBinding.h"
|
||||
#include "nsISupports.h"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef mozilla_dom_UnderlyingSourceCallbackHelpers_h
|
||||
#define mozilla_dom_UnderlyingSourceCallbackHelpers_h
|
||||
|
||||
#include "js/loader/ModuleMapKey.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/ModuleMapKey.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ReadableStreamDefaultController.h"
|
||||
#include "mozilla/dom/UnderlyingSourceBinding.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "js/PropertyAndElement.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Value.h"
|
||||
#include "js/loader/ModuleMapKey.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/AbortSignal.h"
|
||||
#include "mozilla/dom/BindingCallContext.h"
|
||||
#include "mozilla/dom/ModuleMapKey.h"
|
||||
#include "mozilla/dom/QueueWithSizes.h"
|
||||
#include "mozilla/dom/QueuingStrategyBinding.h"
|
||||
#include "mozilla/dom/ReadRequest.h"
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#include "jsfriendapi.h"
|
||||
#include "js/Modules.h" // JS::{Get,Set}ModulePrivate
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace JS::loader {
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// LoadedScript
|
||||
|
@ -40,7 +39,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(LoadedScript)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(LoadedScript)
|
||||
|
||||
LoadedScript::LoadedScript(ScriptKind aKind, ScriptFetchOptions* aFetchOptions,
|
||||
nsIURI* aBaseURL, Element* aElement)
|
||||
nsIURI* aBaseURL, mozilla::dom::Element* aElement)
|
||||
: mKind(aKind),
|
||||
mFetchOptions(aFetchOptions),
|
||||
mBaseURL(aBaseURL),
|
||||
|
@ -49,7 +48,7 @@ LoadedScript::LoadedScript(ScriptKind aKind, ScriptFetchOptions* aFetchOptions,
|
|||
MOZ_ASSERT(mBaseURL);
|
||||
}
|
||||
|
||||
LoadedScript::~LoadedScript() { DropJSObjects(this); }
|
||||
LoadedScript::~LoadedScript() { mozilla::DropJSObjects(this); }
|
||||
|
||||
void LoadedScript::AssociateWithScript(JSScript* aScript) {
|
||||
// Set a JSScript's private value to point to this object. The JS engine will
|
||||
|
@ -95,7 +94,7 @@ void HostReleaseTopLevelScript(const JS::Value& aPrivate) {
|
|||
//////////////////////////////////////////////////////////////
|
||||
|
||||
EventScript::EventScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
||||
Element* aElement)
|
||||
mozilla::dom::Element* aElement)
|
||||
: LoadedScript(ScriptKind::eEvent, aFetchOptions, aBaseURL, aElement) {}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
@ -103,7 +102,7 @@ EventScript::EventScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
|||
//////////////////////////////////////////////////////////////
|
||||
|
||||
ClassicScript::ClassicScript(ScriptFetchOptions* aFetchOptions,
|
||||
nsIURI* aBaseURL, Element* aElement)
|
||||
nsIURI* aBaseURL, mozilla::dom::Element* aElement)
|
||||
: LoadedScript(ScriptKind::eClassic, aFetchOptions, aBaseURL, aElement) {}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
@ -134,7 +133,7 @@ NS_IMPL_ADDREF_INHERITED(ModuleScript, LoadedScript)
|
|||
NS_IMPL_RELEASE_INHERITED(ModuleScript, LoadedScript)
|
||||
|
||||
ModuleScript::ModuleScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
||||
Element* aElement)
|
||||
mozilla::dom::Element* aElement)
|
||||
: LoadedScript(ScriptKind::eModule, aFetchOptions, aBaseURL, aElement),
|
||||
mDebuggerDataInitialized(false) {
|
||||
MOZ_ASSERT(!ModuleRecord());
|
||||
|
@ -172,7 +171,7 @@ void ModuleScript::SetModuleRecord(JS::Handle<JSObject*> aModuleRecord) {
|
|||
MOZ_ASSERT(JS::GetModulePrivate(mModuleRecord).isUndefined());
|
||||
JS::SetModulePrivate(mModuleRecord, JS::PrivateValue(this));
|
||||
|
||||
HoldJSObjects(this);
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
void ModuleScript::SetParseError(const JS::Value& aError) {
|
||||
|
@ -182,7 +181,7 @@ void ModuleScript::SetParseError(const JS::Value& aError) {
|
|||
|
||||
UnlinkModuleRecord();
|
||||
mParseError = aError;
|
||||
HoldJSObjects(this);
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
void ModuleScript::SetErrorToRethrow(const JS::Value& aError) {
|
||||
|
@ -202,5 +201,4 @@ void ModuleScript::SetDebuggerDataInitialized() {
|
|||
mDebuggerDataInitialized = true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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_LoadedScript_h
|
||||
#define mozilla_dom_LoadedScript_h
|
||||
#ifndef js_loader_LoadedScript_h
|
||||
#define js_loader_LoadedScript_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
@ -14,11 +14,7 @@
|
|||
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Element;
|
||||
class ScriptLoader;
|
||||
namespace JS::loader {
|
||||
|
||||
void HostAddRefTopLevelScript(const JS::Value& aPrivate);
|
||||
void HostReleaseTopLevelScript(const JS::Value& aPrivate);
|
||||
|
@ -31,11 +27,11 @@ class LoadedScript : public nsISupports {
|
|||
ScriptKind mKind;
|
||||
RefPtr<ScriptFetchOptions> mFetchOptions;
|
||||
nsCOMPtr<nsIURI> mBaseURL;
|
||||
nsCOMPtr<Element> mElement;
|
||||
nsCOMPtr<mozilla::dom::Element> mElement;
|
||||
|
||||
protected:
|
||||
LoadedScript(ScriptKind aKind, ScriptFetchOptions* aFetchOptions,
|
||||
nsIURI* aBaseURL, Element* aElement);
|
||||
nsIURI* aBaseURL, mozilla::dom::Element* aElement);
|
||||
|
||||
virtual ~LoadedScript();
|
||||
|
||||
|
@ -54,7 +50,7 @@ class LoadedScript : public nsISupports {
|
|||
ScriptFetchOptions* GetFetchOptions() const { return mFetchOptions; }
|
||||
|
||||
// Used by the Debugger to get the associated Script Element
|
||||
Element* GetScriptElement() const { return mElement; }
|
||||
mozilla::dom::Element* GetScriptElement() const { return mElement; }
|
||||
|
||||
nsIURI* BaseURL() const { return mBaseURL; }
|
||||
|
||||
|
@ -66,7 +62,7 @@ class ClassicScript final : public LoadedScript {
|
|||
|
||||
public:
|
||||
ClassicScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
||||
Element* aElement);
|
||||
mozilla::dom::Element* aElement);
|
||||
};
|
||||
|
||||
class EventScript final : public LoadedScript {
|
||||
|
@ -74,7 +70,7 @@ class EventScript final : public LoadedScript {
|
|||
|
||||
public:
|
||||
EventScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
||||
Element* aElement);
|
||||
mozilla::dom::Element* aElement);
|
||||
};
|
||||
|
||||
// A single module script. May be used to satisfy multiple load requests.
|
||||
|
@ -93,7 +89,7 @@ class ModuleScript final : public LoadedScript {
|
|||
LoadedScript)
|
||||
|
||||
ModuleScript(ScriptFetchOptions* aFetchOptions, nsIURI* aBaseURL,
|
||||
Element* aElement);
|
||||
mozilla::dom::Element* aElement);
|
||||
|
||||
void SetModuleRecord(JS::Handle<JSObject*> aModuleRecord);
|
||||
void SetParseError(const JS::Value& aError);
|
||||
|
@ -123,7 +119,6 @@ ModuleScript* LoadedScript::AsModuleScript() {
|
|||
return static_cast<ModuleScript*>(this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
||||
#endif // mozilla_dom_LoadedScript_h
|
||||
#endif // js_loader_LoadedScript_h
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#include "LoadedScript.h"
|
||||
#include "ModuleLoaderBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace JS::loader {
|
||||
|
||||
#undef LOG
|
||||
#define LOG(args) \
|
||||
|
@ -55,10 +54,10 @@ VisitedURLSet* ModuleLoadRequest::NewVisitedSetForTopLevelImport(nsIURI* aURI) {
|
|||
|
||||
ModuleLoadRequest::ModuleLoadRequest(
|
||||
nsIURI* aURI, ScriptFetchOptions* aFetchOptions,
|
||||
const SRIMetadata& aIntegrity, nsIURI* aReferrer,
|
||||
ScriptLoadContext* aContext, bool aIsTopLevel, bool aIsDynamicImport,
|
||||
ModuleLoaderBase* aLoader, VisitedURLSet* aVisitedSet,
|
||||
ModuleLoadRequest* aRootModule)
|
||||
const mozilla::dom::SRIMetadata& aIntegrity, nsIURI* aReferrer,
|
||||
mozilla::dom::ScriptLoadContext* aContext, bool aIsTopLevel,
|
||||
bool aIsDynamicImport, ModuleLoaderBase* aLoader,
|
||||
VisitedURLSet* aVisitedSet, ModuleLoadRequest* aRootModule)
|
||||
: ScriptLoadRequest(ScriptKind::eModule, aURI, aFetchOptions, aIntegrity,
|
||||
aReferrer, aContext),
|
||||
mIsTopLevel(aIsTopLevel),
|
||||
|
@ -192,5 +191,4 @@ void ModuleLoadRequest::ClearDynamicImport() {
|
|||
mDynamicPromise = nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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_ModuleLoadRequest_h
|
||||
#define mozilla_dom_ModuleLoadRequest_h
|
||||
#ifndef js_loader_ModuleLoadRequest_h
|
||||
#define js_loader_ModuleLoadRequest_h
|
||||
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
|
@ -14,8 +14,7 @@
|
|||
#include "nsURIHashKey.h"
|
||||
#include "nsTHashtable.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace JS::loader {
|
||||
|
||||
class ModuleScript;
|
||||
class ModuleLoaderBase;
|
||||
|
@ -43,10 +42,15 @@ class ModuleLoadRequest final : public ScriptLoadRequest {
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ModuleLoadRequest,
|
||||
ScriptLoadRequest)
|
||||
using SRIMetadata = mozilla::dom::SRIMetadata;
|
||||
|
||||
template <typename T>
|
||||
using MozPromiseHolder = mozilla::MozPromiseHolder<T>;
|
||||
using GenericPromise = mozilla::GenericPromise;
|
||||
|
||||
ModuleLoadRequest(nsIURI* aURI, ScriptFetchOptions* aFetchOptions,
|
||||
const SRIMetadata& aIntegrity, nsIURI* aReferrer,
|
||||
ScriptLoadContext* aContext, bool aIsTopLevel,
|
||||
mozilla::dom::ScriptLoadContext* aContext, bool aIsTopLevel,
|
||||
bool aIsDynamicImport, ModuleLoaderBase* aLoader,
|
||||
VisitedURLSet* aVisitedSet, ModuleLoadRequest* aRootModule);
|
||||
|
||||
|
@ -114,7 +118,6 @@ class ModuleLoadRequest final : public ScriptLoadRequest {
|
|||
JS::Heap<JSObject*> mDynamicPromise;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
||||
#endif // mozilla_dom_ModuleLoadRequest_h
|
||||
#endif // js_loader_ModuleLoadRequest_h
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "GeckoProfiler.h"
|
||||
#include "LoadedScript.h"
|
||||
#include "ModuleLoadRequest.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "mozilla/dom/ScriptTrace.h"
|
||||
#include "ModuleLoadRequest.h"
|
||||
|
||||
#include "js/Array.h" // JS::GetArrayLength
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
|
@ -26,10 +26,11 @@
|
|||
|
||||
using JS::SourceText;
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace JS::loader {
|
||||
|
||||
LazyLogModule ModuleLoaderBase::gCspPRLog("CSP");
|
||||
LazyLogModule ModuleLoaderBase::gModuleLoaderBaseLog("ModuleLoaderBase");
|
||||
mozilla::LazyLogModule ModuleLoaderBase::gCspPRLog("CSP");
|
||||
mozilla::LazyLogModule ModuleLoaderBase::gModuleLoaderBaseLog(
|
||||
"ModuleLoaderBase");
|
||||
|
||||
#undef LOG
|
||||
#define LOG(args) \
|
||||
|
@ -49,7 +50,8 @@ inline void ImplCycleCollectionUnlink(
|
|||
for (auto iter = aField.Iter(); !iter.Done(); iter.Next()) {
|
||||
ImplCycleCollectionUnlink(iter.Key());
|
||||
|
||||
RefPtr<GenericNonExclusivePromise::Private> promise = iter.UserData();
|
||||
RefPtr<mozilla::GenericNonExclusivePromise::Private> promise =
|
||||
iter.UserData();
|
||||
if (promise) {
|
||||
promise->Reject(NS_ERROR_ABORT, __func__);
|
||||
}
|
||||
|
@ -119,7 +121,7 @@ void ModuleLoaderBase::SetModuleFetchStarted(ModuleLoadRequest* aRequest) {
|
|||
aRequest->mLoadContext->GetWebExtGlobal()));
|
||||
ModuleMapKey key(aRequest->mURI, aRequest->mLoadContext->GetWebExtGlobal());
|
||||
mFetchingModules.InsertOrUpdate(
|
||||
key, RefPtr<GenericNonExclusivePromise::Private>{});
|
||||
key, RefPtr<mozilla::GenericNonExclusivePromise::Private>{});
|
||||
}
|
||||
|
||||
void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
|
||||
|
@ -136,7 +138,7 @@ void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
|
|||
aRequest, aRequest->mModuleScript.get(), unsigned(aResult)));
|
||||
|
||||
ModuleMapKey key(aRequest->mURI, aRequest->mLoadContext->GetWebExtGlobal());
|
||||
RefPtr<GenericNonExclusivePromise::Private> promise;
|
||||
RefPtr<mozilla::GenericNonExclusivePromise::Private> promise;
|
||||
if (!mFetchingModules.Remove(key, getter_AddRefs(promise))) {
|
||||
LOG(
|
||||
("ScriptLoadRequest (%p): Key not found in mFetchingModules, "
|
||||
|
@ -161,14 +163,14 @@ void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> ModuleLoaderBase::WaitForModuleFetch(
|
||||
nsIURI* aURL, nsIGlobalObject* aGlobal) {
|
||||
RefPtr<mozilla::GenericNonExclusivePromise>
|
||||
ModuleLoaderBase::WaitForModuleFetch(nsIURI* aURL, nsIGlobalObject* aGlobal) {
|
||||
MOZ_ASSERT(ModuleMapContainsURL(aURL, aGlobal));
|
||||
|
||||
ModuleMapKey key(aURL, aGlobal);
|
||||
if (auto entry = mFetchingModules.Lookup(key)) {
|
||||
if (!entry.Data()) {
|
||||
entry.Data() = new GenericNonExclusivePromise::Private(__func__);
|
||||
entry.Data() = new mozilla::GenericNonExclusivePromise::Private(__func__);
|
||||
}
|
||||
return entry.Data();
|
||||
}
|
||||
|
@ -176,11 +178,11 @@ RefPtr<GenericNonExclusivePromise> ModuleLoaderBase::WaitForModuleFetch(
|
|||
RefPtr<ModuleScript> ms;
|
||||
MOZ_ALWAYS_TRUE(mFetchedModules.Get(key, getter_AddRefs(ms)));
|
||||
if (!ms) {
|
||||
return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_FAILURE,
|
||||
__func__);
|
||||
return mozilla::GenericNonExclusivePromise::CreateAndReject(
|
||||
NS_ERROR_FAILURE, __func__);
|
||||
}
|
||||
|
||||
return GenericNonExclusivePromise::CreateAndResolve(true, __func__);
|
||||
return mozilla::GenericNonExclusivePromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
ModuleScript* ModuleLoaderBase::GetFetchedModule(
|
||||
|
@ -233,11 +235,11 @@ nsresult ModuleLoaderBase::CreateModuleScript(ModuleLoadRequest* aRequest) {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoMicroTask mt;
|
||||
mozilla::nsAutoMicroTask mt;
|
||||
|
||||
AutoAllowLegacyScriptExecution exemption;
|
||||
mozilla::AutoAllowLegacyScriptExecution exemption;
|
||||
|
||||
AutoEntryScript aes(globalObject, "CompileModule", true);
|
||||
mozilla::dom::AutoEntryScript aes(globalObject, "CompileModule", true);
|
||||
|
||||
nsresult rv;
|
||||
{
|
||||
|
@ -391,7 +393,7 @@ nsresult ModuleLoaderBase::ResolveRequestedModules(
|
|||
ModuleLoadRequest* aRequest, nsCOMArray<nsIURI>* aUrlsOut) {
|
||||
ModuleScript* ms = aRequest->mModuleScript;
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(ms->ModuleRecord())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -494,23 +496,25 @@ void ModuleLoaderBase::StartFetchingModuleDependencies(
|
|||
|
||||
// For each url in urls, fetch a module script tree given url, module script's
|
||||
// CORS setting, and module script's settings object.
|
||||
nsTArray<RefPtr<GenericPromise>> importsReady;
|
||||
nsTArray<RefPtr<mozilla::GenericPromise>> importsReady;
|
||||
for (auto* url : urls) {
|
||||
RefPtr<GenericPromise> childReady =
|
||||
RefPtr<mozilla::GenericPromise> childReady =
|
||||
StartFetchingModuleAndDependencies(aRequest, url);
|
||||
importsReady.AppendElement(childReady);
|
||||
}
|
||||
|
||||
// Wait for all imports to become ready.
|
||||
RefPtr<GenericPromise::AllPromiseType> allReady =
|
||||
GenericPromise::All(GetMainThreadSerialEventTarget(), importsReady);
|
||||
allReady->Then(GetMainThreadSerialEventTarget(), __func__, aRequest,
|
||||
RefPtr<mozilla::GenericPromise::AllPromiseType> allReady =
|
||||
mozilla::GenericPromise::All(mozilla::GetMainThreadSerialEventTarget(),
|
||||
importsReady);
|
||||
allReady->Then(mozilla::GetMainThreadSerialEventTarget(), __func__, aRequest,
|
||||
&ModuleLoadRequest::DependenciesLoaded,
|
||||
&ModuleLoadRequest::ModuleErrored);
|
||||
}
|
||||
|
||||
RefPtr<GenericPromise> ModuleLoaderBase::StartFetchingModuleAndDependencies(
|
||||
ModuleLoadRequest* aParent, nsIURI* aURI) {
|
||||
RefPtr<mozilla::GenericPromise>
|
||||
ModuleLoaderBase::StartFetchingModuleAndDependencies(ModuleLoadRequest* aParent,
|
||||
nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
RefPtr<ModuleLoadRequest> childRequest = CreateStaticImport(aURI, aParent);
|
||||
|
@ -530,7 +534,7 @@ RefPtr<GenericPromise> ModuleLoaderBase::StartFetchingModuleAndDependencies(
|
|||
url2.get()));
|
||||
}
|
||||
|
||||
RefPtr<GenericPromise> ready = childRequest->mReady.Ensure(__func__);
|
||||
RefPtr<mozilla::GenericPromise> ready = childRequest->mReady.Ensure(__func__);
|
||||
|
||||
nsresult rv = StartModuleLoad(childRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -560,7 +564,7 @@ void ModuleLoaderBase::StartDynamicImport(ModuleLoadRequest* aRequest) {
|
|||
|
||||
void ModuleLoaderBase::FinishDynamicImportAndReject(ModuleLoadRequest* aRequest,
|
||||
nsresult aResult) {
|
||||
AutoJSAPI jsapi;
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
MOZ_ASSERT(NS_FAILED(aResult));
|
||||
MOZ_ALWAYS_TRUE(jsapi.Init(aRequest->mDynamicPromise));
|
||||
FinishDynamicImport(jsapi.cx(), aRequest, aResult, nullptr);
|
||||
|
@ -652,8 +656,8 @@ bool ModuleLoaderBase::InstantiateModuleTree(ModuleLoadRequest* aRequest) {
|
|||
|
||||
MOZ_ASSERT(moduleScript->ModuleRecord());
|
||||
|
||||
nsAutoMicroTask mt;
|
||||
AutoJSAPI jsapi;
|
||||
mozilla::nsAutoMicroTask mt;
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(moduleScript->ModuleRecord()))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -724,8 +728,8 @@ void ModuleLoaderBase::ProcessDynamicImport(ModuleLoadRequest* aRequest) {
|
|||
|
||||
nsresult ModuleLoaderBase::EvaluateModule(nsIGlobalObject* aGlobalObject,
|
||||
ScriptLoadRequest* aRequest) {
|
||||
nsAutoMicroTask mt;
|
||||
AutoEntryScript aes(aGlobalObject, "EvaluateModule", true);
|
||||
mozilla::nsAutoMicroTask mt;
|
||||
mozilla::dom::AutoEntryScript aes(aGlobalObject, "EvaluateModule", true);
|
||||
JSContext* cx = aes.cx();
|
||||
|
||||
nsAutoCString profilerLabelString;
|
||||
|
@ -843,4 +847,4 @@ void ModuleLoaderBase::CancelAndClearDynamicImports() {
|
|||
#undef LOG
|
||||
#undef LOG_ENABLED
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace JS::loader
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
* 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_ModuleLoaderBase_h
|
||||
#define mozilla_dom_ModuleLoaderBase_h
|
||||
#ifndef js_loader_ModuleLoaderBase_h
|
||||
#define js_loader_ModuleLoaderBase_h
|
||||
|
||||
#include "LoadedScript.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
|
||||
#include "js/TypeDecls.h" // JS::MutableHandle, JS::Handle, JS::Root
|
||||
#include "nsRefPtrHashtable.h"
|
||||
|
@ -15,15 +18,20 @@
|
|||
#include "nsINode.h" // nsIURI
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/dom/LoadedScript.h"
|
||||
#include "mozilla/dom/JSExecutionContext.h"
|
||||
#include "mozilla/dom/ScriptLoadRequest.h"
|
||||
#include "mozilla/MaybeOneOf.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "ModuleMapKey.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class LazyLogModule;
|
||||
union Utf8Unit;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
namespace JS {
|
||||
|
||||
class CompileOptions;
|
||||
|
@ -31,14 +39,7 @@ class CompileOptions;
|
|||
template <typename UnitT>
|
||||
class SourceText;
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class LazyLogModule;
|
||||
union Utf8Unit;
|
||||
|
||||
namespace dom {
|
||||
namespace loader {
|
||||
|
||||
class ModuleLoaderBase;
|
||||
class ModuleLoadRequest;
|
||||
|
@ -46,6 +47,13 @@ class ModuleScript;
|
|||
|
||||
class ScriptLoaderInterface : public nsISupports {
|
||||
public:
|
||||
// alias common classes
|
||||
using ScriptFetchOptions = JS::loader::ScriptFetchOptions;
|
||||
using ScriptKind = JS::loader::ScriptKind;
|
||||
using ScriptLoadRequest = JS::loader::ScriptLoadRequest;
|
||||
using ScriptLoadRequestList = JS::loader::ScriptLoadRequestList;
|
||||
using ModuleLoadRequest = JS::loader::ModuleLoadRequest;
|
||||
|
||||
// In some environments, we will need to default to a base URI
|
||||
virtual nsIURI* GetBaseURI() const = 0;
|
||||
|
||||
|
@ -66,8 +74,10 @@ class ScriptLoaderInterface : public nsISupports {
|
|||
|
||||
class ModuleLoaderBase : public nsISupports {
|
||||
private:
|
||||
using GenericNonExclusivePromise = mozilla::GenericNonExclusivePromise;
|
||||
using GenericPromise = mozilla::GenericPromise;
|
||||
// Module map
|
||||
nsRefPtrHashtable<ModuleMapKey, mozilla::GenericNonExclusivePromise::Private>
|
||||
nsRefPtrHashtable<ModuleMapKey, GenericNonExclusivePromise::Private>
|
||||
mFetchingModules;
|
||||
nsRefPtrHashtable<ModuleMapKey, ModuleScript> mFetchedModules;
|
||||
|
||||
|
@ -80,6 +90,9 @@ class ModuleLoaderBase : public nsISupports {
|
|||
NS_DECL_CYCLE_COLLECTION_CLASS(ModuleLoaderBase)
|
||||
explicit ModuleLoaderBase(ScriptLoaderInterface* aLoader);
|
||||
|
||||
using ScriptFetchOptions = JS::loader::ScriptFetchOptions;
|
||||
using ScriptLoadRequest = JS::loader::ScriptLoadRequest;
|
||||
using ModuleLoadRequest = JS::loader::ModuleLoadRequest;
|
||||
ScriptLoadRequestList mDynamicImportRequests;
|
||||
|
||||
using MaybeSourceText =
|
||||
|
@ -112,7 +125,7 @@ class ModuleLoaderBase : public nsISupports {
|
|||
ModuleLoadRequest* aRequest, nsresult aResult);
|
||||
|
||||
bool ModuleMapContainsURL(nsIURI* aURL, nsIGlobalObject* aGlobal) const;
|
||||
RefPtr<mozilla::GenericNonExclusivePromise> WaitForModuleFetch(
|
||||
RefPtr<GenericNonExclusivePromise> WaitForModuleFetch(
|
||||
nsIURI* aURL, nsIGlobalObject* aGlobal);
|
||||
ModuleScript* GetFetchedModule(nsIURI* aURL, nsIGlobalObject* aGlobal) const;
|
||||
|
||||
|
@ -134,7 +147,7 @@ class ModuleLoaderBase : public nsISupports {
|
|||
|
||||
void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);
|
||||
|
||||
RefPtr<mozilla::GenericPromise> StartFetchingModuleAndDependencies(
|
||||
RefPtr<GenericPromise> StartFetchingModuleAndDependencies(
|
||||
ModuleLoadRequest* aParent, nsIURI* aURI);
|
||||
|
||||
void StartDynamicImport(ModuleLoadRequest* aRequest);
|
||||
|
@ -182,11 +195,11 @@ class ModuleLoaderBase : public nsISupports {
|
|||
void CancelAndClearDynamicImports();
|
||||
|
||||
public:
|
||||
static LazyLogModule gCspPRLog;
|
||||
static LazyLogModule gModuleLoaderBaseLog;
|
||||
static mozilla::LazyLogModule gCspPRLog;
|
||||
static mozilla::LazyLogModule gModuleLoaderBaseLog;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace loader
|
||||
} // namespace JS
|
||||
|
||||
#endif // mozilla_dom_ModuleLoaderBase_h
|
||||
#endif // js_loader_ModuleLoaderBase_h
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "ModuleMapKey.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace JS::loader;
|
||||
|
||||
ModuleMapKey::ModuleMapKey(const nsIURI* aURI, nsIGlobalObject* aWebExtGlobal)
|
||||
: nsURIHashKey(aURI), mWebExtGlobal(aWebExtGlobal) {}
|
||||
|
@ -32,7 +32,7 @@ bool ModuleMapKey::KeyEquals(KeyTypePointer aOther) const {
|
|||
PLDHashNumber ModuleMapKey::HashKey(KeyTypePointer aKey) {
|
||||
PLDHashNumber hash = nsURIHashKey::HashKey(aKey->mKey);
|
||||
// XXX This seems wrong.
|
||||
hash =
|
||||
AddToHash(hash, reinterpret_cast<uintptr_t>(aKey->mWebExtGlobal.get()));
|
||||
hash = mozilla::AddToHash(
|
||||
hash, reinterpret_cast<uintptr_t>(aKey->mWebExtGlobal.get()));
|
||||
return hash;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "nsURIHashKey.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace JS::loader {
|
||||
|
||||
class ModuleMapKey : public nsURIHashKey {
|
||||
public:
|
||||
|
@ -42,6 +42,6 @@ inline void ImplCycleCollectionTraverse(
|
|||
ImplCycleCollectionTraverse(aCallback, aField.mWebExtGlobal, aName, aFlags);
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace JS::loader
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
* 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_ScriptKind_h
|
||||
#define mozilla_dom_ScriptKind_h
|
||||
#ifndef js_loader_ScriptKind_h
|
||||
#define js_loader_ScriptKind_h
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace JS::loader {
|
||||
|
||||
enum class ScriptKind { eClassic, eModule, eEvent };
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "mozilla/dom/ScriptLoadContext.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/ScriptLoadContext.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -22,13 +23,10 @@
|
|||
#include "nsICacheInfoChannel.h"
|
||||
#include "nsIClassOfService.h"
|
||||
#include "nsISupportsPriority.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
using JS::SourceText;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace JS::loader {
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// ScriptFetchOptions
|
||||
|
@ -39,9 +37,9 @@ NS_IMPL_CYCLE_COLLECTION(ScriptFetchOptions, mTriggeringPrincipal)
|
|||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ScriptFetchOptions, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ScriptFetchOptions, Release)
|
||||
|
||||
ScriptFetchOptions::ScriptFetchOptions(mozilla::CORSMode aCORSMode,
|
||||
ReferrerPolicy aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
ScriptFetchOptions::ScriptFetchOptions(
|
||||
mozilla::CORSMode aCORSMode, mozilla::dom::ReferrerPolicy aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
: mCORSMode(aCORSMode),
|
||||
mReferrerPolicy(aReferrerPolicy),
|
||||
mTriggeringPrincipal(aTriggeringPrincipal) {
|
||||
|
@ -80,7 +78,7 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI,
|
|||
ScriptFetchOptions* aFetchOptions,
|
||||
const SRIMetadata& aIntegrity,
|
||||
nsIURI* aReferrer,
|
||||
ScriptLoadContext* aContext)
|
||||
mozilla::dom::ScriptLoadContext* aContext)
|
||||
: mKind(aKind),
|
||||
mIsCanceled(false),
|
||||
mProgress(Progress::eLoading),
|
||||
|
@ -232,5 +230,4 @@ bool ScriptLoadRequestList::Contains(ScriptLoadRequest* aElem) const {
|
|||
}
|
||||
#endif // DEBUG
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace JS::loader
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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_ScriptLoadRequest_h
|
||||
#define mozilla_dom_ScriptLoadRequest_h
|
||||
#ifndef js_loader_ScriptLoadRequest_h
|
||||
#define js_loader_ScriptLoadRequest_h
|
||||
|
||||
#include "js/AllocPolicy.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
@ -27,22 +27,25 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "ScriptKind.h"
|
||||
|
||||
class nsICacheInfoChannel;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
class ScriptLoadContext;
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
namespace JS {
|
||||
class OffThreadToken;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace loader {
|
||||
|
||||
using Utf8Unit = mozilla::Utf8Unit;
|
||||
|
||||
class Element;
|
||||
class ModuleLoadRequest;
|
||||
class ScriptLoadRequestList;
|
||||
class ScriptLoadContext;
|
||||
|
||||
/*
|
||||
* ScriptFetchOptions loosely corresponds to HTML's "script fetch options",
|
||||
|
@ -73,7 +76,7 @@ class ScriptFetchOptions {
|
|||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ScriptFetchOptions)
|
||||
|
||||
ScriptFetchOptions(mozilla::CORSMode aCORSMode,
|
||||
enum ReferrerPolicy aReferrerPolicy,
|
||||
enum mozilla::dom::ReferrerPolicy aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal);
|
||||
|
||||
/*
|
||||
|
@ -87,7 +90,7 @@ class ScriptFetchOptions {
|
|||
* The referrer policy used for the initial fetch and for fetching any
|
||||
* imported modules
|
||||
*/
|
||||
const enum ReferrerPolicy mReferrerPolicy;
|
||||
const enum mozilla::dom::ReferrerPolicy mReferrerPolicy;
|
||||
|
||||
/*
|
||||
* related to cryptographic nonce, used to determine CSP
|
||||
|
@ -137,16 +140,27 @@ class ScriptLoadRequest
|
|||
virtual ~ScriptLoadRequest();
|
||||
|
||||
public:
|
||||
using SRIMetadata = mozilla::dom::SRIMetadata;
|
||||
ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI,
|
||||
ScriptFetchOptions* aFetchOptions,
|
||||
const SRIMetadata& aIntegrity, nsIURI* aReferrer,
|
||||
ScriptLoadContext* aContext);
|
||||
mozilla::dom::ScriptLoadContext* aContext);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ScriptLoadRequest)
|
||||
|
||||
using super::getNext;
|
||||
using super::isInList;
|
||||
|
||||
template <typename T>
|
||||
using VariantType = mozilla::VariantType<T>;
|
||||
|
||||
template <typename... Ts>
|
||||
using Variant = mozilla::Variant<Ts...>;
|
||||
|
||||
template <typename T, typename D = JS::DeletePolicy<T>>
|
||||
using UniquePtr = mozilla::UniquePtr<T, D>;
|
||||
|
||||
using MaybeSourceText =
|
||||
mozilla::MaybeOneOf<JS::SourceText<char16_t>, JS::SourceText<Utf8Unit>>;
|
||||
|
||||
|
@ -196,7 +210,7 @@ class ScriptLoadRequest
|
|||
void SetTextSource() {
|
||||
MOZ_ASSERT(IsUnknownDataType());
|
||||
mDataType = DataType::eTextSource;
|
||||
if (StaticPrefs::
|
||||
if (mozilla::StaticPrefs::
|
||||
dom_script_loader_external_scripts_utf8_parsing_enabled()) {
|
||||
mScriptData.emplace(VariantType<ScriptTextBuffer<Utf8Unit>>());
|
||||
} else {
|
||||
|
@ -208,7 +222,7 @@ class ScriptLoadRequest
|
|||
// can be transferred in constant time to the JS engine, not copied in linear
|
||||
// time.
|
||||
template <typename Unit>
|
||||
using ScriptTextBuffer = Vector<Unit, 0, js::MallocAllocPolicy>;
|
||||
using ScriptTextBuffer = mozilla::Vector<Unit, 0, js::MallocAllocPolicy>;
|
||||
|
||||
bool IsUTF16Text() const {
|
||||
return mScriptData->is<ScriptTextBuffer<char16_t>>();
|
||||
|
@ -244,7 +258,7 @@ class ScriptLoadRequest
|
|||
: ScriptText<Utf8Unit>().clearAndFree();
|
||||
}
|
||||
|
||||
enum ReferrerPolicy ReferrerPolicy() const {
|
||||
enum mozilla::dom::ReferrerPolicy ReferrerPolicy() const {
|
||||
return mFetchOptions->mReferrerPolicy;
|
||||
}
|
||||
|
||||
|
@ -266,7 +280,7 @@ class ScriptLoadRequest
|
|||
|
||||
bool HasLoadContext() { return mLoadContext; }
|
||||
|
||||
ScriptLoadContext* GetLoadContext() {
|
||||
mozilla::dom::ScriptLoadContext* GetLoadContext() {
|
||||
MOZ_ASSERT(mLoadContext);
|
||||
return mLoadContext;
|
||||
}
|
||||
|
@ -280,10 +294,12 @@ class ScriptLoadRequest
|
|||
RefPtr<ScriptFetchOptions> mFetchOptions;
|
||||
const SRIMetadata mIntegrity;
|
||||
const nsCOMPtr<nsIURI> mReferrer;
|
||||
Maybe<nsString> mSourceMapURL; // Holds source map url for loaded scripts
|
||||
mozilla::Maybe<nsString>
|
||||
mSourceMapURL; // Holds source map url for loaded scripts
|
||||
|
||||
// Holds script source data for non-inline scripts.
|
||||
Maybe<Variant<ScriptTextBuffer<char16_t>, ScriptTextBuffer<Utf8Unit>>>
|
||||
mozilla::Maybe<
|
||||
Variant<ScriptTextBuffer<char16_t>, ScriptTextBuffer<Utf8Unit>>>
|
||||
mScriptData;
|
||||
|
||||
// The length of script source text, set when reading completes. This is used
|
||||
|
@ -313,7 +329,7 @@ class ScriptLoadRequest
|
|||
|
||||
// ScriptLoadContext for augmenting the load depending on the loading
|
||||
// context (DOM, Worker, etc.)
|
||||
RefPtr<ScriptLoadContext> mLoadContext;
|
||||
RefPtr<mozilla::dom::ScriptLoadContext> mLoadContext;
|
||||
};
|
||||
|
||||
class ScriptLoadRequestList : private mozilla::LinkedList<ScriptLoadRequest> {
|
||||
|
@ -368,7 +384,7 @@ inline void ImplCycleCollectionTraverse(
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace loader
|
||||
} // namespace JS
|
||||
|
||||
#endif // mozilla_dom_ScriptLoadRequest_h
|
||||
#endif // js_loader_ScriptLoadRequest_h
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# 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/.
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
EXPORTS.js.loader += [
|
||||
"LoadedScript.h",
|
||||
"ModuleLoaderBase.h",
|
||||
"ModuleLoadRequest.h",
|
||||
|
|
|
@ -75,8 +75,8 @@ PreloadHashKey& PreloadHashKey::operator=(const PreloadHashKey& aOther) {
|
|||
}
|
||||
|
||||
// static
|
||||
PreloadHashKey PreloadHashKey::CreateAsScript(nsIURI* aURI, CORSMode aCORSMode,
|
||||
dom::ScriptKind aScriptKind) {
|
||||
PreloadHashKey PreloadHashKey::CreateAsScript(
|
||||
nsIURI* aURI, CORSMode aCORSMode, JS::loader::ScriptKind aScriptKind) {
|
||||
PreloadHashKey key(aURI, ResourceType::SCRIPT);
|
||||
key.mCORSMode = aCORSMode;
|
||||
|
||||
|
@ -89,9 +89,9 @@ PreloadHashKey PreloadHashKey::CreateAsScript(nsIURI* aURI, CORSMode aCORSMode,
|
|||
PreloadHashKey PreloadHashKey::CreateAsScript(nsIURI* aURI,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aType) {
|
||||
dom::ScriptKind scriptKind = dom::ScriptKind::eClassic;
|
||||
JS::loader::ScriptKind scriptKind = JS::loader::ScriptKind::eClassic;
|
||||
if (aType.LowerCaseEqualsASCII("module")) {
|
||||
scriptKind = dom::ScriptKind::eModule;
|
||||
scriptKind = JS::loader::ScriptKind::eModule;
|
||||
}
|
||||
CORSMode crossOrigin = dom::Element::StringToCORSMode(aCrossOrigin);
|
||||
return CreateAsScript(aURI, crossOrigin, scriptKind);
|
||||
|
|
|
@ -7,11 +7,15 @@
|
|||
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/css/SheetParsingMode.h"
|
||||
#include "mozilla/dom/ScriptKind.h"
|
||||
#include "js/loader/ScriptKind.h"
|
||||
#include "nsURIHashKey.h"
|
||||
|
||||
class nsIPrincipal;
|
||||
|
||||
namespace JS::loader {
|
||||
enum class ScriptKind;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace css {
|
||||
|
@ -44,7 +48,7 @@ class PreloadHashKey : public nsURIHashKey {
|
|||
|
||||
// Construct key for "script"
|
||||
static PreloadHashKey CreateAsScript(nsIURI* aURI, CORSMode aCORSMode,
|
||||
dom::ScriptKind aScriptKind);
|
||||
JS::loader::ScriptKind aScriptKind);
|
||||
static PreloadHashKey CreateAsScript(nsIURI* aURI,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aType);
|
||||
|
@ -92,7 +96,7 @@ class PreloadHashKey : public nsURIHashKey {
|
|||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
struct {
|
||||
dom::ScriptKind mScriptKind = dom::ScriptKind::eClassic;
|
||||
JS::loader::ScriptKind mScriptKind = JS::loader::ScriptKind::eClassic;
|
||||
} mScript;
|
||||
|
||||
struct {
|
||||
|
|
Загрузка…
Ссылка в новой задаче