mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
07f481cfcf
This patch removes support for the `assert` keyword for import attributes. It was an old variant of the proposal that was only shipped in V8 and no other engine, and that has then been replaced by the `with` keyword. Chrome is planning to remove support for `assert` in version 126, which will be released in June. Node.js already supports the `with` keyword for import attributes, and this patch does not change that. PR-URL: https://github.com/nodejs/node/pull/52104 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { rejects } = require('assert');
|
|
|
|
const jsModuleDataUrl = 'data:text/javascript,export{}';
|
|
const jsonModuleDataUrl = 'data:application/json,""';
|
|
|
|
async function test() {
|
|
await rejects(
|
|
import('data:text/css,', { with: { type: 'css' } }),
|
|
{ code: 'ERR_UNKNOWN_MODULE_FORMAT' }
|
|
);
|
|
|
|
await rejects(
|
|
import('data:text/css,', { with: { unsupportedAttribute: 'value' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
|
|
);
|
|
|
|
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(jsModuleDataUrl, { 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' }
|
|
);
|
|
|
|
await rejects(
|
|
import(jsonModuleDataUrl, { assert: { type: 'json' } }),
|
|
{ code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
|
|
);
|
|
|
|
await rejects(
|
|
import(`data:text/javascript,import${JSON.stringify(jsonModuleDataUrl)}assert{type:"json"}`),
|
|
SyntaxError
|
|
);
|
|
}
|
|
|
|
test().then(common.mustCall());
|