Backed out 4 changesets (bug 1877703) as requested by dev for causing Bug 1885443

Backed out changeset 5eb60e36ef79 (bug 1877703)
Backed out changeset 5921d1fb831e (bug 1877703)
Backed out changeset 64281b11237e (bug 1877703)
Backed out changeset 7ee0827809fb (bug 1877703)
This commit is contained in:
Norisz Fay 2024-03-15 13:28:07 +02:00
Родитель 0da00d16e5
Коммит 66f73c547b
16 изменённых файлов: 45 добавлений и 249 удалений

Просмотреть файл

@ -1 +0,0 @@
// Empty script.

Просмотреть файл

@ -3,9 +3,6 @@ support-files = [
"bug_1865410_module_a.mjs", "bug_1865410_module_a.mjs",
"bug_1865410_module_b.mjs", "bug_1865410_module_b.mjs",
"bug_1873417.mjs", "bug_1873417.mjs",
"classic_script.js",
"module_chain_1.mjs",
"module_chain_2.mjs",
"module_importMap_with_external_script_0.mjs", "module_importMap_with_external_script_0.mjs",
"module_importMap_with_external_script_1.mjs", "module_importMap_with_external_script_1.mjs",
"module_importMap_with_external_script_2.mjs", "module_importMap_with_external_script_2.mjs",
@ -34,5 +31,3 @@ support-files = [
["test_bug_1873417.html"] ["test_bug_1873417.html"]
["test_importMap_with_external_script.html"] ["test_importMap_with_external_script.html"]
["test_dynamic_importMap_with_external_script.html"]
["test_dynamic_importMap_load_completes.html"]

Просмотреть файл

@ -1,2 +0,0 @@
// eslint-disable-next-line import/no-unassigned-import
import {} from "./module_chain_2.mjs";

Просмотреть файл

@ -1 +0,0 @@
loaded = true;

Просмотреть файл

@ -1,33 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<head>
<title>Test script loading complets when there's a dynamicly inserted import map</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<!--
This test case used to fail intermittently with some modules never
being loaded.
-->
<script>
let loaded = false; // Set by module_chain_2.mjs.
</script>
<script src="classic_script.js"></script>
<script>
const script = document.createElement('script');
script.type = 'importmap';
script.textContent = `{}`;
document.head.appendChild(script);
</script>
<script src="module_chain_1.mjs" type="module"></script>
<script type="module">
ok(loaded, "Expected all modules loaded");
</script>
<body></body>

Просмотреть файл

@ -1,81 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<head>
<title>Test speculative preload of external script doesn't conflict with import map</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<!--
These tests check that speculative preloading, which could happen before
the import map is installed, doesn't load the wrong modules. This version
dynamically inserts the import map script element after speculative
preloading has started.
-->
<script>
const script = document.createElement('script');
script.type = 'importmap';
script.textContent =
`{
"imports": {
"bare": "./good/module_0.mjs",
"./bad/module_1.mjs": "./good/module_1.mjs",
"./bad/module_2.mjs": "./good/module_2.mjs",
"./bad/module_3.mjs": "./good/module_3.mjs",
"./bad/module_4.mjs": "./good/module_4.mjs",
"./bad/module_7.mjs": "./good/module_7.mjs"
}
}`;
document.head.appendChild(script);
</script>
<!--
Test bareword import (not supported before import map installed).
-->
<script type="module" src="module_importMap_with_external_script_0.mjs"></script>
<!--
Test mapping from missing resource to existing resource (not found before
import map installed).
-->
<script type="module" src="module_importMap_with_external_script_1.mjs"></script>
<!--
Test mapping from one existing resource to another (would load wrong resource before
import map installed).
-->
<script type="module" src="module_importMap_with_external_script_2.mjs"></script>
<!--
Test mapping from one existing resource to another with circular dependency.
-->
<script type="module" src="module_importMap_with_external_script_3.mjs"></script>
<!--
Test with redirect, script_6.mjs -> script_5.mjs -> script_4.mjs.
We redirect twice here, as sometimes one redirect can't reproduce the crash
from bug 1835468.
-->
<script type="module" src="module_importMap_with_external_script_6.mjs"></script>
<!--
Test with async attribute
-->
<script type="module" async src="module_importMap_with_external_script_7.mjs"></script>
<script>
SimpleTest.waitForExplicitFinish();
let passCount = 0;
const expectedCount = 6;
function success(name) {
ok(true, "Test passed, loaded " + name);
passCount++;
if (passCount == expectedCount) {
SimpleTest.finish();
}
}
</script>
<body></body>

Просмотреть файл

@ -147,7 +147,7 @@ class ScriptLoadContext : public JS::loader::LoadContextBase,
static void PrioritizeAsPreload(nsIChannel* aChannel); static void PrioritizeAsPreload(nsIChannel* aChannel);
bool IsPreload() const override; bool IsPreload() const;
bool CompileStarted() const; bool CompileStarted() const;

Просмотреть файл

@ -1097,6 +1097,19 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
return false; return false;
} }
if (request && request->IsModuleRequest() &&
mModuleLoader->HasImportMapRegistered() &&
request->mState > ScriptLoadRequest::State::Compiling) {
// We don't preload module scripts after seeing an import map but a script
// can dynamically insert an import map after preloading has happened.
//
// In the case of an import map is inserted after preloading has happened,
// We also check if the request has started loading imports, if not then we
// can reuse the preloaded request.
request->Cancel();
request = nullptr;
}
if (request) { if (request) {
// Use the preload request. // Use the preload request.
@ -1386,16 +1399,6 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
return false; return false;
} }
// Remove any module preloads. Module specifier resolution is invalidated by
// adding an import map, and incorrect dependencies may have been loaded.
mPreloads.RemoveElementsBy([](const PreloadInfo& info) {
if (info.mRequest->IsModuleRequest()) {
info.mRequest->Cancel();
return true;
}
return false;
});
// TODO: Bug 1781758: Move RegisterImportMap into EvaluateScriptElement. // TODO: Bug 1781758: Move RegisterImportMap into EvaluateScriptElement.
// //
// https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-element // https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-element

