diff --git a/js/loader/ModuleLoadRequest.cpp b/js/loader/ModuleLoadRequest.cpp index ca5a6d0089e4..b5ddf649ce97 100644 --- a/js/loader/ModuleLoadRequest.cpp +++ b/js/loader/ModuleLoadRequest.cpp @@ -69,7 +69,6 @@ ModuleLoadRequest::ModuleLoadRequest( void ModuleLoadRequest::Cancel() { ScriptLoadRequest::Cancel(); mModuleScript = nullptr; - mState = ScriptLoadRequest::State::Ready; CancelImports(); mReady.RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__); } diff --git a/js/loader/ScriptLoadRequest.cpp b/js/loader/ScriptLoadRequest.cpp index ce2b920b7127..5765dbf36f64 100644 --- a/js/loader/ScriptLoadRequest.cpp +++ b/js/loader/ScriptLoadRequest.cpp @@ -82,7 +82,6 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI, nsIURI* aReferrer, mozilla::dom::ScriptLoadContext* aContext) : mKind(aKind), - mIsCanceled(false), mState(State::Fetching), mFetchSourceOnly(false), mDataType(DataType::eUnknown), @@ -109,12 +108,12 @@ ScriptLoadRequest::~ScriptLoadRequest() { } void ScriptLoadRequest::SetReady() { - MOZ_ASSERT(mState != State::Ready); + MOZ_ASSERT(!IsReadyToRun()); mState = State::Ready; } void ScriptLoadRequest::Cancel() { - mIsCanceled = true; + mState = State::Canceled; if (HasLoadContext()) { GetLoadContext()->MaybeCancelOffThreadScript(); } diff --git a/js/loader/ScriptLoadRequest.h b/js/loader/ScriptLoadRequest.h index 2625ddecd25f..938c737e9e84 100644 --- a/js/loader/ScriptLoadRequest.h +++ b/js/loader/ScriptLoadRequest.h @@ -180,18 +180,26 @@ class ScriptLoadRequest virtual void Cancel(); - bool IsCanceled() const { return mIsCanceled; } - virtual void SetReady(); - enum class State : uint8_t { Fetching, Compiling, LoadingImports, Ready }; + enum class State : uint8_t { + Fetching, + Compiling, + LoadingImports, + Ready, + Canceled + }; - bool IsReadyToRun() const { return mState == State::Ready; } + bool IsReadyToRun() const { + return mState == State::Ready || mState == State::Canceled; + } bool IsLoading() const { return mState == State::Fetching; } bool InCompilingStage() const { return mState == State::Compiling; } + bool IsCanceled() const { return mState == State::Canceled; } + // Type of data provided by the nsChannel. enum class DataType : uint8_t { eUnknown, eTextSource, eBytecode }; @@ -286,10 +294,9 @@ class ScriptLoadRequest const ScriptKind mKind; // Whether this is a classic script or a module // script. - bool mIsCanceled; // True if we have been explicitly canceled. - State mState; // Are we still waiting for a load to complete? + State mState; // Are we still waiting for a load to complete? bool mFetchSourceOnly; // Request source, not cached bytecode. - DataType mDataType; // Does this contain Source or Bytecode? + DataType mDataType; // Does this contain Source or Bytecode? RefPtr mFetchOptions; const SRIMetadata mIntegrity; const nsCOMPtr mReferrer;