1import '../common/index.mjs'; 2import { rejects } from 'assert'; 3 4const jsModuleDataUrl = 'data:text/javascript,export{}'; 5const jsonModuleDataUrl = 'data:application/json,""'; 6 7await rejects( 8 // This rejects because of the unsupported MIME type, not because of the 9 // unsupported assertion. 10 import('data:text/css,', { with: { type: 'css' } }), 11 { code: 'ERR_UNKNOWN_MODULE_FORMAT' } 12); 13 14await rejects( 15 import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`), 16 { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 17); 18 19await rejects( 20 import(jsModuleDataUrl, { with: { type: 'json' } }), 21 { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 22); 23 24await rejects( 25 import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }), 26 { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 27); 28 29await rejects( 30 import(import.meta.url, { with: { type: 'unsupported' } }), 31 { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 32); 33 34await rejects( 35 import(jsonModuleDataUrl), 36 { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 37); 38 39await rejects( 40 import(jsonModuleDataUrl, { with: {} }), 41 { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 42); 43 44await rejects( 45 import(jsonModuleDataUrl, { with: { foo: 'bar' } }), 46 { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 47); 48 49await rejects( 50 import(jsonModuleDataUrl, { with: { type: 'unsupported' } }), 51 { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 52); 53