11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { rejects } = require('assert'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst jsModuleDataUrl = 'data:text/javascript,export{}'; 61cb0ef41Sopenharmony_ciconst jsonModuleDataUrl = 'data:application/json,""'; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciasync function test() { 91cb0ef41Sopenharmony_ci await rejects( 101cb0ef41Sopenharmony_ci import('data:text/css,', { with: { type: 'css' } }), 111cb0ef41Sopenharmony_ci { code: 'ERR_UNKNOWN_MODULE_FORMAT' } 121cb0ef41Sopenharmony_ci ); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci await rejects( 151cb0ef41Sopenharmony_ci import('data:text/css,', { with: { unsupportedAttribute: 'value' } }), 161cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' } 171cb0ef41Sopenharmony_ci ); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci await rejects( 201cb0ef41Sopenharmony_ci import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`), 211cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 221cb0ef41Sopenharmony_ci ); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci await rejects( 251cb0ef41Sopenharmony_ci import(jsModuleDataUrl, { with: { type: 'json' } }), 261cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 271cb0ef41Sopenharmony_ci ); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci await rejects( 301cb0ef41Sopenharmony_ci import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }), 311cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } 321cb0ef41Sopenharmony_ci ); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci await rejects( 351cb0ef41Sopenharmony_ci import(jsModuleDataUrl, { with: { type: 'unsupported' } }), 361cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 371cb0ef41Sopenharmony_ci ); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci await rejects( 401cb0ef41Sopenharmony_ci import(jsonModuleDataUrl), 411cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 421cb0ef41Sopenharmony_ci ); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci await rejects( 451cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: {} }), 461cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 471cb0ef41Sopenharmony_ci ); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci await rejects( 501cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: { foo: 'bar' } }), 511cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' } 521cb0ef41Sopenharmony_ci ); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci await rejects( 551cb0ef41Sopenharmony_ci import(jsonModuleDataUrl, { with: { type: 'unsupported' } }), 561cb0ef41Sopenharmony_ci { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } 571cb0ef41Sopenharmony_ci ); 581cb0ef41Sopenharmony_ci} 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_citest().then(common.mustCall()); 61