Bug 1775424 - Part 1: Impl import.meta.resolve() on browser. r=jonco,yulia

Define 'resolve()' function on import.meta object on browser.

Add mochitests for import.meta.resolve, as some of the wpt tests for
import.meta.resolve cannot be run due to some bugs in wpt testing framework.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1785806

Differential Revision: https://phabricator.services.mozilla.com/D154105
This commit is contained in:
Yoshi Cheng-Hao Huang
2022-08-29 18:12:09 +00:00
parent cebe260e2c
commit 57df0b7fee
8 changed files with 220 additions and 22 deletions

View File

@@ -296,6 +296,10 @@ class ModuleLoaderBase : public nsISupports {
static bool HostPopulateImportMeta(JSContext* aCx,
JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSObject*> aMetaObject);
static bool ImportMetaResolve(JSContext* cx, unsigned argc, Value* vp);
static JSString* ImportMetaResolveImpl(
JSContext* aCx, JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSString*> aSpecifier);
static bool HostImportModuleDynamically(
JSContext* aCx, JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSObject*> aModuleRequest, JS::Handle<JSObject*> aPromise);
@@ -378,6 +382,14 @@ class ModuleLoaderBase : public nsISupports {
nsresult CreateModuleScript(ModuleLoadRequest* aRequest);
// The slot stored in ImportMetaResolve function.
enum { ModulePrivateSlot = 0, SlotCount };
// The number of args in ImportMetaResolve.
static const uint32_t ImportMetaResolveNumArgs = 1;
// The index of the 'specifier' argument in ImportMetaResolve.
static const uint32_t ImportMetaResolveSpecifierArg = 0;
public:
static mozilla::LazyLogModule gCspPRLog;
static mozilla::LazyLogModule gModuleLoaderBaseLog;