mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
The array's length is supposed to be a multiple of two for dynamic import callbacks. Fixes: https://github.com/nodejs/node/issues/50700 PR-URL: https://github.com/nodejs/node/pull/50703 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
import '../common/index.mjs';
|
|
import { rejects } from 'assert';
|
|
|
|
const jsModuleDataUrl = 'data:text/javascript,export{}';
|
|
const jsonModuleDataUrl = 'data:application/json,""';
|
|
|
|
await rejects(
|
|
// This rejects because of the unsupported MIME type, not because of the
|
|
// unsupported assertion.
|
|
import('data:text/css,', { with: { type: 'css' } }),
|
|
{ code: 'ERR_UNKNOWN_MODULE_FORMAT' }
|
|
);
|
|
|
|
await rejects(
|
|
import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsModuleDataUrl, { with: { type: 'json' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
|
|
);
|
|
|
|
await rejects(
|
|
import(import.meta.url, { with: { type: 'unsupported' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsonModuleDataUrl),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsonModuleDataUrl, { with: {} }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsonModuleDataUrl, { with: { foo: 'bar' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsonModuleDataUrl, { with: { type: 'unsupported' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
|
|
);
|