mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Evaluate blob module sources under their original URL instead of rewrapping them in a data URL. This preserves import.meta.url and module identity while retaining the captured source after URL revocation. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66354 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
20 lines
659 B
JavaScript
20 lines
659 B
JavaScript
// Flags: --experimental-web-worker
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const assert = require('node:assert');
|
|
const source = `
|
|
import value from 'data:text/javascript,export default 42';
|
|
postMessage([import.meta.url, location.href, value]);
|
|
`;
|
|
const url = URL.createObjectURL(new Blob([source], { type: 'text/javascript' }));
|
|
const worker = new Worker(url, { type: 'module' });
|
|
URL.revokeObjectURL(url);
|
|
worker.onerror = common.mustNotCall('worker failed');
|
|
worker.onmessage = common.mustCall(({ data }) => {
|
|
worker.terminate();
|
|
assert.deepStrictEqual(data, [url, url, 42]);
|
|
});
|