diff options
author | Moonchild <moonchild@palemoon.org> | 2020-11-27 15:47:49 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-11-27 15:47:49 +0000 |
commit | d218beb6405220816f4340b2b08db6db7ed7e4ac (patch) | |
tree | 80562c8ff9e25d119fde8725fa89d171ef20bb42 /dom | |
parent | b267ce3a5eb0a22cb7c8774badb1f71f4f7d5ff3 (diff) | |
download | uxp-d218beb6405220816f4340b2b08db6db7ed7e4ac.tar.gz |
Issue mcp-graveyard/UXP#1691 - Part 1: Provide a way of associating a private value with a script
or module.
This is a prerequisite for dynamic import
Diffstat (limited to 'dom')
-rw-r--r-- | dom/script/ModuleScript.cpp | 6 | ||||
-rw-r--r-- | dom/script/ScriptLoader.cpp | 8 | ||||
-rw-r--r-- | dom/script/ScriptLoader.h | 5 |
3 files changed, 10 insertions, 9 deletions
diff --git a/dom/script/ModuleScript.cpp b/dom/script/ModuleScript.cpp index 9f7fe9ab92..b2a72e6287 100644 --- a/dom/script/ModuleScript.cpp +++ b/dom/script/ModuleScript.cpp @@ -58,9 +58,9 @@ ModuleScript::UnlinkModuleRecord() { // Remove module's back reference to this object request if present. if (mModuleRecord) { - MOZ_ASSERT(JS::GetModuleHostDefinedField(mModuleRecord).toPrivate() == + MOZ_ASSERT(JS::GetModulePrivate(mModuleRecord).toPrivate() == this); - JS::SetModuleHostDefinedField(mModuleRecord, JS::UndefinedValue()); + JS::SetModulePrivate(mModuleRecord, JS::UndefinedValue()); mModuleRecord = nullptr; } } @@ -83,7 +83,7 @@ ModuleScript::SetModuleRecord(JS::Handle<JSObject*> aModuleRecord) // Make module's host defined field point to this module script object. // This is cleared in the UnlinkModuleRecord(). - JS::SetModuleHostDefinedField(mModuleRecord, JS::PrivateValue(this)); + JS::SetModulePrivate(mModuleRecord, JS::PrivateValue(this)); HoldJSObjects(this); } diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 5b7bea8d22..8058c8caa7 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -798,13 +798,13 @@ ScriptLoader::StartFetchingModuleAndDependencies(ModuleLoadRequest* aParent, // 8.1.3.8.1 HostResolveImportedModule(referencingModule, specifier) JSObject* -HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule, +HostResolveImportedModule(JSContext* aCx, + JS::Handle<JS::Value> aReferencingPrivate, JS::Handle<JSString*> aSpecifier) { // Let referencing module script be referencingModule.[[HostDefined]]. - JS::Value value = JS::GetModuleHostDefinedField(aModule); - auto script = static_cast<ModuleScript*>(value.toPrivate()); - MOZ_ASSERT(script->ModuleRecord() == aModule); + auto script = static_cast<ModuleScript*>(aReferencingPrivate.toPrivate()); + MOZ_ASSERT(JS::GetModulePrivate(script->ModuleRecord()) == aReferencingPrivate); // Let url be the result of resolving a module specifier given referencing // module script and specifier. diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h index ec9524f14a..8cbcf7b966 100644 --- a/dom/script/ScriptLoader.h +++ b/dom/script/ScriptLoader.h @@ -630,8 +630,9 @@ private: ModuleScript* GetFetchedModule(nsIURI* aURL) const; friend JSObject* - HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule, - JS::Handle<JSString*> aSpecifier); + HostResolveImportedModule(JSContext* aCx, + JS::Handle<JS::Value> aReferencingPrivate, + JS::Handle<JSString*> aSpecifier); nsresult CreateModuleScript(ModuleLoadRequest* aRequest); nsresult ProcessFetchedModuleSource(ModuleLoadRequest* aRequest); |