()
| 11 | // callback. |
| 12 | |
| 13 | async function testScript() { |
| 14 | const ctx = createContext(); |
| 15 | |
| 16 | const mod1 = new SourceTextModule('export const a = 1;', { |
| 17 | context: ctx, |
| 18 | }); |
| 19 | // No import statements, so must not link statically. |
| 20 | await mod1.link(common.mustNotCall()); |
| 21 | |
| 22 | const script2 = new Script(` |
| 23 | const promise = import("mod1"); |
| 24 | if (Object.getPrototypeOf(promise) !== Promise.prototype) { |
| 25 | throw new Error('Expected promise to be created in the current context'); |
| 26 | } |
| 27 | globalThis.__result = promise; |
| 28 | `, { |
| 29 | importModuleDynamically: common.mustCall((specifier, referrer) => { |
| 30 | assert.strictEqual(specifier, 'mod1'); |
| 31 | assert.strictEqual(referrer, script2); |
| 32 | return mod1; |
| 33 | }), |
| 34 | }); |
| 35 | script2.runInContext(ctx); |
| 36 | |
| 37 | // Wait for the promise to resolve. |
| 38 | await ctx.__result; |
| 39 | } |
| 40 | |
| 41 | async function testScriptImportFailed() { |
| 42 | const ctx = createContext(); |
no test coverage detected
searching dependent graphs…