11cb0ef41Sopenharmony_ciimport { spawnPromisified } from '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport * as fixtures from '../common/fixtures.mjs'; 31cb0ef41Sopenharmony_ciimport assert from 'node:assert'; 41cb0ef41Sopenharmony_ciimport { execPath } from 'node:process'; 51cb0ef41Sopenharmony_ciimport { describe, it } from 'node:test'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_cidescribe('Loader hooks', { concurrency: true }, () => { 81cb0ef41Sopenharmony_ci it('are called with all expected arguments', async () => { 91cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 101cb0ef41Sopenharmony_ci '--no-warnings', 111cb0ef41Sopenharmony_ci '--experimental-loader', 121cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/hooks-input.mjs'), 131cb0ef41Sopenharmony_ci fixtures.path('es-modules/json-modules.mjs'), 141cb0ef41Sopenharmony_ci ]); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 171cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 181cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci const lines = stdout.split('\n'); 211cb0ef41Sopenharmony_ci assert.match(lines[0], /{"url":"file:\/\/\/.*\/json-modules\.mjs","format":"test","shortCircuit":true}/); 221cb0ef41Sopenharmony_ci assert.match(lines[1], /{"source":{"type":"Buffer","data":\[.*\]},"format":"module","shortCircuit":true}/); 231cb0ef41Sopenharmony_ci assert.match(lines[2], /{"url":"file:\/\/\/.*\/experimental\.json","format":"test","shortCircuit":true}/); 241cb0ef41Sopenharmony_ci assert.match(lines[3], /{"source":{"type":"Buffer","data":\[.*\]},"format":"json","shortCircuit":true}/); 251cb0ef41Sopenharmony_ci assert.strictEqual(lines[4], ''); 261cb0ef41Sopenharmony_ci assert.strictEqual(lines.length, 5); 271cb0ef41Sopenharmony_ci }); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci it('are called with all expected arguments using register function', async () => { 301cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 311cb0ef41Sopenharmony_ci '--no-warnings', 321cb0ef41Sopenharmony_ci '--experimental-loader=data:text/javascript,', 331cb0ef41Sopenharmony_ci '--input-type=module', 341cb0ef41Sopenharmony_ci '--eval', 351cb0ef41Sopenharmony_ci "import { register } from 'node:module';" + 361cb0ef41Sopenharmony_ci `register(${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-input.mjs'))});` + 371cb0ef41Sopenharmony_ci `await import(${JSON.stringify(fixtures.fileURL('es-modules/json-modules.mjs'))});`, 381cb0ef41Sopenharmony_ci ]); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 411cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 421cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci const lines = stdout.split('\n'); 451cb0ef41Sopenharmony_ci assert.match(lines[0], /{"url":"file:\/\/\/.*\/json-modules\.mjs","format":"test","shortCircuit":true}/); 461cb0ef41Sopenharmony_ci assert.match(lines[1], /{"source":{"type":"Buffer","data":\[.*\]},"format":"module","shortCircuit":true}/); 471cb0ef41Sopenharmony_ci assert.match(lines[2], /{"url":"file:\/\/\/.*\/experimental\.json","format":"test","shortCircuit":true}/); 481cb0ef41Sopenharmony_ci assert.match(lines[3], /{"source":{"type":"Buffer","data":\[.*\]},"format":"json","shortCircuit":true}/); 491cb0ef41Sopenharmony_ci assert.strictEqual(lines[4], ''); 501cb0ef41Sopenharmony_ci assert.strictEqual(lines.length, 5); 511cb0ef41Sopenharmony_ci }); 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci describe('should handle never-settling hooks in ESM files', { concurrency: true }, () => { 541cb0ef41Sopenharmony_ci it('top-level await of a never-settling resolve', async () => { 551cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 561cb0ef41Sopenharmony_ci '--no-warnings', 571cb0ef41Sopenharmony_ci '--experimental-loader', 581cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 591cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/never-resolve.mjs'), 601cb0ef41Sopenharmony_ci ]); 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 631cb0ef41Sopenharmony_ci assert.match(stdout, /^should be output\r?\n$/); 641cb0ef41Sopenharmony_ci assert.strictEqual(code, 13); 651cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 661cb0ef41Sopenharmony_ci }); 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci it('top-level await of a never-settling load', async () => { 691cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 701cb0ef41Sopenharmony_ci '--no-warnings', 711cb0ef41Sopenharmony_ci '--experimental-loader', 721cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 731cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/never-load.mjs'), 741cb0ef41Sopenharmony_ci ]); 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 771cb0ef41Sopenharmony_ci assert.match(stdout, /^should be output\r?\n$/); 781cb0ef41Sopenharmony_ci assert.strictEqual(code, 13); 791cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 801cb0ef41Sopenharmony_ci }); 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci it('top-level await of a race of never-settling hooks', async () => { 841cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 851cb0ef41Sopenharmony_ci '--no-warnings', 861cb0ef41Sopenharmony_ci '--experimental-loader', 871cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 881cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/race.mjs'), 891cb0ef41Sopenharmony_ci ]); 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 921cb0ef41Sopenharmony_ci assert.match(stdout, /^true\r?\n$/); 931cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 941cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 951cb0ef41Sopenharmony_ci }); 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci it('import.meta.resolve of a never-settling resolve', async () => { 981cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 991cb0ef41Sopenharmony_ci '--no-warnings', 1001cb0ef41Sopenharmony_ci '--experimental-loader', 1011cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 1021cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/import.meta.never-resolve.mjs'), 1031cb0ef41Sopenharmony_ci ]); 1041cb0ef41Sopenharmony_ci 1051cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1061cb0ef41Sopenharmony_ci assert.match(stdout, /^should be output\r?\n$/); 1071cb0ef41Sopenharmony_ci assert.strictEqual(code, 13); 1081cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1091cb0ef41Sopenharmony_ci }); 1101cb0ef41Sopenharmony_ci }); 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci describe('should handle never-settling hooks in CJS files', { concurrency: true }, () => { 1131cb0ef41Sopenharmony_ci it('never-settling resolve', async () => { 1141cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1151cb0ef41Sopenharmony_ci '--no-warnings', 1161cb0ef41Sopenharmony_ci '--experimental-loader', 1171cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 1181cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/never-resolve.cjs'), 1191cb0ef41Sopenharmony_ci ]); 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1221cb0ef41Sopenharmony_ci assert.match(stdout, /^should be output\r?\n$/); 1231cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 1241cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1251cb0ef41Sopenharmony_ci }); 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci it('never-settling load', async () => { 1291cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1301cb0ef41Sopenharmony_ci '--no-warnings', 1311cb0ef41Sopenharmony_ci '--experimental-loader', 1321cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 1331cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/never-load.cjs'), 1341cb0ef41Sopenharmony_ci ]); 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1371cb0ef41Sopenharmony_ci assert.match(stdout, /^should be output\r?\n$/); 1381cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 1391cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1401cb0ef41Sopenharmony_ci }); 1411cb0ef41Sopenharmony_ci 1421cb0ef41Sopenharmony_ci it('race of never-settling hooks', async () => { 1431cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1441cb0ef41Sopenharmony_ci '--no-warnings', 1451cb0ef41Sopenharmony_ci '--experimental-loader', 1461cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), 1471cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/never-settling-resolve-step/race.cjs'), 1481cb0ef41Sopenharmony_ci ]); 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1511cb0ef41Sopenharmony_ci assert.match(stdout, /^true\r?\n$/); 1521cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 1531cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1541cb0ef41Sopenharmony_ci }); 1551cb0ef41Sopenharmony_ci }); 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_ci it('should not leak internals or expose import.meta.resolve', async () => { 1581cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1591cb0ef41Sopenharmony_ci '--no-warnings', 1601cb0ef41Sopenharmony_ci '--experimental-loader', 1611cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/loader-edge-cases.mjs'), 1621cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 1631cb0ef41Sopenharmony_ci ]); 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1661cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 1671cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 1681cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1691cb0ef41Sopenharmony_ci }); 1701cb0ef41Sopenharmony_ci 1711cb0ef41Sopenharmony_ci it('should be fine to call `process.exit` from a custom async hook', async () => { 1721cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1731cb0ef41Sopenharmony_ci '--no-warnings', 1741cb0ef41Sopenharmony_ci '--experimental-loader', 1751cb0ef41Sopenharmony_ci 'data:text/javascript,export function load(a,b,next){if(a==="data:exit")process.exit(42);return next(a,b)}', 1761cb0ef41Sopenharmony_ci '--input-type=module', 1771cb0ef41Sopenharmony_ci '--eval', 1781cb0ef41Sopenharmony_ci 'import "data:exit"', 1791cb0ef41Sopenharmony_ci ]); 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1821cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 1831cb0ef41Sopenharmony_ci assert.strictEqual(code, 42); 1841cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 1851cb0ef41Sopenharmony_ci }); 1861cb0ef41Sopenharmony_ci 1871cb0ef41Sopenharmony_ci it('should be fine to call `process.exit` from a custom sync hook', async () => { 1881cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 1891cb0ef41Sopenharmony_ci '--no-warnings', 1901cb0ef41Sopenharmony_ci '--experimental-loader', 1911cb0ef41Sopenharmony_ci 'data:text/javascript,export function resolve(a,b,next){if(a==="exit:")process.exit(42);return next(a,b)}', 1921cb0ef41Sopenharmony_ci '--input-type=module', 1931cb0ef41Sopenharmony_ci '--eval', 1941cb0ef41Sopenharmony_ci 'import "data:text/javascript,import.meta.resolve(%22exit:%22)"', 1951cb0ef41Sopenharmony_ci ]); 1961cb0ef41Sopenharmony_ci 1971cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 1981cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 1991cb0ef41Sopenharmony_ci assert.strictEqual(code, 42); 2001cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2011cb0ef41Sopenharmony_ci }); 2021cb0ef41Sopenharmony_ci 2031cb0ef41Sopenharmony_ci it('should be fine to call `process.exit` from the loader thread top-level', async () => { 2041cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2051cb0ef41Sopenharmony_ci '--no-warnings', 2061cb0ef41Sopenharmony_ci '--experimental-loader', 2071cb0ef41Sopenharmony_ci 'data:text/javascript,process.exit(42)', 2081cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2091cb0ef41Sopenharmony_ci ]); 2101cb0ef41Sopenharmony_ci 2111cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 2121cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2131cb0ef41Sopenharmony_ci assert.strictEqual(code, 42); 2141cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2151cb0ef41Sopenharmony_ci }); 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ci describe('should handle a throwing top-level body', () => { 2181cb0ef41Sopenharmony_ci it('should handle regular Error object', async () => { 2191cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2201cb0ef41Sopenharmony_ci '--no-warnings', 2211cb0ef41Sopenharmony_ci '--experimental-loader', 2221cb0ef41Sopenharmony_ci 'data:text/javascript,throw new Error("error message")', 2231cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2241cb0ef41Sopenharmony_ci ]); 2251cb0ef41Sopenharmony_ci 2261cb0ef41Sopenharmony_ci assert.match(stderr, /Error: error message\r?\n/); 2271cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2281cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2291cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2301cb0ef41Sopenharmony_ci }); 2311cb0ef41Sopenharmony_ci 2321cb0ef41Sopenharmony_ci it('should handle null', async () => { 2331cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2341cb0ef41Sopenharmony_ci '--no-warnings', 2351cb0ef41Sopenharmony_ci '--experimental-loader', 2361cb0ef41Sopenharmony_ci 'data:text/javascript,throw null', 2371cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2381cb0ef41Sopenharmony_ci ]); 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci assert.match(stderr, /\nnull\r?\n/); 2411cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2421cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2431cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2441cb0ef41Sopenharmony_ci }); 2451cb0ef41Sopenharmony_ci 2461cb0ef41Sopenharmony_ci it('should handle undefined', async () => { 2471cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2481cb0ef41Sopenharmony_ci '--no-warnings', 2491cb0ef41Sopenharmony_ci '--experimental-loader', 2501cb0ef41Sopenharmony_ci 'data:text/javascript,throw undefined', 2511cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2521cb0ef41Sopenharmony_ci ]); 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_ci assert.match(stderr, /\nundefined\r?\n/); 2551cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2561cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2571cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2581cb0ef41Sopenharmony_ci }); 2591cb0ef41Sopenharmony_ci 2601cb0ef41Sopenharmony_ci it('should handle boolean', async () => { 2611cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2621cb0ef41Sopenharmony_ci '--no-warnings', 2631cb0ef41Sopenharmony_ci '--experimental-loader', 2641cb0ef41Sopenharmony_ci 'data:text/javascript,throw true', 2651cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2661cb0ef41Sopenharmony_ci ]); 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ci assert.match(stderr, /\ntrue\r?\n/); 2691cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2701cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2711cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2721cb0ef41Sopenharmony_ci }); 2731cb0ef41Sopenharmony_ci 2741cb0ef41Sopenharmony_ci it('should handle empty plain object', async () => { 2751cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2761cb0ef41Sopenharmony_ci '--no-warnings', 2771cb0ef41Sopenharmony_ci '--experimental-loader', 2781cb0ef41Sopenharmony_ci 'data:text/javascript,throw {}', 2791cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2801cb0ef41Sopenharmony_ci ]); 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ci assert.match(stderr, /\n\{\}\r?\n/); 2831cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2841cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2851cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 2861cb0ef41Sopenharmony_ci }); 2871cb0ef41Sopenharmony_ci 2881cb0ef41Sopenharmony_ci it('should handle plain object', async () => { 2891cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 2901cb0ef41Sopenharmony_ci '--no-warnings', 2911cb0ef41Sopenharmony_ci '--experimental-loader', 2921cb0ef41Sopenharmony_ci 'data:text/javascript,throw {fn(){},symbol:Symbol("symbol"),u:undefined}', 2931cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 2941cb0ef41Sopenharmony_ci ]); 2951cb0ef41Sopenharmony_ci 2961cb0ef41Sopenharmony_ci assert.match(stderr, /\n\{ fn: \[Function: fn\], symbol: Symbol\(symbol\), u: undefined \}\r?\n/); 2971cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 2981cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 2991cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3001cb0ef41Sopenharmony_ci }); 3011cb0ef41Sopenharmony_ci 3021cb0ef41Sopenharmony_ci it('should handle number', async () => { 3031cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 3041cb0ef41Sopenharmony_ci '--no-warnings', 3051cb0ef41Sopenharmony_ci '--experimental-loader', 3061cb0ef41Sopenharmony_ci 'data:text/javascript,throw 1', 3071cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3081cb0ef41Sopenharmony_ci ]); 3091cb0ef41Sopenharmony_ci 3101cb0ef41Sopenharmony_ci assert.match(stderr, /\n1\r?\n/); 3111cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3121cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 3131cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3141cb0ef41Sopenharmony_ci }); 3151cb0ef41Sopenharmony_ci 3161cb0ef41Sopenharmony_ci it('should handle bigint', async () => { 3171cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 3181cb0ef41Sopenharmony_ci '--no-warnings', 3191cb0ef41Sopenharmony_ci '--experimental-loader', 3201cb0ef41Sopenharmony_ci 'data:text/javascript,throw 1n', 3211cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3221cb0ef41Sopenharmony_ci ]); 3231cb0ef41Sopenharmony_ci 3241cb0ef41Sopenharmony_ci assert.match(stderr, /\n1\r?\n/); 3251cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3261cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 3271cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3281cb0ef41Sopenharmony_ci }); 3291cb0ef41Sopenharmony_ci 3301cb0ef41Sopenharmony_ci it('should handle string', async () => { 3311cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 3321cb0ef41Sopenharmony_ci '--no-warnings', 3331cb0ef41Sopenharmony_ci '--experimental-loader', 3341cb0ef41Sopenharmony_ci 'data:text/javascript,throw "literal string"', 3351cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3361cb0ef41Sopenharmony_ci ]); 3371cb0ef41Sopenharmony_ci 3381cb0ef41Sopenharmony_ci assert.match(stderr, /\nliteral string\r?\n/); 3391cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3401cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 3411cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3421cb0ef41Sopenharmony_ci }); 3431cb0ef41Sopenharmony_ci 3441cb0ef41Sopenharmony_ci it('should handle symbol', async () => { 3451cb0ef41Sopenharmony_ci const { code, signal, stdout } = await spawnPromisified(execPath, [ 3461cb0ef41Sopenharmony_ci '--experimental-loader', 3471cb0ef41Sopenharmony_ci 'data:text/javascript,throw Symbol("symbol descriptor")', 3481cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3491cb0ef41Sopenharmony_ci ]); 3501cb0ef41Sopenharmony_ci 3511cb0ef41Sopenharmony_ci // Throwing a symbol doesn't produce any output 3521cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3531cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 3541cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3551cb0ef41Sopenharmony_ci }); 3561cb0ef41Sopenharmony_ci 3571cb0ef41Sopenharmony_ci it('should handle function', async () => { 3581cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 3591cb0ef41Sopenharmony_ci '--no-warnings', 3601cb0ef41Sopenharmony_ci '--experimental-loader', 3611cb0ef41Sopenharmony_ci 'data:text/javascript,throw function fnName(){}', 3621cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3631cb0ef41Sopenharmony_ci ]); 3641cb0ef41Sopenharmony_ci 3651cb0ef41Sopenharmony_ci assert.match(stderr, /\n\[Function: fnName\]\r?\n/); 3661cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3671cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 3681cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 3691cb0ef41Sopenharmony_ci }); 3701cb0ef41Sopenharmony_ci }); 3711cb0ef41Sopenharmony_ci 3721cb0ef41Sopenharmony_ci describe('globalPreload', () => { 3731cb0ef41Sopenharmony_ci it('should emit warning', async () => { 3741cb0ef41Sopenharmony_ci const { stderr } = await spawnPromisified(execPath, [ 3751cb0ef41Sopenharmony_ci '--experimental-loader', 3761cb0ef41Sopenharmony_ci 'data:text/javascript,export function globalPreload(){}', 3771cb0ef41Sopenharmony_ci '--experimental-loader', 3781cb0ef41Sopenharmony_ci 'data:text/javascript,export function globalPreload(){return""}', 3791cb0ef41Sopenharmony_ci fixtures.path('empty.js'), 3801cb0ef41Sopenharmony_ci ]); 3811cb0ef41Sopenharmony_ci 3821cb0ef41Sopenharmony_ci assert.strictEqual(stderr.match(/`globalPreload` is an experimental feature/g).length, 1); 3831cb0ef41Sopenharmony_ci }); 3841cb0ef41Sopenharmony_ci }); 3851cb0ef41Sopenharmony_ci 3861cb0ef41Sopenharmony_ci it('should be fine to call `process.removeAllListeners("beforeExit")` from the main thread', async () => { 3871cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 3881cb0ef41Sopenharmony_ci '--no-warnings', 3891cb0ef41Sopenharmony_ci '--experimental-loader', 3901cb0ef41Sopenharmony_ci 'data:text/javascript,export function load(a,b,c){return new Promise(d=>setTimeout(()=>d(c(a,b)),99))}', 3911cb0ef41Sopenharmony_ci '--input-type=module', 3921cb0ef41Sopenharmony_ci '--eval', 3931cb0ef41Sopenharmony_ci 'setInterval(() => process.removeAllListeners("beforeExit"),1).unref();await import("data:text/javascript,")', 3941cb0ef41Sopenharmony_ci ]); 3951cb0ef41Sopenharmony_ci 3961cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 3971cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 3981cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 3991cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 4001cb0ef41Sopenharmony_ci }); 4011cb0ef41Sopenharmony_ci 4021cb0ef41Sopenharmony_ci describe('`initialize`/`register`', () => { 4031cb0ef41Sopenharmony_ci it('should invoke `initialize` correctly', async () => { 4041cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 4051cb0ef41Sopenharmony_ci '--no-warnings', 4061cb0ef41Sopenharmony_ci '--experimental-loader', 4071cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'), 4081cb0ef41Sopenharmony_ci '--input-type=module', 4091cb0ef41Sopenharmony_ci '--eval', 4101cb0ef41Sopenharmony_ci 'import os from "node:os";', 4111cb0ef41Sopenharmony_ci ]); 4121cb0ef41Sopenharmony_ci 4131cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 4141cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n'), ['hooks initialize 1', '']); 4151cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 4161cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 4171cb0ef41Sopenharmony_ci }); 4181cb0ef41Sopenharmony_ci 4191cb0ef41Sopenharmony_ci it('should allow communicating with loader via `register` ports', async () => { 4201cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 4211cb0ef41Sopenharmony_ci '--no-warnings', 4221cb0ef41Sopenharmony_ci '--input-type=module', 4231cb0ef41Sopenharmony_ci '--eval', 4241cb0ef41Sopenharmony_ci ` 4251cb0ef41Sopenharmony_ci import {MessageChannel} from 'node:worker_threads'; 4261cb0ef41Sopenharmony_ci import {register} from 'node:module'; 4271cb0ef41Sopenharmony_ci import {once} from 'node:events'; 4281cb0ef41Sopenharmony_ci const {port1, port2} = new MessageChannel(); 4291cb0ef41Sopenharmony_ci port1.on('message', (msg) => { 4301cb0ef41Sopenharmony_ci console.log('message', msg); 4311cb0ef41Sopenharmony_ci }); 4321cb0ef41Sopenharmony_ci const result = register( 4331cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize-port.mjs'))}, 4341cb0ef41Sopenharmony_ci {data: port2, transferList: [port2]}, 4351cb0ef41Sopenharmony_ci ); 4361cb0ef41Sopenharmony_ci console.log('register', result); 4371cb0ef41Sopenharmony_ci 4381cb0ef41Sopenharmony_ci const timeout = setTimeout(() => {}, 2**31 - 1); // to keep the process alive. 4391cb0ef41Sopenharmony_ci await Promise.all([ 4401cb0ef41Sopenharmony_ci once(port1, 'message').then(() => once(port1, 'message')), 4411cb0ef41Sopenharmony_ci import('node:os'), 4421cb0ef41Sopenharmony_ci ]); 4431cb0ef41Sopenharmony_ci clearTimeout(timeout); 4441cb0ef41Sopenharmony_ci port1.close(); 4451cb0ef41Sopenharmony_ci `, 4461cb0ef41Sopenharmony_ci ]); 4471cb0ef41Sopenharmony_ci 4481cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 4491cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n'), [ 'register undefined', 4501cb0ef41Sopenharmony_ci 'message initialize', 4511cb0ef41Sopenharmony_ci 'message resolve node:os', 4521cb0ef41Sopenharmony_ci '' ]); 4531cb0ef41Sopenharmony_ci 4541cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 4551cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 4561cb0ef41Sopenharmony_ci }); 4571cb0ef41Sopenharmony_ci 4581cb0ef41Sopenharmony_ci it('should have `register` accept URL objects as `parentURL`', async () => { 4591cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 4601cb0ef41Sopenharmony_ci '--no-warnings', 4611cb0ef41Sopenharmony_ci '--import', 4621cb0ef41Sopenharmony_ci `data:text/javascript,${encodeURIComponent( 4631cb0ef41Sopenharmony_ci 'import{ register } from "node:module";' + 4641cb0ef41Sopenharmony_ci 'import { pathToFileURL } from "node:url";' + 4651cb0ef41Sopenharmony_ci 'register("./hooks-initialize.mjs", pathToFileURL("./"));' 4661cb0ef41Sopenharmony_ci )}`, 4671cb0ef41Sopenharmony_ci '--input-type=module', 4681cb0ef41Sopenharmony_ci '--eval', 4691cb0ef41Sopenharmony_ci ` 4701cb0ef41Sopenharmony_ci import {register} from 'node:module'; 4711cb0ef41Sopenharmony_ci register( 4721cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/loader-load-foo-or-42.mjs'))}, 4731cb0ef41Sopenharmony_ci new URL('data:'), 4741cb0ef41Sopenharmony_ci ); 4751cb0ef41Sopenharmony_ci 4761cb0ef41Sopenharmony_ci import('node:os').then((result) => { 4771cb0ef41Sopenharmony_ci console.log(JSON.stringify(result)); 4781cb0ef41Sopenharmony_ci }); 4791cb0ef41Sopenharmony_ci `, 4801cb0ef41Sopenharmony_ci ], { cwd: fixtures.fileURL('es-module-loaders/') }); 4811cb0ef41Sopenharmony_ci 4821cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 4831cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n').sort(), ['hooks initialize 1', '{"default":"foo"}', ''].sort()); 4841cb0ef41Sopenharmony_ci 4851cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 4861cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 4871cb0ef41Sopenharmony_ci }); 4881cb0ef41Sopenharmony_ci 4891cb0ef41Sopenharmony_ci it('should have `register` work with cjs', async () => { 4901cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 4911cb0ef41Sopenharmony_ci '--no-warnings', 4921cb0ef41Sopenharmony_ci '--input-type=commonjs', 4931cb0ef41Sopenharmony_ci '--eval', 4941cb0ef41Sopenharmony_ci ` 4951cb0ef41Sopenharmony_ci 'use strict'; 4961cb0ef41Sopenharmony_ci const {register} = require('node:module'); 4971cb0ef41Sopenharmony_ci register( 4981cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'))}, 4991cb0ef41Sopenharmony_ci ); 5001cb0ef41Sopenharmony_ci register( 5011cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/loader-load-foo-or-42.mjs'))}, 5021cb0ef41Sopenharmony_ci ); 5031cb0ef41Sopenharmony_ci 5041cb0ef41Sopenharmony_ci import('node:os').then((result) => { 5051cb0ef41Sopenharmony_ci console.log(JSON.stringify(result)); 5061cb0ef41Sopenharmony_ci }); 5071cb0ef41Sopenharmony_ci `, 5081cb0ef41Sopenharmony_ci ]); 5091cb0ef41Sopenharmony_ci 5101cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 5111cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n').sort(), ['hooks initialize 1', '{"default":"foo"}', ''].sort()); 5121cb0ef41Sopenharmony_ci 5131cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 5141cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 5151cb0ef41Sopenharmony_ci }); 5161cb0ef41Sopenharmony_ci 5171cb0ef41Sopenharmony_ci it('`register` should work with `require`', async () => { 5181cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 5191cb0ef41Sopenharmony_ci '--no-warnings', 5201cb0ef41Sopenharmony_ci '--require', 5211cb0ef41Sopenharmony_ci fixtures.path('es-module-loaders/register-loader.cjs'), 5221cb0ef41Sopenharmony_ci '--input-type=module', 5231cb0ef41Sopenharmony_ci '--eval', 5241cb0ef41Sopenharmony_ci 'import "node:os";', 5251cb0ef41Sopenharmony_ci ]); 5261cb0ef41Sopenharmony_ci 5271cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 5281cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n'), ['resolve passthru', 'resolve passthru', '']); 5291cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 5301cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 5311cb0ef41Sopenharmony_ci }); 5321cb0ef41Sopenharmony_ci 5331cb0ef41Sopenharmony_ci it('`register` should work with `import`', async () => { 5341cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 5351cb0ef41Sopenharmony_ci '--no-warnings', 5361cb0ef41Sopenharmony_ci '--import', 5371cb0ef41Sopenharmony_ci fixtures.fileURL('es-module-loaders/register-loader.mjs'), 5381cb0ef41Sopenharmony_ci '--input-type=module', 5391cb0ef41Sopenharmony_ci '--eval', 5401cb0ef41Sopenharmony_ci 'import "node:os"', 5411cb0ef41Sopenharmony_ci ]); 5421cb0ef41Sopenharmony_ci 5431cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 5441cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n'), ['resolve passthru', '']); 5451cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 5461cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 5471cb0ef41Sopenharmony_ci }); 5481cb0ef41Sopenharmony_ci 5491cb0ef41Sopenharmony_ci it('should execute `initialize` in sequence', async () => { 5501cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 5511cb0ef41Sopenharmony_ci '--no-warnings', 5521cb0ef41Sopenharmony_ci '--input-type=module', 5531cb0ef41Sopenharmony_ci '--eval', 5541cb0ef41Sopenharmony_ci ` 5551cb0ef41Sopenharmony_ci import {register} from 'node:module'; 5561cb0ef41Sopenharmony_ci console.log('result 1', register( 5571cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'))} 5581cb0ef41Sopenharmony_ci )); 5591cb0ef41Sopenharmony_ci console.log('result 2', register( 5601cb0ef41Sopenharmony_ci ${JSON.stringify(fixtures.fileURL('es-module-loaders/hooks-initialize.mjs'))} 5611cb0ef41Sopenharmony_ci )); 5621cb0ef41Sopenharmony_ci 5631cb0ef41Sopenharmony_ci await import('node:os'); 5641cb0ef41Sopenharmony_ci `, 5651cb0ef41Sopenharmony_ci ]); 5661cb0ef41Sopenharmony_ci 5671cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 5681cb0ef41Sopenharmony_ci assert.deepStrictEqual(stdout.split('\n'), [ 'hooks initialize 1', 5691cb0ef41Sopenharmony_ci 'result 1 undefined', 5701cb0ef41Sopenharmony_ci 'hooks initialize 2', 5711cb0ef41Sopenharmony_ci 'result 2 undefined', 5721cb0ef41Sopenharmony_ci '' ]); 5731cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 5741cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 5751cb0ef41Sopenharmony_ci }); 5761cb0ef41Sopenharmony_ci 5771cb0ef41Sopenharmony_ci it('should handle `initialize` returning never-settling promise', async () => { 5781cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 5791cb0ef41Sopenharmony_ci '--no-warnings', 5801cb0ef41Sopenharmony_ci '--input-type=module', 5811cb0ef41Sopenharmony_ci '--eval', 5821cb0ef41Sopenharmony_ci ` 5831cb0ef41Sopenharmony_ci import {register} from 'node:module'; 5841cb0ef41Sopenharmony_ci register('data:text/javascript,export function initialize(){return new Promise(()=>{})}'); 5851cb0ef41Sopenharmony_ci `, 5861cb0ef41Sopenharmony_ci ]); 5871cb0ef41Sopenharmony_ci 5881cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 5891cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 5901cb0ef41Sopenharmony_ci assert.strictEqual(code, 13); 5911cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 5921cb0ef41Sopenharmony_ci }); 5931cb0ef41Sopenharmony_ci 5941cb0ef41Sopenharmony_ci it('should handle `initialize` returning rejecting promise', async () => { 5951cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 5961cb0ef41Sopenharmony_ci '--no-warnings', 5971cb0ef41Sopenharmony_ci '--input-type=module', 5981cb0ef41Sopenharmony_ci '--eval', 5991cb0ef41Sopenharmony_ci ` 6001cb0ef41Sopenharmony_ci import {register} from 'node:module'; 6011cb0ef41Sopenharmony_ci register('data:text/javascript,export function initialize(){return Promise.reject()}'); 6021cb0ef41Sopenharmony_ci `, 6031cb0ef41Sopenharmony_ci ]); 6041cb0ef41Sopenharmony_ci 6051cb0ef41Sopenharmony_ci assert.match(stderr, /undefined\r?\n/); 6061cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 6071cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 6081cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 6091cb0ef41Sopenharmony_ci }); 6101cb0ef41Sopenharmony_ci 6111cb0ef41Sopenharmony_ci it('should handle `initialize` throwing null', async () => { 6121cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 6131cb0ef41Sopenharmony_ci '--no-warnings', 6141cb0ef41Sopenharmony_ci '--input-type=module', 6151cb0ef41Sopenharmony_ci '--eval', 6161cb0ef41Sopenharmony_ci ` 6171cb0ef41Sopenharmony_ci import {register} from 'node:module'; 6181cb0ef41Sopenharmony_ci register('data:text/javascript,export function initialize(){throw null}'); 6191cb0ef41Sopenharmony_ci `, 6201cb0ef41Sopenharmony_ci ]); 6211cb0ef41Sopenharmony_ci 6221cb0ef41Sopenharmony_ci assert.match(stderr, /null\r?\n/); 6231cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 6241cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 6251cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 6261cb0ef41Sopenharmony_ci }); 6271cb0ef41Sopenharmony_ci 6281cb0ef41Sopenharmony_ci it('should be fine to call `process.exit` from a initialize hook', async () => { 6291cb0ef41Sopenharmony_ci const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ 6301cb0ef41Sopenharmony_ci '--no-warnings', 6311cb0ef41Sopenharmony_ci '--input-type=module', 6321cb0ef41Sopenharmony_ci '--eval', 6331cb0ef41Sopenharmony_ci ` 6341cb0ef41Sopenharmony_ci import {register} from 'node:module'; 6351cb0ef41Sopenharmony_ci register('data:text/javascript,export function initialize(){process.exit(42);}'); 6361cb0ef41Sopenharmony_ci `, 6371cb0ef41Sopenharmony_ci ]); 6381cb0ef41Sopenharmony_ci 6391cb0ef41Sopenharmony_ci assert.strictEqual(stderr, ''); 6401cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 6411cb0ef41Sopenharmony_ci assert.strictEqual(code, 42); 6421cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 6431cb0ef41Sopenharmony_ci }); 6441cb0ef41Sopenharmony_ci }); 6451cb0ef41Sopenharmony_ci}); 646