Просмотреть файл

@ -52,9 +52,6 @@ class LoadContextBase : public nsISupports {
// Used to output a string for the Gecko Profiler. // Used to output a string for the Gecko Profiler.
virtual void GetProfilerLabel(nsACString& aOutString); virtual void GetProfilerLabel(nsACString& aOutString);
// Whether this is a preload, for contexts that support them.
virtual bool IsPreload() const { return false; }
// Casting to the different contexts // Casting to the different contexts
bool IsWindowContext() const { return mKind == ContextKind::Window; } bool IsWindowContext() const { return mKind == ContextKind::Window; }
mozilla::dom::ScriptLoadContext* AsWindowContext(); mozilla::dom::ScriptLoadContext* AsWindowContext();

Просмотреть файл

@ -207,7 +207,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
ModuleScript::ModuleScript(mozilla::dom::ReferrerPolicy aReferrerPolicy, ModuleScript::ModuleScript(mozilla::dom::ReferrerPolicy aReferrerPolicy,
ScriptFetchOptions* aFetchOptions, nsIURI* aURI) ScriptFetchOptions* aFetchOptions, nsIURI* aURI)
: LoadedScript(ScriptKind::eModule, aReferrerPolicy, aFetchOptions, aURI), : LoadedScript(ScriptKind::eModule, aReferrerPolicy, aFetchOptions, aURI),
mHadImportMap(false),
mDebuggerDataInitialized(false) { mDebuggerDataInitialized(false) {
MOZ_ASSERT(!ModuleRecord()); MOZ_ASSERT(!ModuleRecord());
MOZ_ASSERT(!HasParseError()); MOZ_ASSERT(!HasParseError());
@ -280,9 +279,6 @@ void ModuleScript::SetErrorToRethrow(const JS::Value& aError) {
mErrorToRethrow = aError; mErrorToRethrow = aError;
} }
void ModuleScript::SetForPreload(bool aValue) { mForPreload = aValue; }
void ModuleScript::SetHadImportMap(bool aValue) { mHadImportMap = aValue; }
void ModuleScript::SetDebuggerDataInitialized() { void ModuleScript::SetDebuggerDataInitialized() {
MOZ_ASSERT(ModuleRecord()); MOZ_ASSERT(ModuleRecord());
MOZ_ASSERT(!mDebuggerDataInitialized); MOZ_ASSERT(!mDebuggerDataInitialized);

Просмотреть файл

@ -332,8 +332,6 @@ class ModuleScript final : public LoadedScript {
JS::Heap<JSObject*> mModuleRecord; JS::Heap<JSObject*> mModuleRecord;
JS::Heap<JS::Value> mParseError; JS::Heap<JS::Value> mParseError;
JS::Heap<JS::Value> mErrorToRethrow; JS::Heap<JS::Value> mErrorToRethrow;
bool mForPreload;
bool mHadImportMap;
bool mDebuggerDataInitialized; bool mDebuggerDataInitialized;
~ModuleScript(); ~ModuleScript();
@ -354,8 +352,6 @@ class ModuleScript final : public LoadedScript {
void SetModuleRecord(JS::Handle<JSObject*> aModuleRecord); void SetModuleRecord(JS::Handle<JSObject*> aModuleRecord);
void SetParseError(const JS::Value& aError); void SetParseError(const JS::Value& aError);
void SetErrorToRethrow(const JS::Value& aError); void SetErrorToRethrow(const JS::Value& aError);
void SetForPreload(bool aValue);
void SetHadImportMap(bool aValue);
void SetDebuggerDataInitialized(); void SetDebuggerDataInitialized();
JSObject* ModuleRecord() const { return mModuleRecord; } JSObject* ModuleRecord() const { return mModuleRecord; }
@ -364,8 +360,6 @@ class ModuleScript final : public LoadedScript {
JS::Value ErrorToRethrow() const { return mErrorToRethrow; } JS::Value ErrorToRethrow() const { return mErrorToRethrow; }
bool HasParseError() const { return !mParseError.isUndefined(); } bool HasParseError() const { return !mParseError.isUndefined(); }
bool HasErrorToRethrow() const { return !mErrorToRethrow.isUndefined(); } bool HasErrorToRethrow() const { return !mErrorToRethrow.isUndefined(); }
bool ForPreload() const { return mForPreload; }
bool HadImportMap() const { return mHadImportMap; }
bool DebuggerDataInitialized() const { return mDebuggerDataInitialized; } bool DebuggerDataInitialized() const { return mDebuggerDataInitialized; }
void Shutdown(); void Shutdown();

Просмотреть файл

@ -205,7 +205,6 @@ void ModuleLoadRequest::CheckModuleDependenciesLoaded() {
if (!mModuleScript || mModuleScript->HasParseError()) { if (!mModuleScript || mModuleScript->HasParseError()) {
return; return;
} }
for (const auto& childRequest : mImports) { for (const auto& childRequest : mImports) {
ModuleScript* childScript = childRequest->mModuleScript; ModuleScript* childScript = childRequest->mModuleScript;
if (!childScript) { if (!childScript) {
@ -214,9 +213,6 @@ void ModuleLoadRequest::CheckModuleDependenciesLoaded() {
childRequest.get())); childRequest.get()));
return; return;
} }
MOZ_DIAGNOSTIC_ASSERT(mModuleScript->HadImportMap() ==
childScript->HadImportMap());
} }
LOG(("ScriptLoadRequest (%p): all ok", this)); LOG(("ScriptLoadRequest (%p): all ok", this));

Просмотреть файл

@ -55,17 +55,17 @@ mozilla::LazyLogModule ModuleLoaderBase::gModuleLoaderBaseLog(
MOZ_LOG_TEST(ModuleLoaderBase::gModuleLoaderBaseLog, mozilla::LogLevel::Debug) MOZ_LOG_TEST(ModuleLoaderBase::gModuleLoaderBaseLog, mozilla::LogLevel::Debug)
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// ModuleLoaderBase::LoadingRequest // ModuleLoaderBase::WaitingRequests
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ModuleLoaderBase::LoadingRequest) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ModuleLoaderBase::WaitingRequests)
NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(ModuleLoaderBase::LoadingRequest, mRequest, mWaiting) NS_IMPL_CYCLE_COLLECTION(ModuleLoaderBase::WaitingRequests, mWaiting)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleLoaderBase::LoadingRequest) NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleLoaderBase::WaitingRequests)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ModuleLoaderBase::LoadingRequest) NS_IMPL_CYCLE_COLLECTING_RELEASE(ModuleLoaderBase::WaitingRequests)
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// ModuleLoaderBase // ModuleLoaderBase
@ -509,9 +509,7 @@ void ModuleLoaderBase::SetModuleFetchStarted(ModuleLoadRequest* aRequest) {
MOZ_ASSERT(aRequest->IsFetching() || aRequest->IsPendingFetchingError()); MOZ_ASSERT(aRequest->IsFetching() || aRequest->IsPendingFetchingError());
MOZ_ASSERT(!ModuleMapContainsURL(aRequest->mURI)); MOZ_ASSERT(!ModuleMapContainsURL(aRequest->mURI));
RefPtr<LoadingRequest> loadingRequest = new LoadingRequest(); mFetchingModules.InsertOrUpdate(aRequest->mURI, nullptr);
loadingRequest->mRequest = aRequest;
mFetchingModules.InsertOrUpdate(aRequest->mURI, loadingRequest);
} }
void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests( void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
@ -528,8 +526,9 @@ void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
"%u)", "%u)",
aRequest, aRequest->mModuleScript.get(), unsigned(aResult))); aRequest, aRequest->mModuleScript.get(), unsigned(aResult)));
auto entry = mFetchingModules.Lookup(aRequest->mURI); RefPtr<WaitingRequests> waitingRequests;
if (!entry) { if (!mFetchingModules.Remove(aRequest->mURI,
getter_AddRefs(waitingRequests))) {
LOG( LOG(
("ScriptLoadRequest (%p): Key not found in mFetchingModules, " ("ScriptLoadRequest (%p): Key not found in mFetchingModules, "
"assuming we have an inline module or have finished fetching already", "assuming we have an inline module or have finished fetching already",
@ -537,35 +536,20 @@ void ModuleLoaderBase::SetModuleFetchFinishedAndResumeWaitingRequests(
return; return;
} }
// It's possible for a request to be cancelled and removed from the fetching
// modules map and a new request started for the same URI and added to the
// map. In this case we don't want the first cancelled request to complete the
// later request (which will cause it to fail) so we ignore it.
RefPtr<LoadingRequest> loadingRequest = entry.Data();
if (loadingRequest->mRequest != aRequest) {
MOZ_ASSERT(aRequest->IsCanceled());
LOG(
("ScriptLoadRequest (%p): Ignoring completion of cancelled request "
"that was removed from the map",
aRequest));
return;
}
MOZ_ALWAYS_TRUE(mFetchingModules.Remove(aRequest->mURI));
RefPtr<ModuleScript> moduleScript(aRequest->mModuleScript); RefPtr<ModuleScript> moduleScript(aRequest->mModuleScript);
MOZ_ASSERT(NS_FAILED(aResult) == !moduleScript); MOZ_ASSERT(NS_FAILED(aResult) == !moduleScript);
mFetchedModules.InsertOrUpdate(aRequest->mURI, RefPtr{moduleScript}); mFetchedModules.InsertOrUpdate(aRequest->mURI, RefPtr{moduleScript});
if (waitingRequests) {
LOG(("ScriptLoadRequest (%p): Resuming waiting requests", aRequest)); LOG(("ScriptLoadRequest (%p): Resuming waiting requests", aRequest));
MOZ_ASSERT(loadingRequest->mRequest == aRequest); ResumeWaitingRequests(waitingRequests, bool(moduleScript));
ResumeWaitingRequests(loadingRequest, bool(moduleScript)); }
} }
void ModuleLoaderBase::ResumeWaitingRequests(LoadingRequest* aLoadingRequest, void ModuleLoaderBase::ResumeWaitingRequests(WaitingRequests* aWaitingRequests,
bool aSuccess) { bool aSuccess) {
for (ModuleLoadRequest* request : aLoadingRequest->mWaiting) { for (ModuleLoadRequest* request : aWaitingRequests->mWaiting) {
ResumeWaitingRequest(request, aSuccess); ResumeWaitingRequest(request, aSuccess);
} }
} }
@ -584,8 +568,13 @@ void ModuleLoaderBase::WaitForModuleFetch(ModuleLoadRequest* aRequest) {
MOZ_ASSERT(ModuleMapContainsURL(uri)); MOZ_ASSERT(ModuleMapContainsURL(uri));
if (auto entry = mFetchingModules.Lookup(uri)) { if (auto entry = mFetchingModules.Lookup(uri)) {
RefPtr<LoadingRequest> loadingRequest = entry.Data(); RefPtr<WaitingRequests> waitingRequests = entry.Data();
loadingRequest->mWaiting.AppendElement(aRequest); if (!waitingRequests) {
waitingRequests = new WaitingRequests();
mFetchingModules.InsertOrUpdate(uri, waitingRequests);
}
waitingRequests->mWaiting.AppendElement(aRequest);
return; return;
} }
@ -689,8 +678,6 @@ nsresult ModuleLoaderBase::CreateModuleScript(ModuleLoadRequest* aRequest) {
aRequest->mLoadedScript->AsModuleScript(); aRequest->mLoadedScript->AsModuleScript();
aRequest->mModuleScript = moduleScript; aRequest->mModuleScript = moduleScript;
moduleScript->SetForPreload(aRequest->mLoadContext->IsPreload());
if (!module) { if (!module) {
LOG(("ScriptLoadRequest (%p): compilation failed (%d)", aRequest, LOG(("ScriptLoadRequest (%p): compilation failed (%d)", aRequest,
unsigned(rv))); unsigned(rv)));
@ -782,7 +769,6 @@ ResolveResult ModuleLoaderBase::ResolveModuleSpecifier(
// Import Maps are not supported on workers/worklets. // Import Maps are not supported on workers/worklets.
// See https://github.com/WICG/import-maps/issues/2 // See https://github.com/WICG/import-maps/issues/2
MOZ_ASSERT_IF(!NS_IsMainThread(), mImportMap == nullptr); MOZ_ASSERT_IF(!NS_IsMainThread(), mImportMap == nullptr);
// Forward to the updated 'Resolve a module specifier' algorithm defined in // Forward to the updated 'Resolve a module specifier' algorithm defined in
// the Import Maps spec. // the Import Maps spec.
return ImportMap::ResolveModuleSpecifier(mImportMap.get(), mLoader, aScript, return ImportMap::ResolveModuleSpecifier(mImportMap.get(), mLoader, aScript,
@ -857,7 +843,6 @@ void ModuleLoaderBase::StartFetchingModuleDependencies(
MOZ_ASSERT(visitedSet->Contains(aRequest->mURI)); MOZ_ASSERT(visitedSet->Contains(aRequest->mURI));
aRequest->mState = ModuleLoadRequest::State::LoadingImports; aRequest->mState = ModuleLoadRequest::State::LoadingImports;
aRequest->mModuleScript->SetHadImportMap(HasImportMapRegistered());
nsCOMArray<nsIURI> urls; nsCOMArray<nsIURI> urls;
nsresult rv = ResolveRequestedModules(aRequest, &urls); nsresult rv = ResolveRequestedModules(aRequest, &urls);
@ -1049,9 +1034,9 @@ void ModuleLoaderBase::Shutdown() {
CancelAndClearDynamicImports(); CancelAndClearDynamicImports();
for (const auto& entry : mFetchingModules) { for (const auto& entry : mFetchingModules) {
RefPtr<LoadingRequest> loadingRequest(entry.GetData()); RefPtr<WaitingRequests> waitingRequests(entry.GetData());
if (loadingRequest) { if (waitingRequests) {
ResumeWaitingRequests(loadingRequest, false); ResumeWaitingRequests(waitingRequests, false);
} }
} }
@ -1115,9 +1100,6 @@ JS::Value ModuleLoaderBase::FindFirstParseError(ModuleLoadRequest* aRequest) {
} }
for (ModuleLoadRequest* childRequest : aRequest->mImports) { for (ModuleLoadRequest* childRequest : aRequest->mImports) {
MOZ_DIAGNOSTIC_ASSERT(moduleScript->HadImportMap() ==
childRequest->mModuleScript->HadImportMap());
JS::Value error = FindFirstParseError(childRequest); JS::Value error = FindFirstParseError(childRequest);
if (!error.isUndefined()) { if (!error.isUndefined()) {
return error; return error;
@ -1411,38 +1393,6 @@ void ModuleLoaderBase::RegisterImportMap(UniquePtr<ImportMap> aImportMap) {
// Step 3. Set global's import map to result's import map. // Step 3. Set global's import map to result's import map.
mImportMap = std::move(aImportMap); mImportMap = std::move(aImportMap);
// Any import resolution has been invalidated by the addition of the import
// map. If speculative preloading is currently fetching any modules then
// cancel their requests and remove them from the map.
//
// The cancelled requests will still complete later so we have to check this
// in SetModuleFetchFinishedAndResumeWaitingRequests.
for (const auto& entry : mFetchingModules) {
LoadingRequest* loadingRequest = entry.GetData();
MOZ_DIAGNOSTIC_ASSERT(loadingRequest->mRequest->mLoadContext->IsPreload());
loadingRequest->mRequest->Cancel();
for (const auto& request : loadingRequest->mWaiting) {
MOZ_DIAGNOSTIC_ASSERT(request->mLoadContext->IsPreload());
request->Cancel();
}
}
mFetchingModules.Clear();
// If speculative preloading has added modules to the module map, remove
// them.
for (const auto& entry : mFetchedModules) {
ModuleScript* script = entry.GetData();
if (script) {
MOZ_DIAGNOSTIC_ASSERT(script->ForPreload());
MOZ_DIAGNOSTIC_ASSERT(!script->HadImportMap());
if (JSObject* module = script->ModuleRecord()) {
MOZ_DIAGNOSTIC_ASSERT(!JS::ModuleIsLinked(module));
}
script->Shutdown();
}
}
mFetchedModules.Clear();
} }
void ModuleLoaderBase::CopyModulesTo(ModuleLoaderBase* aDest) { void ModuleLoaderBase::CopyModulesTo(ModuleLoaderBase* aDest) {

Просмотреть файл

@ -165,30 +165,20 @@ class ScriptLoaderInterface : public nsISupports {
*/ */
class ModuleLoaderBase : public nsISupports { class ModuleLoaderBase : public nsISupports {
/* /*
* Represents an ongoing load operation for a URI initiated for one request * The set of requests that are waiting for an ongoing fetch to complete.
* and which may have other requests waiting for it to complete.
*
* These are tracked in the mFetchingModules map.
*/ */
class LoadingRequest final : public nsISupports { class WaitingRequests final : public nsISupports {
virtual ~LoadingRequest() = default; virtual ~WaitingRequests() = default;
public: public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(LoadingRequest) NS_DECL_CYCLE_COLLECTION_CLASS(WaitingRequests)
// The request that initiated the load and which is currently fetching or
// being compiled.
RefPtr<ModuleLoadRequest> mRequest;
// A list of any other requests for the same URI that are waiting for the
// initial load to complete. These will be resumed by ResumeWaitingRequests
// when that happens.
nsTArray<RefPtr<ModuleLoadRequest>> mWaiting; nsTArray<RefPtr<ModuleLoadRequest>> mWaiting;
}; };
// Module map // Module map
nsRefPtrHashtable<nsURIHashKey, LoadingRequest> mFetchingModules; nsRefPtrHashtable<nsURIHashKey, WaitingRequests> mFetchingModules;
nsRefPtrHashtable<nsURIHashKey, ModuleScript> mFetchedModules; nsRefPtrHashtable<nsURIHashKey, ModuleScript> mFetchedModules;
// List of dynamic imports that are currently being loaded. // List of dynamic imports that are currently being loaded.
@ -431,7 +421,7 @@ class ModuleLoaderBase : public nsISupports {
void SetModuleFetchFinishedAndResumeWaitingRequests( void SetModuleFetchFinishedAndResumeWaitingRequests(
ModuleLoadRequest* aRequest, nsresult aResult); ModuleLoadRequest* aRequest, nsresult aResult);
void ResumeWaitingRequests(LoadingRequest* aLoadingRequest, bool aSuccess); void ResumeWaitingRequests(WaitingRequests* aWaitingRequests, bool aSuccess);
void ResumeWaitingRequest(ModuleLoadRequest* aRequest, bool aSuccess); void ResumeWaitingRequest(ModuleLoadRequest* aRequest, bool aSuccess);
void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest); void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);

Просмотреть файл

@ -299,8 +299,6 @@ extern JS_PUBLIC_API JSObject* GetModuleEnvironment(
*/ */
extern JS_PUBLIC_API void ClearModuleEnvironment(JSObject* moduleObj); extern JS_PUBLIC_API void ClearModuleEnvironment(JSObject* moduleObj);
extern JS_PUBLIC_API bool ModuleIsLinked(JSObject* moduleObj);
} // namespace JS } // namespace JS
#endif // js_Modules_h #endif // js_Modules_h

Просмотреть файл

@ -327,11 +327,6 @@ JS_PUBLIC_API void JS::ClearModuleEnvironment(JSObject* moduleObj) {
} }
} }
JS_PUBLIC_API bool JS::ModuleIsLinked(JSObject* moduleObj) {
AssertHeapIsIdle();
return moduleObj->as<ModuleObject>().status() != ModuleStatus::Unlinked;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Internal implementation // Internal implementation