2023-10-14 03:52:38 +00:00
|
|
|
import '../common/index.mjs';
|
2021-08-27 23:47:49 +00:00
|
|
|
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.
|
2023-10-14 03:52:38 +00:00
|
|
|
import('data:text/css,', { with: { type: 'css' } }),
|
2020-11-30 16:03:30 +00:00
|
|
|
{ code: 'ERR_UNKNOWN_MODULE_FORMAT' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(jsModuleDataUrl, { with: { type: 'json' } }),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(import.meta.url, { with: { type: 'unsupported' } }),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
|
|
|
import(jsonModuleDataUrl),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(jsonModuleDataUrl, { with: {} }),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(jsonModuleDataUrl, { with: { foo: 'bar' } }),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await rejects(
|
2023-10-14 03:52:38 +00:00
|
|
|
import(jsonModuleDataUrl, { with: { type: 'unsupported' } }),
|
2023-10-18 14:27:55 +00:00
|
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
|
2021-08-27 23:47:49 +00:00
|
|
|
);
|