xref: /third_party/node/test/parallel/test-vm-module-dynamic-namespace.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Flags: --experimental-vm-modules
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst { types } = require('util');
101cb0ef41Sopenharmony_ciconst { SourceTextModule } = require('vm');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci(async () => {
131cb0ef41Sopenharmony_ci  const m = new SourceTextModule('globalThis.importResult = import("");', {
141cb0ef41Sopenharmony_ci    importModuleDynamically: common.mustCall(async (specifier, wrap) => {
151cb0ef41Sopenharmony_ci      const m = new SourceTextModule('');
161cb0ef41Sopenharmony_ci      await m.link(() => 0);
171cb0ef41Sopenharmony_ci      await m.evaluate();
181cb0ef41Sopenharmony_ci      return m.namespace;
191cb0ef41Sopenharmony_ci    }),
201cb0ef41Sopenharmony_ci  });
211cb0ef41Sopenharmony_ci  await m.link(() => 0);
221cb0ef41Sopenharmony_ci  await m.evaluate();
231cb0ef41Sopenharmony_ci  const ns = await globalThis.importResult;
241cb0ef41Sopenharmony_ci  delete globalThis.importResult;
251cb0ef41Sopenharmony_ci  assert.ok(types.isModuleNamespaceObject(ns));
261cb0ef41Sopenharmony_ci})().then(common.mustCall());
27

Indexes created Thu Nov 07 10:32:03 CST 2024