Backed out 4 changesets (bug 1842798) for wpt failures on module-tla-import.html . CLOSED TREE

Backed out changeset 879154594bb1 (bug 1842798)
Backed out changeset 2a6b3ff79a01 (bug 1842798)
Backed out changeset 507da9d36f91 (bug 1842798)
Backed out changeset 3528d70acb5f (bug 1842798)
This commit is contained in:
Narcis Beleuzu
2023-08-02 20:48:53 +03:00
parent a4699a0906
commit b9b0f9065e
7 changed files with 106 additions and 202 deletions

View File

@@ -23,6 +23,7 @@
#include "mozilla/CORSMode.h"
#include "mozilla/dom/JSExecutionContext.h"
#include "mozilla/MaybeOneOf.h"
#include "mozilla/MozPromise.h"
#include "mozilla/UniquePtr.h"
#include "ResolveResult.h"
@@ -123,9 +124,9 @@ class ScriptLoaderInterface : public nsISupports {
* module map.
*
* The module map is made up of two parts. A module that has been requested but
* has not finished fetching is represented by an entry in the mFetchingModules
* map. A module which has been fetched and compiled is represented by a
* ModuleScript in the mFetchedModules map.
* has not yet loaded is represented by a promise in the mFetchingModules map. A
* module which has been loaded is represented by a ModuleScript in the
* mFetchedModules map.
*
* Module loading typically works as follows:
*
@@ -162,21 +163,13 @@ class ScriptLoaderInterface : public nsISupports {
* 10. The client calls EvaluateModule() to execute the top-level module.
*/
class ModuleLoaderBase : public nsISupports {
/*
* The set of requests that are waiting for an ongoing fetch to complete.
*/
class WaitingRequests final : public nsISupports {
virtual ~WaitingRequests() = default;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(WaitingRequests)
nsTArray<RefPtr<ModuleLoadRequest>> mWaiting;
};
private:
using GenericNonExclusivePromise = mozilla::GenericNonExclusivePromise;
using GenericPromise = mozilla::GenericPromise;
// Module map
nsRefPtrHashtable<nsURIHashKey, WaitingRequests> mFetchingModules;
nsRefPtrHashtable<nsURIHashKey, GenericNonExclusivePromise::Private>
mFetchingModules;
nsRefPtrHashtable<nsURIHashKey, ModuleScript> mFetchedModules;
// List of dynamic imports that are currently being loaded.
@@ -190,8 +183,8 @@ class ModuleLoaderBase : public nsISupports {
bool mImportMapsAllowed = true;
protected:
// Event handler used to dispatch runnables, used internally to wait for
// fetches to finish and for imports to become avilable.
// Event handler used to process MozPromise actions, used internally to wait
// for fetches to finish and for imports to become avilable.
nsCOMPtr<nsISerialEventTarget> mEventTarget;
RefPtr<ScriptLoaderInterface> mLoader;
@@ -367,7 +360,7 @@ class ModuleLoaderBase : public nsISupports {
bool ModuleMapContainsURL(nsIURI* aURL) const;
bool IsModuleFetching(nsIURI* aURL) const;
void WaitForModuleFetch(ModuleLoadRequest* aRequest);
RefPtr<GenericNonExclusivePromise> WaitForModuleFetch(nsIURI* aURL);
void SetModuleFetchStarted(ModuleLoadRequest* aRequest);
ModuleScript* GetFetchedModule(nsIURI* aURL) const;
@@ -380,15 +373,11 @@ class ModuleLoaderBase : public nsISupports {
void SetModuleFetchFinishedAndResumeWaitingRequests(
ModuleLoadRequest* aRequest, nsresult aResult);
void ResumeWaitingRequests(WaitingRequests* aWaitingRequests, bool aSuccess);
void ResumeWaitingRequest(ModuleLoadRequest* aRequest, bool aSuccess);
void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);
void StartFetchingModuleAndDependencies(ModuleLoadRequest* aParent,
nsIURI* aURI);
void InstantiateAndEvaluateDynamicImport(ModuleLoadRequest* aRequest);
RefPtr<GenericPromise> StartFetchingModuleAndDependencies(
ModuleLoadRequest* aParent, nsIURI* aURI);
/**
* Shorthand Wrapper for JSAPI FinishDynamicImport function for the reject