mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 19:47:32 +09:00
Issue #1691 - Part 3: Finish implementing import meta. https://bugzilla.mozilla.org/show_bug.cgi?id=1427610
(cherry picked from commit a8625238ac846fb7eb103646ddb8634a5860f067)
This commit is contained in:
parent
a8ab41b4c6
commit
3f4985ce6c
18 changed files with 207 additions and 9 deletions
|
|
@ -4102,6 +4102,23 @@ ShellGetModulePrivate(JSContext* cx, unsigned argc, Value* vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
ShellModuleMetadataHook(JSContext* cx, HandleObject module, HandleObject metaObject)
|
||||
{
|
||||
// For the shell, just use the script's filename as the base URL.
|
||||
RootedScript script(cx, module->as<ModuleObject>().script());
|
||||
const char* filename = script->scriptSource()->filename();
|
||||
MOZ_ASSERT(filename);
|
||||
|
||||
RootedString url(cx, NewStringCopyZ<CanGC>(cx, filename));
|
||||
if (!url)
|
||||
return false;
|
||||
|
||||
if (!JS_DefineProperty(cx, metaObject, "url", url, JSPROP_ENUMERATE))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetModuleLoadPath(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
|
|
@ -8038,6 +8055,7 @@ main(int argc, char** argv, char** envp)
|
|||
js::SetPreserveWrapperCallback(cx, DummyPreserveWrapperCallback);
|
||||
|
||||
JS::SetModuleResolveHook(cx->runtime(), CallModuleResolveHook);
|
||||
JS::SetModuleMetadataHook(cx, ShellModuleMetadataHook);
|
||||
|
||||
result = Shell(cx, &op, envp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue