11cb0ef41Sopenharmony_ciimport '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport { rejects } from 'assert'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst jsModuleDataUrl = 'data:text/javascript,export{}'; 51cb0ef41Sopenharmony_ciconst jsonModuleDataUrl = 'data:application/json,""'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciawait rejects( 81cb0ef41Sopenharmony_ci // This rejects because of the unsupported MIME type, not because of the 91cb0ef41Sopenharmony_ci // unsupported assertion. 101cb0ef41Sopenharmony_ci import('data:text/css,', { with: { type: 'css' } }), 111cb0ef41Sopenharmony_ci { code: 'ERR_UNKNOWN_MODULE_FORMAT' } 121cb0ef41Sopenharmony_ci); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciawait rejects( 151cb0ef41Sopenharmony_ci import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`), 161cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 171cb0ef41Sopenharmony_ci); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciawait rejects( 201cb0ef41Sopenharmony_ci import(jsModuleDataUrl, { with: { type: 'json' } }), 211cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 221cb0ef41Sopenharmony_ci); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciawait rejects( 251cb0ef41Sopenharmony_ci import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }), 261cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 271cb0ef41Sopenharmony_ci); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciawait rejects( 301cb0ef41Sopenharmony_ci import(import.meta.url, { with: { type: 'unsupported' } }), 311cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 321cb0ef41Sopenharmony_ci); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciawait rejects( 351cb0ef41Sopenharmony_ci import(jsonModuleDataUrl), 361cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 371cb0ef41Sopenharmony_ci); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ciawait rejects( 401cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: {} }), 411cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 421cb0ef41Sopenharmony_ci); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciawait rejects( 451cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: { foo: 'bar' } }), 461cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 471cb0ef41Sopenharmony_ci); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciawait rejects( 501cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: { type: 'unsupported' } }), 511cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 521cb0ef41Sopenharmony_ci); 53