tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 08904835b890fdee01976450b0c5ae62844fafd5
parent 8b743b6a79d5be966c4f3253a69eeaf6be2e5fc1
Author: Yoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Date:   Fri,  3 Oct 2025 20:53:29 +0000

Bug 1968890 - Part 8: Remove FinishDynamicImportAndReject. r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D264810

Diffstat:
Mjs/loader/ModuleLoaderBase.cpp | 37-------------------------------------
Mjs/loader/ModuleLoaderBase.h | 14--------------
2 files changed, 0 insertions(+), 51 deletions(-)

diff --git a/js/loader/ModuleLoaderBase.cpp b/js/loader/ModuleLoaderBase.cpp @@ -1411,37 +1411,6 @@ void ModuleLoaderBase::AppendDynamicImport(ModuleLoadRequest* aRequest) { mDynamicImportRequests.AppendElement(aRequest); } -void ModuleLoaderBase::FinishDynamicImportAndReject(ModuleLoadRequest* aRequest, - nsresult aResult) { - AutoJSAPI jsapi; - MOZ_ASSERT(NS_FAILED(aResult)); - if (!jsapi.Init(mGlobalObject)) { - return; - } - - if (aRequest->mPayload.isUndefined()) { - // Import has already been completed. - return; - } - - JSContext* cx = jsapi.cx(); - Rooted<Value> payload(cx, aRequest->mPayload); - - if (NS_FAILED(aResult) && - aResult != NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE) { - MOZ_ASSERT(!JS_IsExceptionPending(cx)); - nsAutoCString url; - aRequest->mURI->GetSpec(url); - JS_ReportErrorNumberASCII(cx, js::GetErrorMessage, nullptr, - JSMSG_DYNAMIC_IMPORT_FAILED, url.get()); - FinishLoadingImportedModuleFailedWithPendingException(cx, payload); - } else { - FinishLoadingImportedModuleFailed(cx, payload, UndefinedHandleValue); - } - - aRequest->ClearImport(); -} - ModuleLoaderBase::ModuleLoaderBase(ScriptLoaderInterface* aLoader, nsIGlobalObject* aGlobalObject) : mGlobalObject(aGlobalObject), mLoader(aLoader) { @@ -1501,7 +1470,6 @@ bool ModuleLoaderBase::HasPendingDynamicImports() const { return !mDynamicImportRequests.isEmpty(); } -// TODO: Bug 1968890 : Update error handling for dynamic import void ModuleLoaderBase::CancelDynamicImport(ModuleLoadRequest* aRequest, nsresult aResult) { // aRequest may have already been unlinked by CC. @@ -1512,12 +1480,7 @@ void ModuleLoaderBase::CancelDynamicImport(ModuleLoadRequest* aRequest, // If the ClearDynamicImport() has been called, then it should have been // removed from mDynamicImportRequests as well. MOZ_ASSERT(!aRequest->mPayload.isUndefined()); - aRequest->Cancel(); - // FinishDynamicImport must happen exactly once for each dynamic import - // request. If the load is aborted we do it when we remove the request - // from mDynamicImportRequests. - FinishDynamicImportAndReject(aRequest, aResult); } } diff --git a/js/loader/ModuleLoaderBase.h b/js/loader/ModuleLoaderBase.h @@ -553,20 +553,6 @@ class ModuleLoaderBase : public nsISupports { ModuleLoadRequest* aRequest, Handle<Value> aError); - /** - * Shorthand Wrapper for JSAPI FinishDynamicImport function for the reject - * case where we do not have `aEvaluationPromise`. As there is no evaluation - * Promise, JS::FinishDynamicImport will always reject. - * - * @param aRequest - * The module load request for the dynamic module. - * @param aResult - * The result of running ModuleEvaluate -- If this is successful, then - * we can await the associated EvaluationPromise. - */ - void FinishDynamicImportAndReject(ModuleLoadRequest* aRequest, - nsresult aResult); - void RemoveDynamicImport(ModuleLoadRequest* aRequest); nsresult CreateModuleScript(ModuleLoadRequest* aRequest);