From 4baba61595092974e09ea9f2111c9ae9a0baade8 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 26 Nov 2020 17:30:00 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Avoid=C2=A0generating=20broken=C2=A0code=20?= =?UTF-8?q?when=C2=A0the=C2=A0`object`=C2=A0type=20is=C2=A0in=C2=A0a=C2=A0?= =?UTF-8?q?union?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/types.js | 3 +- test/__snapshots__/test.js.snap | 3838 +++++++++++++++++++++-------- test/cases/NoUselessIfElse.webidl | 46 + 3 files changed, 2794 insertions(+), 1093 deletions(-) create mode 100644 test/cases/NoUselessIfElse.webidl diff --git a/lib/types.js b/lib/types.js index 3ec2d5f0..c1d26ebf 100644 --- a/lib/types.js +++ b/lib/types.js @@ -208,7 +208,8 @@ function generateTypeConversion(ctx, name, idlType, argAttrs = [], parentName, e if (union.ArrayBufferViews.size > 0 || union.object) { let condition = `ArrayBuffer.isView(${name})`; // Skip specific type check if all ArrayBufferView member types are allowed. - if (union.ArrayBufferViews.size !== arrayBufferViewTypes.size) { + if (union.ArrayBufferViews.size !== 0 && + union.ArrayBufferViews.size !== arrayBufferViewTypes.size) { const exprs = [...union.ArrayBufferViews].map(a => `${name}.constructor.name === "${a}"`); condition += ` && (${exprs.join(" || ")})`; } diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 8023678b..2df3ac36 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -4323,95 +4323,16 @@ const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`with processors NodeFilter.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { - if (!utils.isObject(value)) { - throw new TypeError(\`\${context} is not an object.\`); - } - - function callTheUserObjectsOperation(node) { - let thisArg = utils.tryWrapperForImpl(this); - let O = value; - let X = O; - - if (typeof O !== \\"function\\") { - X = O[\\"acceptNode\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement NodeFilter.\`); - } - thisArg = O; - } - - node = utils.tryWrapperForImpl(node); - - let callResult = Reflect.apply(X, thisArg, [node]); - - callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); - - return callResult; - } - - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; - - return callTheUserObjectsOperation; -}; - -const exposed = new Set([\\"Window\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - - const NodeFilter = () => { - throw new TypeError(\\"Illegal invocation\\"); - }; - - Object.defineProperties(NodeFilter, { - FILTER_ACCEPT: { value: 1, enumerable: true }, - FILTER_REJECT: { value: 2, enumerable: true }, - FILTER_SKIP: { value: 3, enumerable: true }, - SHOW_ALL: { value: 0xffffffff, enumerable: true }, - SHOW_ELEMENT: { value: 0x1, enumerable: true }, - SHOW_ATTRIBUTE: { value: 0x2, enumerable: true }, - SHOW_TEXT: { value: 0x4, enumerable: true }, - SHOW_CDATA_SECTION: { value: 0x8, enumerable: true }, - SHOW_ENTITY_REFERENCE: { value: 0x10, enumerable: true }, - SHOW_ENTITY: { value: 0x20, enumerable: true }, - SHOW_PROCESSING_INSTRUCTION: { value: 0x40, enumerable: true }, - SHOW_COMMENT: { value: 0x80, enumerable: true }, - SHOW_DOCUMENT: { value: 0x100, enumerable: true }, - SHOW_DOCUMENT_TYPE: { value: 0x200, enumerable: true }, - SHOW_DOCUMENT_FRAGMENT: { value: 0x400, enumerable: true }, - SHOW_NOTATION: { value: 0x800, enumerable: true } - }); - - Object.defineProperty(globalObject, \\"NodeFilter\\", { - configurable: true, - writable: true, - value: NodeFilter - }); -}; -" -`; - -exports[`with processors Overloads.webidl 1`] = ` +exports[`with processors NoUselessIfElse.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const URL = require(\\"./URL.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Overloads\\"; +const interfaceName = \\"NoUselessIfElse\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -4423,7 +4344,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Overloads'.\`); + throw new TypeError(\`\${context} is not of type 'NoUselessIfElse'.\`); }; function makeWrapper(globalObject) { @@ -4431,9 +4352,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"NoUselessIfElse\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor NoUselessIfElse is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -4489,111 +4410,171 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Overloads { + class NoUselessIfElse { constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + overloadsObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (URL.is(curArg)) { - { - let curArg = arguments[0]; - curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); } } } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBoolean(...args)); } - compatible(arg1) { + overloadsObjectOrBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'compatible' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - case 2: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - default: + } else { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumeric(...args)); + } + + overloadsObjectOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" - }); - } else { - curArg = 0; - } + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); args.push(curArg); } + } } - return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumeric(...args)); } - incompatible1(arg1) { + overloadsBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible1' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -4601,369 +4582,322 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { { let curArg = arguments[0]; curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } } else { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } } } - return esValue[implSymbol].incompatible1(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumeric(...args)); } - incompatible2(arg1) { + overloadsObjectOrBooleanOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible2' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - default: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else { { - let curArg = arguments[1]; + let curArg = arguments[0]; curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } } - return esValue[implSymbol].incompatible2(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrString(...args)); } - incompatible3(arg1) { + overloadsObjectOrBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible3' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - case 2: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[1]; - if (curArg === undefined) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = URL.convert(curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - } - args.push(curArg); - } - } else if (URL.is(curArg)) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = URL.convert(curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - } - args.push(curArg); - } - } else if (utils.isArrayBuffer(curArg)) { - { - let curArg = arguments[1]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - } else if (ArrayBuffer.isView(curArg)) { - { - let curArg = arguments[1]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - } else { - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - } + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); } - break; - case 3: - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" - ); - break; - default: + } else { { let curArg = arguments[0]; curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumericOrString(...args)); + } + + overloadsObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { - let curArg = arguments[1]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[2]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" - ); - } + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); args.push(curArg); } + } else { { - let curArg = arguments[3]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" - ); - } + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); args.push(curArg); } + } } - return esValue[implSymbol].incompatible3(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumericOrString(...args)); } - } - Object.defineProperties(Overloads.prototype, { - compatible: { enumerable: true }, - incompatible1: { enumerable: true }, - incompatible2: { enumerable: true }, - incompatible3: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Overloads\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = Overloads; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: Overloads - }); -}; - -const Impl = require(\\"../implementations/Overloads.js\\"); -" -`; - -exports[`with processors PromiseTypes.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"PromiseTypes\\"; - -exports.is = value => { - return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = value => { - return utils.isObject(value) && value instanceof Impl.implementation; -}; -exports.convert = (value, { context = \\"The provided value\\" } = {}) => { - if (exports.is(value)) { - return utils.implForWrapper(value); - } - throw new TypeError(\`\${context} is not of type 'PromiseTypes'.\`); -}; - -function makeWrapper(globalObject) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } - - const ctor = globalObject[ctorRegistrySymbol][\\"PromiseTypes\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor PromiseTypes is not installed on the passed global object\\"); - } - - return Object.create(ctor.prototype); -} - -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; + overloadsBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports._internalSetup = (wrapper, globalObject) => { - Object.defineProperties( - wrapper, - Object.getOwnPropertyDescriptors({ - unforgeablePromiseOperation() { - try { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'unforgeablePromiseOperation' called on an object that is not a valid instance of PromiseTypes.\\" - ); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); } - - return utils.tryWrapperForImpl(esValue[implSymbol].unforgeablePromiseOperation()); - } catch (e) { - return Promise.reject(e); - } - }, - get unforgeablePromiseAttribute() { - try { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError( - \\"'get unforgeablePromiseAttribute' called on an object that is not a valid instance of PromiseTypes.\\" - ); + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); } - - return utils.tryWrapperForImpl(esValue[implSymbol][\\"unforgeablePromiseAttribute\\"]); - } catch (e) { - return Promise.reject(e); } } - }) - ); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumericOrString(...args)); + } - Object.defineProperties(wrapper, { - unforgeablePromiseOperation: { configurable: false, writable: false }, - unforgeablePromiseAttribute: { configurable: false } - }); -}; + unionObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper; -}; - -exports.new = globalObject => { - const wrapper = makeWrapper(globalObject); - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true - }); - - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBoolean(...args)); + } -const exposed = new Set([\\"Window\\"]); + unionObjectOrBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class PromiseTypes { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumeric(...args)); } - voidPromiseConsumer(p) { + unionObjectOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'voidPromiseConsumer' called on an object that is not a valid instance of PromiseTypes.\\"); + throw new TypeError( + \\"'unionObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -4971,21 +4905,37 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = new Promise(resolve => resolve(curArg)); + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } args.push(curArg); } - return esValue[implSymbol].voidPromiseConsumer(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumeric(...args)); } - promiseConsumer(p) { + unionBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'promiseConsumer' called on an object that is not a valid instance of PromiseTypes.\\"); + throw new TypeError( + \\"'unionBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -4993,97 +4943,302 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = new Promise(resolve => resolve(curArg)); + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } args.push(curArg); } - return esValue[implSymbol].promiseConsumer(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); } - promiseOperation() { - try { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'promiseOperation' called on an object that is not a valid instance of PromiseTypes.\\"); - } + unionObjectOrBooleanOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - return utils.tryWrapperForImpl(esValue[implSymbol].promiseOperation()); - } catch (e) { - return Promise.reject(e); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrString(...args)); } - get promiseAttribute() { - try { - const esValue = this !== null && this !== undefined ? this : globalObject; + unionObjectOrBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - if (!exports.is(esValue)) { - throw new TypeError( - \\"'get promiseAttribute' called on an object that is not a valid instance of PromiseTypes.\\" - ); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); } - - return utils.tryWrapperForImpl(esValue[implSymbol][\\"promiseAttribute\\"]); - } catch (e) { - return Promise.reject(e); + args.push(curArg); } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumericOrString(...args)); } - static staticPromiseOperation() { - try { - return utils.tryWrapperForImpl(Impl.implementation.staticPromiseOperation()); - } catch (e) { - return Promise.reject(e); + unionObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumericOrString(...args)); } - static get staticPromiseAttribute() { - try { - const esValue = this !== null && this !== undefined ? this : globalObject; + unionBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - return Impl.implementation[\\"staticPromiseAttribute\\"]; - } catch (e) { - return Promise.reject(e); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - } - } - Object.defineProperties(PromiseTypes.prototype, { - voidPromiseConsumer: { enumerable: true }, - promiseConsumer: { enumerable: true }, - promiseOperation: { enumerable: true }, - promiseAttribute: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"PromiseTypes\\", configurable: true } - }); - Object.defineProperties(PromiseTypes, { - staticPromiseOperation: { enumerable: true }, - staticPromiseAttribute: { enumerable: true } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumericOrString(...args)); + } + } + Object.defineProperties(NoUselessIfElse.prototype, { + overloadsObjectOrBoolean: { enumerable: true }, + overloadsObjectOrBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrNumeric: { enumerable: true }, + overloadsBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrBooleanOrString: { enumerable: true }, + overloadsObjectOrBooleanOrNumericOrString: { enumerable: true }, + overloadsObjectOrNumericOrString: { enumerable: true }, + overloadsBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrBoolean: { enumerable: true }, + unionObjectOrBooleanOrNumeric: { enumerable: true }, + unionObjectOrNumeric: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionObjectOrBooleanOrString: { enumerable: true }, + unionObjectOrBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrNumericOrString: { enumerable: true }, + unionBooleanOrNumericOrString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"NoUselessIfElse\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = PromiseTypes; + globalObject[ctorRegistrySymbol][interfaceName] = NoUselessIfElse; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: PromiseTypes + value: NoUselessIfElse }); }; -const Impl = require(\\"../implementations/PromiseTypes.js\\"); +const Impl = require(\\"../implementations/NoUselessIfElse.js\\"); " `; -exports[`with processors Reflect.webidl 1`] = ` +exports[`with processors NodeFilter.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const whatwg_url = require(\\"whatwg-url\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"Reflect\\"; +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + if (!utils.isObject(value)) { + throw new TypeError(\`\${context} is not an object.\`); + } + + function callTheUserObjectsOperation(node) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + if (typeof O !== \\"function\\") { + X = O[\\"acceptNode\\"]; + if (typeof X !== \\"function\\") { + throw new TypeError(\`\${context} does not correctly implement NodeFilter.\`); + } + thisArg = O; + } + + node = utils.tryWrapperForImpl(node); + + let callResult = Reflect.apply(X, thisArg, [node]); + + callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); + + return callResult; + } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const NodeFilter = () => { + throw new TypeError(\\"Illegal invocation\\"); + }; + + Object.defineProperties(NodeFilter, { + FILTER_ACCEPT: { value: 1, enumerable: true }, + FILTER_REJECT: { value: 2, enumerable: true }, + FILTER_SKIP: { value: 3, enumerable: true }, + SHOW_ALL: { value: 0xffffffff, enumerable: true }, + SHOW_ELEMENT: { value: 0x1, enumerable: true }, + SHOW_ATTRIBUTE: { value: 0x2, enumerable: true }, + SHOW_TEXT: { value: 0x4, enumerable: true }, + SHOW_CDATA_SECTION: { value: 0x8, enumerable: true }, + SHOW_ENTITY_REFERENCE: { value: 0x10, enumerable: true }, + SHOW_ENTITY: { value: 0x20, enumerable: true }, + SHOW_PROCESSING_INSTRUCTION: { value: 0x40, enumerable: true }, + SHOW_COMMENT: { value: 0x80, enumerable: true }, + SHOW_DOCUMENT: { value: 0x100, enumerable: true }, + SHOW_DOCUMENT_TYPE: { value: 0x200, enumerable: true }, + SHOW_DOCUMENT_FRAGMENT: { value: 0x400, enumerable: true }, + SHOW_NOTATION: { value: 0x800, enumerable: true } + }); + + Object.defineProperty(globalObject, \\"NodeFilter\\", { + configurable: true, + writable: true, + value: NodeFilter + }); +}; +" +`; + +exports[`with processors Overloads.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const URL = require(\\"./URL.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Overloads\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -5095,7 +5250,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Reflect'.\`); + throw new TypeError(\`\${context} is not of type 'Overloads'.\`); }; function makeWrapper(globalObject) { @@ -5103,9 +5258,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Reflect\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Reflect is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -5161,84 +5316,756 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Reflect { + class Overloads { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - get reflectedBoolean() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get reflectedBoolean' called on an object that is not a valid instance of Reflect.\\"); + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (URL.is(curArg)) { + { + let curArg = arguments[0]; + curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } + } } - - return esValue[implSymbol].hasAttributeNS(null, \\"reflectedboolean\\"); + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - set reflectedBoolean(V) { + compatible(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set reflectedBoolean' called on an object that is not a valid instance of Reflect.\\"); + throw new TypeError(\\"'compatible' called on an object that is not a valid instance of Overloads.\\"); } - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'reflectedBoolean' property on 'Reflect': The provided value\\" - }); - - if (V) { - esValue[implSymbol].setAttributeNS(null, \\"reflectedboolean\\", \\"\\"); - } else { - esValue[implSymbol].removeAttributeNS(null, \\"reflectedboolean\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - } - - get reflectedDOMString() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get reflectedDOMString' called on an object that is not a valid instance of Reflect.\\"); + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" + }); + } else { + curArg = 0; + } + args.push(curArg); + } } - - const value = esValue[implSymbol].getAttributeNS(null, \\"reflecteddomstring\\"); - return value === null ? \\"\\" : value; + return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); } - set reflectedDOMString(V) { + incompatible1(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set reflectedDOMString' called on an object that is not a valid instance of Reflect.\\"); + throw new TypeError(\\"'incompatible1' called on an object that is not a valid instance of Overloads.\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'reflectedDOMString' property on 'Reflect': The provided value\\" - }); - - esValue[implSymbol].setAttributeNS(null, \\"reflecteddomstring\\", V); - } - - get reflectedLong() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get reflectedLong' called on an object that is not a valid instance of Reflect.\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - - const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedlong\\")); - return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value; + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } + } + return esValue[implSymbol].incompatible1(...args); } - set reflectedLong(V) { + incompatible2(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set reflectedLong' called on an object that is not a valid instance of Reflect.\\"); + throw new TypeError(\\"'incompatible2' called on an object that is not a valid instance of Overloads.\\"); } - V = conversions[\\"long\\"](V, { - context: \\"Failed to set the 'reflectedLong' property on 'Reflect': The provided value\\" + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + } + return esValue[implSymbol].incompatible2(...args); + } + + incompatible3(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'incompatible3' called on an object that is not a valid instance of Overloads.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === undefined) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = URL.convert(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); + } + } else if (URL.is(curArg)) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = URL.convert(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); + } + } else if (utils.isArrayBuffer(curArg)) { + { + let curArg = arguments[1]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[1]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } else { + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + } + } + break; + case 3: + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" + ); + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } + return esValue[implSymbol].incompatible3(...args); + } + } + Object.defineProperties(Overloads.prototype, { + compatible: { enumerable: true }, + incompatible1: { enumerable: true }, + incompatible2: { enumerable: true }, + incompatible3: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Overloads\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Overloads; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Overloads + }); +}; + +const Impl = require(\\"../implementations/Overloads.js\\"); +" +`; + +exports[`with processors PromiseTypes.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"PromiseTypes\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'PromiseTypes'.\`); +}; + +function makeWrapper(globalObject) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"PromiseTypes\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor PromiseTypes is not installed on the passed global object\\"); + } + + return Object.create(ctor.prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Object.defineProperties( + wrapper, + Object.getOwnPropertyDescriptors({ + unforgeablePromiseOperation() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unforgeablePromiseOperation' called on an object that is not a valid instance of PromiseTypes.\\" + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].unforgeablePromiseOperation()); + } catch (e) { + return Promise.reject(e); + } + }, + get unforgeablePromiseAttribute() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError( + \\"'get unforgeablePromiseAttribute' called on an object that is not a valid instance of PromiseTypes.\\" + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"unforgeablePromiseAttribute\\"]); + } catch (e) { + return Promise.reject(e); + } + } + }) + ); + + Object.defineProperties(wrapper, { + unforgeablePromiseOperation: { configurable: false, writable: false }, + unforgeablePromiseAttribute: { configurable: false } + }); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = globalObject => { + const wrapper = makeWrapper(globalObject); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class PromiseTypes { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + voidPromiseConsumer(p) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'voidPromiseConsumer' called on an object that is not a valid instance of PromiseTypes.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = new Promise(resolve => resolve(curArg)); + args.push(curArg); + } + return esValue[implSymbol].voidPromiseConsumer(...args); + } + + promiseConsumer(p) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'promiseConsumer' called on an object that is not a valid instance of PromiseTypes.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = new Promise(resolve => resolve(curArg)); + args.push(curArg); + } + return esValue[implSymbol].promiseConsumer(...args); + } + + promiseOperation() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'promiseOperation' called on an object that is not a valid instance of PromiseTypes.\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].promiseOperation()); + } catch (e) { + return Promise.reject(e); + } + } + + get promiseAttribute() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError( + \\"'get promiseAttribute' called on an object that is not a valid instance of PromiseTypes.\\" + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"promiseAttribute\\"]); + } catch (e) { + return Promise.reject(e); + } + } + + static staticPromiseOperation() { + try { + return utils.tryWrapperForImpl(Impl.implementation.staticPromiseOperation()); + } catch (e) { + return Promise.reject(e); + } + } + + static get staticPromiseAttribute() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + + return Impl.implementation[\\"staticPromiseAttribute\\"]; + } catch (e) { + return Promise.reject(e); + } + } + } + Object.defineProperties(PromiseTypes.prototype, { + voidPromiseConsumer: { enumerable: true }, + promiseConsumer: { enumerable: true }, + promiseOperation: { enumerable: true }, + promiseAttribute: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"PromiseTypes\\", configurable: true } + }); + Object.defineProperties(PromiseTypes, { + staticPromiseOperation: { enumerable: true }, + staticPromiseAttribute: { enumerable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = PromiseTypes; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PromiseTypes + }); +}; + +const Impl = require(\\"../implementations/PromiseTypes.js\\"); +" +`; + +exports[`with processors Reflect.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const whatwg_url = require(\\"whatwg-url\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Reflect\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'Reflect'.\`); +}; + +function makeWrapper(globalObject) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Reflect\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Reflect is not installed on the passed global object\\"); + } + + return Object.create(ctor.prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = globalObject => { + const wrapper = makeWrapper(globalObject); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Reflect { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + get reflectedBoolean() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get reflectedBoolean' called on an object that is not a valid instance of Reflect.\\"); + } + + return esValue[implSymbol].hasAttributeNS(null, \\"reflectedboolean\\"); + } + + set reflectedBoolean(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set reflectedBoolean' called on an object that is not a valid instance of Reflect.\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'reflectedBoolean' property on 'Reflect': The provided value\\" + }); + + if (V) { + esValue[implSymbol].setAttributeNS(null, \\"reflectedboolean\\", \\"\\"); + } else { + esValue[implSymbol].removeAttributeNS(null, \\"reflectedboolean\\"); + } + } + + get reflectedDOMString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get reflectedDOMString' called on an object that is not a valid instance of Reflect.\\"); + } + + const value = esValue[implSymbol].getAttributeNS(null, \\"reflecteddomstring\\"); + return value === null ? \\"\\" : value; + } + + set reflectedDOMString(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set reflectedDOMString' called on an object that is not a valid instance of Reflect.\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'reflectedDOMString' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflecteddomstring\\", V); + } + + get reflectedLong() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get reflectedLong' called on an object that is not a valid instance of Reflect.\\"); + } + + const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedlong\\")); + return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value; + } + + set reflectedLong(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set reflectedLong' called on an object that is not a valid instance of Reflect.\\"); + } + + V = conversions[\\"long\\"](V, { + context: \\"Failed to set the 'reflectedLong' property on 'Reflect': The provided value\\" }); esValue[implSymbol].setAttributeNS(null, \\"reflectedlong\\", String(V)); @@ -13302,36 +14129,277 @@ exports._internalSetup = (wrapper, globalObject) => { throw new TypeError(\\"'get length' called on an object that is not a valid instance of Global.\\"); } - return esValue[implSymbol][\\"length\\"]; - }, - set length(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + return esValue[implSymbol][\\"length\\"]; + }, + set length(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set length' called on an object that is not a valid instance of Global.\\"); + } + + V = conversions[\\"unsigned long\\"](V, { + context: \\"Failed to set the 'length' property on 'Global': The provided value\\" + }); + + esValue[implSymbol][\\"length\\"] = V; + }, + [Symbol.iterator]: Array.prototype[Symbol.iterator], + keys: Array.prototype.keys, + values: Array.prototype[Symbol.iterator], + entries: Array.prototype.entries, + forEach: Array.prototype.forEach + }) + ); + + Object.defineProperties(wrapper, { + unforgeableOp: { configurable: false, writable: false }, + unforgeableAttr: { configurable: false }, + [Symbol.iterator]: { enumerable: false } + }); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = globalObject => { + const wrapper = makeWrapper(globalObject); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Global\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Global { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + static staticOp() { + return Impl.implementation.staticOp(); + } + + static get staticAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + return Impl.implementation[\\"staticAttr\\"]; + } + + static set staticAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'staticAttr' property on 'Global': The provided value\\" + }); + + Impl.implementation[\\"staticAttr\\"] = V; + } + } + Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); + Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Global; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Global + }); +}; + +const Impl = require(\\"../implementations/Global.js\\"); +" +`; + +exports[`without processors HTMLConstructor.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"HTMLConstructor\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'HTMLConstructor'.\`); +}; + +function makeWrapper(globalObject) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor HTMLConstructor is not installed on the passed global object\\"); + } + + return Object.create(ctor.prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = globalObject => { + const wrapper = makeWrapper(globalObject); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class HTMLConstructor { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(HTMLConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = HTMLConstructor; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLConstructor + }); +}; + +const Impl = require(\\"../implementations/HTMLConstructor.js\\"); +" +`; + +exports[`without processors LegacyLenientAttributes.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"LegacyLenientAttributes\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'LegacyLenientAttributes'.\`); +}; + +function makeWrapper(globalObject) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } - if (!exports.is(esValue)) { - throw new TypeError(\\"'set length' called on an object that is not a valid instance of Global.\\"); - } + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor LegacyLenientAttributes is not installed on the passed global object\\"); + } - V = conversions[\\"unsigned long\\"](V, { - context: \\"Failed to set the 'length' property on 'Global': The provided value\\" - }); + return Object.create(ctor.prototype); +} - esValue[implSymbol][\\"length\\"] = V; - }, - [Symbol.iterator]: Array.prototype[Symbol.iterator], - keys: Array.prototype.keys, - values: Array.prototype[Symbol.iterator], - entries: Array.prototype.entries, - forEach: Array.prototype.forEach - }) - ); +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; - Object.defineProperties(wrapper, { - unforgeableOp: { configurable: false, writable: false }, - unforgeableAttr: { configurable: false }, - [Symbol.iterator]: { enumerable: false } - }); +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); }; +exports._internalSetup = (wrapper, globalObject) => {}; + exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -13364,56 +14432,131 @@ exports.new = globalObject => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Global\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Global { + class LegacyLenientAttributes { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - static staticOp() { - return Impl.implementation.staticOp(); + get lenientSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError( + \\"'get lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" + ); + } + + return esValue[implSymbol][\\"lenientSetter\\"]; } - static get staticAttr() { + set lenientSetter(V) { const esValue = this !== null && this !== undefined ? this : globalObject; - return Impl.implementation[\\"staticAttr\\"]; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'set lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" + ); + } } - static set staticAttr(V) { + get lenientThisSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"lenientThisSetter\\"]; + } + + set lenientThisSetter(V) {} + + get lenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"lenientThis\\"]; + } + + set lenientThis(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + return; + } + V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'staticAttr' property on 'Global': The provided value\\" + context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" }); - Impl.implementation[\\"staticAttr\\"] = V; + esValue[implSymbol][\\"lenientThis\\"] = V; + } + + get readonlyLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"readonlyLenientThis\\"]; + } + + get replaceableLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"replaceableLenientThis\\"]; + } + + set replaceableLenientThis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + Object.defineProperty(esValue, \\"replaceableLenientThis\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); } } - Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); - Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); + Object.defineProperties(LegacyLenientAttributes.prototype, { + lenientSetter: { enumerable: true }, + lenientThisSetter: { enumerable: true }, + lenientThis: { enumerable: true }, + readonlyLenientThis: { enumerable: true }, + replaceableLenientThis: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyLenientAttributes\\", configurable: true } + }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Global; + globalObject[ctorRegistrySymbol][interfaceName] = LegacyLenientAttributes; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Global + value: LegacyLenientAttributes }); }; -const Impl = require(\\"../implementations/Global.js\\"); +const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); " `; -exports[`without processors HTMLConstructor.webidl 1`] = ` +exports[`without processors LegacyUnforgeable.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13422,7 +14565,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"HTMLConstructor\\"; +const interfaceName = \\"LegacyUnforgeable\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13434,7 +14577,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'HTMLConstructor'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyUnforgeable'.\`); }; function makeWrapper(globalObject) { @@ -13442,25 +14585,123 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor HTMLConstructor is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor LegacyUnforgeable is not installed on the passed global object\\"); } - return Object.create(ctor.prototype); -} + return Object.create(ctor.prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Object.defineProperties( + wrapper, + Object.getOwnPropertyDescriptors({ + assign(url) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'assign' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'assign' on 'LegacyUnforgeable': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'assign' on 'LegacyUnforgeable': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].assign(...args); + }, + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + return esValue[implSymbol][\\"href\\"]; + }, + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'href' property on 'LegacyUnforgeable': The provided value\\" + }); + + esValue[implSymbol][\\"href\\"] = V; + }, + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new TypeError(\\"'toString' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + return esValue[implSymbol][\\"href\\"]; + }, + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get origin' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + return esValue[implSymbol][\\"origin\\"]; + }, + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get protocol' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } + + return esValue[implSymbol][\\"protocol\\"]; + }, + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set protocol' called on an object that is not a valid instance of LegacyUnforgeable.\\"); + } -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'protocol' property on 'LegacyUnforgeable': The provided value\\" + }); -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; + esValue[implSymbol][\\"protocol\\"] = V; + } + }) + ); -exports._internalSetup = (wrapper, globalObject) => {}; + Object.defineProperties(wrapper, { + assign: { configurable: false, writable: false }, + href: { configurable: false }, + toString: { configurable: false, writable: false }, + origin: { configurable: false }, + protocol: { configurable: false } + }); +}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -13500,31 +14741,31 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class HTMLConstructor { + class LegacyUnforgeable { constructor() { throw new TypeError(\\"Illegal constructor\\"); } } - Object.defineProperties(HTMLConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + Object.defineProperties(LegacyUnforgeable.prototype, { + [Symbol.toStringTag]: { value: \\"LegacyUnforgeable\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = HTMLConstructor; + globalObject[ctorRegistrySymbol][interfaceName] = LegacyUnforgeable; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: HTMLConstructor + value: LegacyUnforgeable }); }; -const Impl = require(\\"../implementations/HTMLConstructor.js\\"); +const Impl = require(\\"../implementations/LegacyUnforgeable.js\\"); " `; -exports[`without processors LegacyLenientAttributes.webidl 1`] = ` +exports[`without processors LegacyUnforgeableMap.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13533,7 +14774,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyLenientAttributes\\"; +const interfaceName = \\"LegacyUnforgeableMap\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13545,7 +14786,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyLenientAttributes'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyUnforgeableMap'.\`); }; function makeWrapper(globalObject) { @@ -13553,9 +14794,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeableMap\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyLenientAttributes is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor LegacyUnforgeableMap is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -13571,7 +14812,24 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => {}; +exports._internalSetup = (wrapper, globalObject) => { + Object.defineProperties( + wrapper, + Object.getOwnPropertyDescriptors({ + get a() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get a' called on an object that is not a valid instance of LegacyUnforgeableMap.\\"); + } + + return esValue[implSymbol][\\"a\\"]; + } + }) + ); + + Object.defineProperties(wrapper, { a: { configurable: false } }); +}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -13582,6 +14840,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) configurable: true }); + wrapper = new Proxy(wrapper, proxyHandler); + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -13590,7 +14850,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = globalObject => { - const wrapper = makeWrapper(globalObject); + let wrapper = makeWrapper(globalObject); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -13598,6 +14858,8 @@ exports.new = globalObject => { configurable: true }); + wrapper = new Proxy(wrapper, proxyHandler); + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -13611,125 +14873,208 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyLenientAttributes { + class LegacyUnforgeableMap { constructor() { throw new TypeError(\\"Illegal constructor\\"); } + } + Object.defineProperties(LegacyUnforgeableMap.prototype, { + [Symbol.toStringTag]: { value: \\"LegacyUnforgeableMap\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = LegacyUnforgeableMap; - get lenientSetter() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: LegacyUnforgeableMap + }); +}; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'get lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" - ); +const proxyHandler = { + get(target, P, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + }, - return esValue[implSymbol][\\"lenientSetter\\"]; + has(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); } + return false; + }, - set lenientSetter(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + ownKeys(target) { + const keys = new Set(); - if (!exports.is(esValue)) { - throw new TypeError( - \\"'set lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" - ); + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(\`\${key}\`); } } - get lenientThisSetter() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + }, - return esValue[implSymbol][\\"lenientThisSetter\\"]; + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); } + let ignoreNamedProps = false; - set lenientThisSetter(V) {} + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { + const namedValue = target[implSymbol][utils.namedGet](P); - get lenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } - if (!exports.is(esValue)) { - return; - } + return Reflect.getOwnPropertyDescriptor(target, P); + }, - return esValue[implSymbol][\\"lenientThis\\"]; + set(target, P, V, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.set(target, P, V, receiver); } + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { + let namedValue = V; - set lenientThis(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" + }); - if (!exports.is(esValue)) { - return; + const creating = !target[implSymbol][utils.supportsPropertyName](P); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + + return true; } + } + let ownDesc; - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" - }); + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + }, - esValue[implSymbol][\\"lenientThis\\"] = V; + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); } + if (![\\"a\\"].includes(P)) { + if (!utils.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; + } - get readonlyLenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; + let namedValue = desc.value; + + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" + }); + + const creating = !target[implSymbol][utils.supportsPropertyName](P); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } - if (!exports.is(esValue)) { - return; + return true; } - - return esValue[implSymbol][\\"readonlyLenientThis\\"]; } + return Reflect.defineProperty(target, P, desc); + }, - get replaceableLenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } - return esValue[implSymbol][\\"replaceableLenientThis\\"]; + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { + return false; } - set replaceableLenientThis(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + return Reflect.deleteProperty(target, P); + }, - Object.defineProperty(esValue, \\"replaceableLenientThis\\", { - configurable: true, - enumerable: true, - value: V, - writable: true - }); - } - } - Object.defineProperties(LegacyLenientAttributes.prototype, { - lenientSetter: { enumerable: true }, - lenientThisSetter: { enumerable: true }, - lenientThis: { enumerable: true }, - readonlyLenientThis: { enumerable: true }, - replaceableLenientThis: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"LegacyLenientAttributes\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); + preventExtensions() { + return false; } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyLenientAttributes; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: LegacyLenientAttributes - }); }; -const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); +const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); " `; -exports[`without processors LegacyUnforgeable.webidl 1`] = ` +exports[`without processors MixedIn.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13738,7 +15083,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyUnforgeable\\"; +const interfaceName = \\"MixedIn\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13750,7 +15095,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyUnforgeable'.\`); + throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); }; function makeWrapper(globalObject) { @@ -13758,9 +15103,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyUnforgeable is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -13776,105 +15121,7 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => { - Object.defineProperties( - wrapper, - Object.getOwnPropertyDescriptors({ - assign(url) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'assign' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'assign' on 'LegacyUnforgeable': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'assign' on 'LegacyUnforgeable': parameter 1\\" - }); - args.push(curArg); - } - return esValue[implSymbol].assign(...args); - }, - get href() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - return esValue[implSymbol][\\"href\\"]; - }, - set href(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'href' property on 'LegacyUnforgeable': The provided value\\" - }); - - esValue[implSymbol][\\"href\\"] = V; - }, - toString() { - const esValue = this; - if (!exports.is(esValue)) { - throw new TypeError(\\"'toString' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - return esValue[implSymbol][\\"href\\"]; - }, - get origin() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get origin' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - return esValue[implSymbol][\\"origin\\"]; - }, - get protocol() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get protocol' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - return esValue[implSymbol][\\"protocol\\"]; - }, - set protocol(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set protocol' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'protocol' property on 'LegacyUnforgeable': The provided value\\" - }); - - esValue[implSymbol][\\"protocol\\"] = V; - } - }) - ); - - Object.defineProperties(wrapper, { - assign: { configurable: false, writable: false }, - href: { configurable: false }, - toString: { configurable: false, writable: false }, - origin: { configurable: false }, - protocol: { configurable: false } - }); -}; +exports._internalSetup = (wrapper, globalObject) => {}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -13914,31 +15161,107 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyUnforgeable { + class MixedIn { constructor() { throw new TypeError(\\"Illegal constructor\\"); } + + mixedInOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'mixedInOp' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol].mixedInOp(); + } + + ifaceMixinOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'ifaceMixinOp' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol].ifaceMixinOp(); + } + + get mixedInAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol][\\"mixedInAttr\\"]; + } + + set mixedInAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" + }); + + esValue[implSymbol][\\"mixedInAttr\\"] = V; + } + + get ifaceMixinAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + } + + set ifaceMixinAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" + }); + + esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + } } - Object.defineProperties(LegacyUnforgeable.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyUnforgeable\\", configurable: true } + Object.defineProperties(MixedIn.prototype, { + mixedInOp: { enumerable: true }, + ifaceMixinOp: { enumerable: true }, + mixedInAttr: { enumerable: true }, + ifaceMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } + }); + Object.defineProperties(MixedIn, { + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyUnforgeable; + globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: LegacyUnforgeable + value: MixedIn }); }; -const Impl = require(\\"../implementations/LegacyUnforgeable.js\\"); +const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`without processors LegacyUnforgeableMap.webidl 1`] = ` +exports[`without processors NoUselessIfElse.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13947,7 +15270,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyUnforgeableMap\\"; +const interfaceName = \\"NoUselessIfElse\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13959,7 +15282,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyUnforgeableMap'.\`); + throw new TypeError(\`\${context} is not of type 'NoUselessIfElse'.\`); }; function makeWrapper(globalObject) { @@ -13967,9 +15290,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeableMap\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"NoUselessIfElse\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyUnforgeableMap is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor NoUselessIfElse is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -13985,24 +15308,7 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => { - Object.defineProperties( - wrapper, - Object.getOwnPropertyDescriptors({ - get a() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get a' called on an object that is not a valid instance of LegacyUnforgeableMap.\\"); - } - - return esValue[implSymbol][\\"a\\"]; - } - }) - ); - - Object.defineProperties(wrapper, { a: { configurable: false } }); -}; +exports._internalSetup = (wrapper, globalObject) => {}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -14013,8 +15319,6 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) configurable: true }); - wrapper = new Proxy(wrapper, proxyHandler); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -14023,7 +15327,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = globalObject => { - let wrapper = makeWrapper(globalObject); + const wrapper = makeWrapper(globalObject); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -14031,8 +15335,6 @@ exports.new = globalObject => { configurable: true }); - wrapper = new Proxy(wrapper, proxyHandler); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -14046,391 +15348,743 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyUnforgeableMap { + class NoUselessIfElse { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - } - Object.defineProperties(LegacyUnforgeableMap.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyUnforgeableMap\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyUnforgeableMap; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: LegacyUnforgeableMap - }); -}; - -const proxyHandler = { - get(target, P, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.get(target, P, receiver); - } - const desc = this.getOwnPropertyDescriptor(target, P); - if (desc === undefined) { - const parent = Object.getPrototypeOf(target); - if (parent === null) { - return undefined; + overloadsObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return Reflect.get(target, P, receiver); - } - if (!desc.get && !desc.set) { - return desc.value; - } - const getter = desc.get; - if (getter === undefined) { - return undefined; - } - return Reflect.apply(getter, receiver, []); - }, - - has(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.has(target, P); - } - const desc = this.getOwnPropertyDescriptor(target, P); - if (desc !== undefined) { - return true; - } - const parent = Object.getPrototypeOf(target); - if (parent !== null) { - return Reflect.has(parent, P); - } - return false; - }, - - ownKeys(target) { - const keys = new Set(); - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBoolean(...args)); } - for (const key of Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - }, - - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - let ignoreNamedProps = false; - - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { - const namedValue = target[implSymbol][utils.namedGet](P); + overloadsObjectOrBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumeric(...args)); } - return Reflect.getOwnPropertyDescriptor(target, P); - }, + overloadsObjectOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumeric(...args)); } - // The \`receiver\` argument refers to the Proxy exotic object or an object - // that inherits from it, whereas \`target\` refers to the Proxy target: - if (target[implSymbol][utils.wrapperSymbol] === receiver) { - if (typeof P === \\"string\\") { - let namedValue = V; - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" - }); + overloadsBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } } - - return true; } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumeric(...args)); } - let ownDesc; - if (ownDesc === undefined) { - ownDesc = Reflect.getOwnPropertyDescriptor(target, P); - } - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - if (parent !== null) { - return Reflect.set(parent, P, V, receiver); + overloadsObjectOrBooleanOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; - } - if (!ownDesc.writable) { - return false; - } - if (!utils.isObject(receiver)) { - return false; - } - const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); - let valueDesc; - if (existingDesc !== undefined) { - if (existingDesc.get || existingDesc.set) { - return false; + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - if (!existingDesc.writable) { - return false; + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } } - valueDesc = { value: V }; - } else { - valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; - } - return Reflect.defineProperty(receiver, P, valueDesc); - }, - - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrString(...args)); } - if (![\\"a\\"].includes(P)) { - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; - } - - let namedValue = desc.value; - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" - }); + overloadsObjectOrBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } } - - return true; } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumericOrString(...args)); } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + overloadsObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - return false; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumericOrString(...args)); } - return Reflect.deleteProperty(target, P); - }, - - preventExtensions() { - return false; - } -}; - -const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); -" -`; - -exports[`without processors MixedIn.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"MixedIn\\"; - -exports.is = value => { - return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = value => { - return utils.isObject(value) && value instanceof Impl.implementation; -}; -exports.convert = (value, { context = \\"The provided value\\" } = {}) => { - if (exports.is(value)) { - return utils.implForWrapper(value); - } - throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); -}; - -function makeWrapper(globalObject) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } - - const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); - } - - return Object.create(ctor.prototype); -} - -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; - -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; - -exports._internalSetup = (wrapper, globalObject) => {}; - -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper; -}; + overloadsBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports.new = globalObject => { - const wrapper = makeWrapper(globalObject); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumericOrString(...args)); + } - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true - }); + unionObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBoolean(...args)); + } -const exposed = new Set([\\"Window\\"]); + unionObjectOrBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class MixedIn { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumeric(...args)); } - mixedInOp() { + unionObjectOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'mixedInOp' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol].mixedInOp(); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumeric(...args)); } - ifaceMixinOp() { + unionBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'ifaceMixinOp' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol].ifaceMixinOp(); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); } - get mixedInAttr() { + unionObjectOrBooleanOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol][\\"mixedInAttr\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrString(...args)); } - set mixedInAttr(V) { + unionObjectOrBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"mixedInAttr\\"] = V; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumericOrString(...args)); } - get ifaceMixinAttr() { + unionObjectOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumericOrString(...args)); } - set ifaceMixinAttr(V) { + unionBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; - } - } - Object.defineProperties(MixedIn.prototype, { - mixedInOp: { enumerable: true }, - ifaceMixinOp: { enumerable: true }, - mixedInAttr: { enumerable: true }, - ifaceMixinAttr: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, - mixedInConst: { value: 43, enumerable: true }, - ifaceMixinConst: { value: 42, enumerable: true } - }); - Object.defineProperties(MixedIn, { - mixedInConst: { value: 43, enumerable: true }, - ifaceMixinConst: { value: 42, enumerable: true } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumericOrString(...args)); + } + } + Object.defineProperties(NoUselessIfElse.prototype, { + overloadsObjectOrBoolean: { enumerable: true }, + overloadsObjectOrBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrNumeric: { enumerable: true }, + overloadsBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrBooleanOrString: { enumerable: true }, + overloadsObjectOrBooleanOrNumericOrString: { enumerable: true }, + overloadsObjectOrNumericOrString: { enumerable: true }, + overloadsBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrBoolean: { enumerable: true }, + unionObjectOrBooleanOrNumeric: { enumerable: true }, + unionObjectOrNumeric: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionObjectOrBooleanOrString: { enumerable: true }, + unionObjectOrBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrNumericOrString: { enumerable: true }, + unionBooleanOrNumericOrString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"NoUselessIfElse\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; + globalObject[ctorRegistrySymbol][interfaceName] = NoUselessIfElse; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: MixedIn + value: NoUselessIfElse }); }; -const Impl = require(\\"../implementations/MixedIn.js\\"); +const Impl = require(\\"../implementations/NoUselessIfElse.js\\"); " `; diff --git a/test/cases/NoUselessIfElse.webidl b/test/cases/NoUselessIfElse.webidl new file mode 100644 index 00000000..5a278f56 --- /dev/null +++ b/test/cases/NoUselessIfElse.webidl @@ -0,0 +1,46 @@ +[Exposed=Window] +interface NoUselessIfElse { + // # Overloads: + undefined overloadsObjectOrBoolean(object arg1); + undefined overloadsObjectOrBoolean(boolean arg1); + + undefined overloadsObjectOrBooleanOrNumeric(object arg1); + undefined overloadsObjectOrBooleanOrNumeric(boolean arg1); + undefined overloadsObjectOrBooleanOrNumeric(long arg1); + + undefined overloadsObjectOrNumeric(object arg1); + undefined overloadsObjectOrNumeric(long arg1); + + undefined overloadsBooleanOrNumeric(boolean arg1); + undefined overloadsBooleanOrNumeric(long arg1); + + // ## Avoid regressions: + undefined overloadsObjectOrBooleanOrString(object arg1); + undefined overloadsObjectOrBooleanOrString(boolean arg1); + undefined overloadsObjectOrBooleanOrString(DOMString arg1); + + undefined overloadsObjectOrBooleanOrNumericOrString(object arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(boolean arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(long arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(DOMString arg1); + + undefined overloadsObjectOrNumericOrString(object arg1); + undefined overloadsObjectOrNumericOrString(long arg1); + undefined overloadsObjectOrNumericOrString(DOMString arg1); + + undefined overloadsBooleanOrNumericOrString(boolean arg1); + undefined overloadsBooleanOrNumericOrString(long arg1); + undefined overloadsBooleanOrNumericOrString(DOMString arg1); + + // # Unions: + undefined unionObjectOrBoolean((object or boolean) arg1); + undefined unionObjectOrBooleanOrNumeric((object or boolean or long) arg1); + undefined unionObjectOrNumeric((object or long) arg1); + undefined unionBooleanOrNumeric((boolean or long) arg1); + + // ## Avoid regressions: + undefined unionObjectOrBooleanOrString((object or boolean or DOMString) arg1); + undefined unionObjectOrBooleanOrNumericOrString((object or boolean or long or DOMString) arg1); + undefined unionObjectOrNumericOrString((object or long or DOMString) arg1); + undefined unionBooleanOrNumericOrString((boolean or long or DOMString) arg1); +}; From c483c427336cbff5cf3570e086bd204f09d344b8 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 26 Nov 2020 17:30:00 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Avoid=C2=A0useless=20`if`=E2=80=91`else`?= =?UTF-8?q?=C2=A0check=20during=C2=A0fallback=20type=C2=A0conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/parameters.js | 41 ++++++++------ lib/types.js | 33 ++++++------ test/__snapshots__/test.js.snap | 96 --------------------------------- 3 files changed, 42 insertions(+), 128 deletions(-) diff --git a/lib/parameters.js b/lib/parameters.js index adfab32f..22c975a1 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -273,32 +273,41 @@ module.exports.generateOverloadConversions = function (ctx, typeOfOp, name, pare } const booleans = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => t.idlType === "boolean")); - if (booleans.length) { - possibilities.push(` - if (typeof curArg === "boolean") { - ${continued(booleans[0], i)} - } - `); - } - const numerics = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => Types.numericTypes.has(t.idlType))); - if (numerics.length) { - possibilities.push(` - if (typeof curArg === "number") { - ${continued(numerics[0], i)} - } - `); - } - const strings = S.filter(o => { return isOrIncludes(ctx, o.typeList[d], t => { return Types.stringTypes.has(t.idlType) || ctx.enumerations.has(t.idlType); }); }); + const any = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => t.idlType === "any")); if (strings.length) { + if (booleans.length) { + possibilities.push(` + if (typeof curArg === "boolean") { + ${continued(booleans[0], i)} + } + `); + } + + if (numerics.length) { + possibilities.push(` + if (typeof curArg === "number") { + ${continued(numerics[0], i)} + } + `); + } + possibilities.push(`{ ${continued(strings[0], i)} }`); } else if (numerics.length) { + if (booleans.length) { + possibilities.push(` + if (typeof curArg === "boolean") { + ${continued(booleans[0], i)} + } + `); + } + possibilities.push(`{ ${continued(numerics[0], i)} }`); } else if (booleans.length) { possibilities.push(`{ ${continued(booleans[0], i)} }`); diff --git a/lib/types.js b/lib/types.js index c1d26ebf..03d048ac 100644 --- a/lib/types.js +++ b/lib/types.js @@ -273,25 +273,26 @@ function generateTypeConversion(ctx, name, idlType, argAttrs = [], parentName, e output.push(code); } - if (union.boolean) { - output.push(` - if (typeof ${name} === "boolean") { - ${generateTypeConversion(ctx, name, union.boolean, [], parentName, errPrefix).body} - } - `); - } + { + const { string, numeric, boolean } = union; + if (boolean && (string || numeric)) { + output.push(` + if (typeof ${name} === "boolean") { + ${generateTypeConversion(ctx, name, boolean, [], parentName, errPrefix).body} + } + `); + } - if (union.numeric) { - output.push(` - if (typeof ${name} === "number") { - ${generateTypeConversion(ctx, name, union.numeric, [], parentName, errPrefix).body} - } - `); - } + if (numeric && string) { + output.push(` + if (typeof ${name} === "number") { + ${generateTypeConversion(ctx, name, numeric, [], parentName, errPrefix).body} + } + `); + } - { let code = "{"; - const type = union.string || union.numeric || union.boolean; + const type = string || numeric || boolean; if (type) { const conv = generateTypeConversion(ctx, name, type, [], parentName, errPrefix); code += conv.body; diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 2df3ac36..cdf200b5 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -4441,14 +4441,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"boolean\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"boolean\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -4496,14 +4488,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -4543,14 +4527,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -4590,14 +4566,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -4831,10 +4799,6 @@ exports.install = (globalObject, globalNames) => { } else if (ArrayBuffer.isView(curArg)) { } else if (typeof curArg === \\"function\\") { } else if (utils.isObject(curArg)) { - } else if (typeof curArg === \\"boolean\\") { - curArg = conversions[\\"boolean\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" @@ -4873,10 +4837,6 @@ exports.install = (globalObject, globalNames) => { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" @@ -4911,10 +4871,6 @@ exports.install = (globalObject, globalNames) => { } else if (ArrayBuffer.isView(curArg)) { } else if (typeof curArg === \\"function\\") { } else if (utils.isObject(curArg)) { - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" @@ -4947,10 +4903,6 @@ exports.install = (globalObject, globalNames) => { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" @@ -15379,14 +15331,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"boolean\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"boolean\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -15434,14 +15378,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -15481,14 +15417,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -15528,14 +15456,6 @@ exports.install = (globalObject, globalNames) => { }); args.push(curArg); } - } else if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); - args.push(curArg); - } } else { { let curArg = arguments[0]; @@ -15769,10 +15689,6 @@ exports.install = (globalObject, globalNames) => { } else if (ArrayBuffer.isView(curArg)) { } else if (typeof curArg === \\"function\\") { } else if (utils.isObject(curArg)) { - } else if (typeof curArg === \\"boolean\\") { - curArg = conversions[\\"boolean\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" @@ -15811,10 +15727,6 @@ exports.install = (globalObject, globalNames) => { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" @@ -15849,10 +15761,6 @@ exports.install = (globalObject, globalNames) => { } else if (ArrayBuffer.isView(curArg)) { } else if (typeof curArg === \\"function\\") { } else if (utils.isObject(curArg)) { - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" @@ -15885,10 +15793,6 @@ exports.install = (globalObject, globalNames) => { curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" - }); } else { curArg = conversions[\\"long\\"](curArg, { context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\"