node/test/wpt/test-url.js
XadillaX af4e682758
test: pass URL's toascii.window.js WPT
PR-URL: https://github.com/nodejs/node/pull/39910
Backport-PR-URL: https://github.com/nodejs/node/pull/40383
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2021-11-04 13:25:39 +01:00

27 lines
855 B
JavaScript

'use strict';
require('../common');
const { WPTRunner } = require('../common/wpt');
const runner = new WPTRunner('url');
// Needed to access to DOMException.
runner.setFlags(['--expose-internals']);
// DOMException is needed by urlsearchparams-constructor.any.js
runner.setInitScript(`
const { internalBinding } = require('internal/test/binding');
const { DOMException } = internalBinding('messaging');
global.DOMException = DOMException;
`);
runner.setScriptModifier((obj) => {
if (obj.filename.includes('toascii.window.js')) {
// `a` and `area` in `toascii.window.js` is for testing `Element` that
// created via `document.createElement`. So we need to ignore them and just
// test `URL`.
obj.code = obj.code.replace(/\["url", "a", "area"\]/, '[ "url" ]');
}
});
runner.pretendGlobalThisAs('Window');
runner.runJsTests();