diff --git a/README.md b/README.md index c8182c17..5b131352 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,17 @@ It is often useful for implementation classes to inherit from each other, if the However, it is not required! The wrapper classes will have a correct inheritance chain, regardless of the implementation class inheritance chain. Just make sure that, either via inheritance or manual implementation, you implement all of the expected operations and attributes. +### The `[LegacyFactoryFunction]` extended attribute + +For interfaces which have the `[LegacyFactoryFunction]` extended attribute, the implementation class file must contain the `legacyFactoryFunction` export, with the signature `(thisValue, globalObject, [...legacyFactoryFunctionArgs], { newTarget, wrapper })`, which is used for: + +- Setting up initial state that will always be used, such as caches or default values +- `thisValue` holds the value of a new uninitialized implementation instance, which may be ignored by returning a different object, similarly to how constructors with overridden return values are implemented. +- Keep a reference to the relevant `globalObject` for later consumption. +- Processing constructor arguments `legacyFactoryFunctionArgs` passed to the legacy factory function constructor, if the legacy factory function takes arguments. +- `newTarget` holds a reference to the value of `new.target` that the legacy factor function was invoked with. +- `wrapper` holds a reference to the uninitialized wrapper instance, just like in `privateData` with the standard impl constructor. + ### The init export In addition to the `implementation` export, for interfaces, your implementation class file can contain an `init` export. This would be a function taking as an argument an instance of the implementation class, and is called when any wrapper/implementation pairs are constructed (such as by the exports of the [generated wrapper module](https://github.com/jsdom/webidl2js#for-interfaces)). In particular, it is called even if they are constructed by [`new()`](newglobalobject), which does not invoke the implementation class constructor. @@ -484,6 +495,7 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S - `[Clamp]` - `[EnforceRange]` - `[Exposed]` +- `[LegacyFactoryFunction]` - `[LegacyLenientThis]` - `[LegacyLenientSetter]` - `[LegacyNoInterfaceObject]` @@ -510,7 +522,6 @@ Notable missing features include: - `[AllowShared]` - `[Default]` (for `toJSON()` operations) - `[Global]`'s various consequences, including the named properties object and `[[SetPrototypeOf]]` -- `[LegacyFactoryFunction]` - `[LegacyNamespace]` - `[LegacyTreatNonObjectAsNull]` - `[SecureContext]` diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 3f20d12d..7b1b4d48 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -46,6 +46,7 @@ class Interface { this.attributes = new Map(); this.staticAttributes = new Map(); this.constants = new Map(); + this.legacyFactoryFunction = null; this.indexedGetter = null; this.indexedSetter = null; @@ -391,6 +392,24 @@ class Interface { throw new Error(msg); } } + + for (const attr of this.idl.extAttrs) { + if (attr.name === "LegacyFactoryFunction") { + if (!attr.rhs || attr.rhs.type !== "identifier" || !attr.arguments) { + throw new Error(`[LegacyFactoryFunction] must take a named argument list`); + } + + if (this.legacyFactoryFunction) { + // This is currently valid, but not used anywhere, and there are plans to disallow it: + // https://github.com/heycam/webidl/issues/878 + throw new Error( + `Multiple [LegacyFactoryFunction] definitions are not supported on ${this.name}` + ); + } + + this.legacyFactoryFunction = attr; + } + } } get supportsIndexedProperties() { @@ -1644,6 +1663,94 @@ class Interface { `; } + generateLegacyFactoryFunction() { + const { legacyFactoryFunction } = this; + if (!legacyFactoryFunction) { + return; + } + + const name = legacyFactoryFunction.rhs.value; + if (!name) { + throw new Error(`Internal error: The legacy factory function does not have a name (in interface ${this.name})`); + } + + const overloads = Overloads.getEffectiveOverloads("legacy factory function", name, 0, this); + let minOp = overloads[0]; + for (let i = 1; i < overloads.length; ++i) { + if (overloads[i].nameList.length < minOp.nameList.length) { + minOp = overloads[i]; + } + } + + const args = minOp.nameList; + const conversions = Parameters.generateOverloadConversions( + this.ctx, + "legacy factory function", + name, + this, + `Failed to construct '${name}': ` + ); + this.requires.merge(conversions.requires); + + const argsParam = conversions.hasArgs ? "args" : "[]"; + + this.str += ` + function ${name}(${utils.formatArgs(args)}) { + if (new.target === undefined) { + throw new TypeError("Class constructor ${name} cannot be invoked without 'new'"); + } + + ${conversions.body} + `; + + // This implements the WebIDL legacy factory function behavior, as well as support for overridding + // the return type, which is used by HTML's element legacy factory functions: + this.str += ` + ${this.isLegacyPlatformObj ? "let" : "const"} wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, ${argsParam}); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + `; + + if (this.isLegacyPlatformObj) { + this.str += ` + wrapper = ${this.needsPerGlobalProxyHandler ? + "makeProxy(wrapper, globalObject)" : + "new Proxy(wrapper, proxyHandler)"}; + `; + } + + this.str += ` + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(${name}, "prototype", { + configurable: false, + enumerable: false, + writable: false, + value: ${this.name}.prototype + }) + + Object.defineProperty(globalObject, "${name}", { + configurable: true, + writable: true, + value: ${name} + }); + `; + } + generateInstall() { const { idl, name } = this; @@ -1712,6 +1819,8 @@ class Interface { } } + this.generateLegacyFactoryFunction(); + this.str += ` }; `; diff --git a/lib/overloads.js b/lib/overloads.js index 53668234..a9b11b1d 100644 --- a/lib/overloads.js +++ b/lib/overloads.js @@ -11,6 +11,8 @@ function getOperations(type, A, I) { case "constructor": { return I.constructorOperations; } + case "legacy factory function": + return [I.legacyFactoryFunction]; } throw new RangeError(`${type}s are not yet supported`); } diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index c2f16237..11acc439 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -3311,7 +3311,7 @@ const Impl = require(\\"../implementations/Global.js\\"); " `; -exports[`generation with processors HTMLConstructor.webidl 1`] = ` +exports[`generation with processors HTMLAudioElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -3321,7 +3321,7 @@ const HTMLConstructor_HTMLConstructor = require(\\"../HTMLConstructor.js\\").HTM const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"HTMLConstructor\\"; +const interfaceName = \\"HTMLAudioElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -3333,7 +3333,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 'HTMLAudioElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -3343,7 +3343,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLAudioElement\\"].prototype; } return Object.create(proto); @@ -3401,37 +3401,83 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class HTMLConstructor { + class HTMLAudioElement { constructor() { return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); } } - Object.defineProperties(HTMLConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + Object.defineProperties(HTMLAudioElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLAudioElement\\", configurable: true } }); - ctorRegistry[interfaceName] = HTMLConstructor; + ctorRegistry[interfaceName] = HTMLAudioElement; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: HTMLConstructor + value: HTMLAudioElement + }); + + function Audio() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); + } + + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); + } + args.push(curArg); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(Audio, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLAudioElement.prototype + }); + + Object.defineProperty(globalObject, \\"Audio\\", { + configurable: true, + writable: true, + value: Audio }); }; -const Impl = require(\\"../implementations/HTMLConstructor.js\\"); +const Impl = require(\\"../implementations/HTMLAudioElement.js\\"); " `; -exports[`generation with processors LegacyLenientAttributes.webidl 1`] = ` +exports[`generation with processors HTMLConstructor.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const HTMLConstructor_HTMLConstructor = require(\\"../HTMLConstructor.js\\").HTMLConstructor; const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyLenientAttributes\\"; +const interfaceName = \\"HTMLConstructor\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -3443,7 +3489,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 'HTMLConstructor'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -3453,7 +3499,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"].prototype; } return Object.create(proto); @@ -3511,131 +3557,38 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class LegacyLenientAttributes { + class HTMLConstructor { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - 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\\"]; - } - - set lenientSetter(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError( - \\"'set lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" - ); - } - } - - 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 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" - }); - - 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 - }); + return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); } } - 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 } + Object.defineProperties(HTMLConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } }); - ctorRegistry[interfaceName] = LegacyLenientAttributes; + ctorRegistry[interfaceName] = HTMLConstructor; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: LegacyLenientAttributes + value: HTMLConstructor }); }; -const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); +const Impl = require(\\"../implementations/HTMLConstructor.js\\"); " `; -exports[`generation with processors LegacyNoInterfaceObject.webidl 1`] = ` +exports[`generation with processors HTMLImageElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const HTMLConstructor_HTMLConstructor = require(\\"../HTMLConstructor.js\\").HTMLConstructor; const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyNoInterfaceObject\\"; +const interfaceName = \\"HTMLImageElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -3647,7 +3600,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyNoInterfaceObject'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLImageElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -3657,7 +3610,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"LegacyNoInterfaceObject\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLImageElement\\"].prototype; } return Object.create(proto); @@ -3715,67 +3668,90 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class LegacyNoInterfaceObject { + class HTMLImageElement { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); } + } + Object.defineProperties(HTMLImageElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLImageElement\\", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLImageElement; - def() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'def' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLImageElement + }); - return esValue[implSymbol].def(); + function Image() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); } - get abc() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get abc' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); } - - return esValue[implSymbol][\\"abc\\"]; + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); + } + args.push(curArg); } - set abc(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); - if (!exports.is(esValue)) { - throw new TypeError(\\"'set abc' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); - } + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'abc' property on 'LegacyNoInterfaceObject': The provided value\\" - }); + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); - esValue[implSymbol][\\"abc\\"] = V; + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); } + return wrapper; } - delete LegacyNoInterfaceObject.constructor; - Object.defineProperties(LegacyNoInterfaceObject.prototype, { - def: { enumerable: true }, - abc: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"LegacyNoInterfaceObject\\", configurable: true } + + Object.defineProperty(Image, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLImageElement.prototype + }); + + Object.defineProperty(globalObject, \\"Image\\", { + configurable: true, + writable: true, + value: Image }); - ctorRegistry[interfaceName] = LegacyNoInterfaceObject; }; -const Impl = require(\\"../implementations/LegacyNoInterfaceObject.js\\"); +const Impl = require(\\"../implementations/HTMLImageElement.js\\"); " `; -exports[`generation with processors LegacyUnforgeable.webidl 1`] = ` +exports[`generation with processors HTMLOptionElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const HTMLConstructor_HTMLConstructor = require(\\"../HTMLConstructor.js\\").HTMLConstructor; const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyUnforgeable\\"; +const interfaceName = \\"HTMLOptionElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -3787,7 +3763,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 'HTMLOptionElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -3797,7 +3773,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLOptionElement\\"].prototype; } return Object.create(proto); @@ -3813,127 +3789,23 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -function getUnforgeables(globalObject) { - let unforgeables = unforgeablesMap.get(globalObject); - if (unforgeables === undefined) { - unforgeables = Object.create(null); - utils.define(unforgeables, { - 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.\\"); - } +exports._internalSetup = (wrapper, globalObject) => {}; - 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; +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - 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(unforgeables, { - assign: { configurable: false, writable: false }, - href: { configurable: false }, - toString: { configurable: false, writable: false }, - origin: { configurable: false }, - protocol: { configurable: false } - }); - unforgeablesMap.set(globalObject, unforgeables); - } - return unforgeables; -} - -exports._internalSetup = (wrapper, globalObject) => { - utils.define(wrapper, getUnforgeables(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; -}; + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; exports.new = (globalObject, newTarget) => { const wrapper = makeWrapper(globalObject, newTarget); @@ -3951,7 +3823,6 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -3960,28 +3831,100 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class LegacyUnforgeable { + class HTMLOptionElement { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); } } - Object.defineProperties(LegacyUnforgeable.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyUnforgeable\\", configurable: true } + Object.defineProperties(HTMLOptionElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLOptionElement\\", configurable: true } }); - ctorRegistry[interfaceName] = LegacyUnforgeable; + ctorRegistry[interfaceName] = HTMLOptionElement; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: LegacyUnforgeable + value: HTMLOptionElement + }); + + function Option() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); + } + + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); + } else { + curArg = \\"\\"; + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); + } else { + curArg = false; + } + args.push(curArg); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(Option, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLOptionElement.prototype + }); + + Object.defineProperty(globalObject, \\"Option\\", { + configurable: true, + writable: true, + value: Option }); }; -const Impl = require(\\"../implementations/LegacyUnforgeable.js\\"); +const Impl = require(\\"../implementations/HTMLOptionElement.js\\"); " `; -exports[`generation with processors LegacyUnforgeableMap.webidl 1`] = ` +exports[`generation with processors LegacyLenientAttributes.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -3990,7 +3933,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyUnforgeableMap\\"; +const interfaceName = \\"LegacyLenientAttributes\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -4002,7 +3945,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 'LegacyLenientAttributes'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -4012,7 +3955,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeableMap\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"].prototype; } return Object.create(proto); @@ -4028,32 +3971,7 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -function getUnforgeables(globalObject) { - let unforgeables = unforgeablesMap.get(globalObject); - if (unforgeables === undefined) { - unforgeables = Object.create(null); - utils.define(unforgeables, { - 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(unforgeables, { - a: { configurable: false } - }); - unforgeablesMap.set(globalObject, unforgeables); - } - return unforgeables; -} - -exports._internalSetup = (wrapper, globalObject) => { - utils.define(wrapper, getUnforgeables(globalObject)); -}; +exports._internalSetup = (wrapper, globalObject) => {}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -4064,8 +3982,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]); @@ -4074,7 +3990,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - let wrapper = makeWrapper(globalObject, newTarget); + const wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -4082,8 +3998,6 @@ exports.new = (globalObject, newTarget) => { configurable: true }); - wrapper = new Proxy(wrapper, proxyHandler); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -4091,7 +4005,6 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -4100,205 +4013,122 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class LegacyUnforgeableMap { + class LegacyLenientAttributes { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - } - Object.defineProperties(LegacyUnforgeableMap.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyUnforgeableMap\\", configurable: true } - }); - ctorRegistry[interfaceName] = LegacyUnforgeableMap; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: LegacyUnforgeableMap - }); -}; + get lenientSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; -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; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'get lenientSetter' called on an object that is not a valid instance of LegacyLenientAttributes.\\" + ); } - 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 esValue[implSymbol][\\"lenientSetter\\"]; } - return false; - }, - ownKeys(target) { - const keys = new Set(); + set lenientSetter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); + 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 Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - }, - - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - let ignoreNamedProps = false; + get lenientThisSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { - const namedValue = target[implSymbol][utils.namedGet](P); + if (!exports.is(esValue)) { + return; + } - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; + return esValue[implSymbol][\\"lenientThisSetter\\"]; } - return Reflect.getOwnPropertyDescriptor(target, P); - }, - - 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; - - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" - }); + set lenientThisSetter(V) {} - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } + get lenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; - return true; + if (!exports.is(esValue)) { + return; } - } - 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); - } - 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 esValue[implSymbol][\\"lenientThis\\"]; } - return Reflect.defineProperty(receiver, P, valueDesc); - }, - 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; - } + set lenientThis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - let namedValue = desc.value; + if (!exports.is(esValue)) { + return; + } - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" - }); + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': 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); - } + esValue[implSymbol][\\"lenientThis\\"] = V; + } - return true; + get readonlyLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; } - } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); + return esValue[implSymbol][\\"readonlyLenientThis\\"]; } - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - return false; + get replaceableLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"replaceableLenientThis\\"]; } - return Reflect.deleteProperty(target, P); - }, + set replaceableLenientThis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - preventExtensions() { - return false; + 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 } + }); + ctorRegistry[interfaceName] = LegacyLenientAttributes; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: LegacyLenientAttributes + }); }; -const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); +const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); " `; -exports[`generation with processors MixedIn.webidl 1`] = ` +exports[`generation with processors LegacyNoInterfaceObject.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -4307,7 +4137,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"MixedIn\\"; +const interfaceName = \\"LegacyNoInterfaceObject\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -4319,7 +4149,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyNoInterfaceObject'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -4329,7 +4159,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"MixedIn\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"LegacyNoInterfaceObject\\"].prototype; } return Object.create(proto); @@ -4387,142 +4217,243 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class MixedIn { + class LegacyNoInterfaceObject { 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) { + def() { 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(\\"'def' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"mixedInAttr\\"] = V; + return esValue[implSymbol].def(); } - get ifaceMixinAttr() { + get abc() { 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(\\"'get abc' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); } - return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + return esValue[implSymbol][\\"abc\\"]; } - set ifaceMixinAttr(V) { + set abc(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.\\"); + throw new TypeError(\\"'set abc' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); } V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" + context: \\"Failed to set the 'abc' property on 'LegacyNoInterfaceObject': The provided value\\" }); - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + esValue[implSymbol][\\"abc\\"] = 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 } - }); - ctorRegistry[interfaceName] = MixedIn; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: MixedIn + delete LegacyNoInterfaceObject.constructor; + Object.defineProperties(LegacyNoInterfaceObject.prototype, { + def: { enumerable: true }, + abc: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyNoInterfaceObject\\", configurable: true } }); + ctorRegistry[interfaceName] = LegacyNoInterfaceObject; }; -const Impl = require(\\"../implementations/MixedIn.js\\"); +const Impl = require(\\"../implementations/LegacyNoInterfaceObject.js\\"); " `; -exports[`generation with processors NodeFilter.webidl 1`] = ` +exports[`generation with processors LegacyUnforgeable.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; - } +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - node = utils.tryWrapperForImpl(node); +const interfaceName = \\"LegacyUnforgeable\\"; - let callResult = Reflect.apply(X, thisArg, [node]); +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 'LegacyUnforgeable'.\`); +}; - callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } - return callResult; + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"].prototype; } - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; + return Object.create(proto); +} - return callTheUserObjectsOperation; +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); +}; + +function getUnforgeables(globalObject) { + let unforgeables = unforgeablesMap.get(globalObject); + if (unforgeables === undefined) { + unforgeables = Object.create(null); + utils.define(unforgeables, { + 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(unforgeables, { + assign: { configurable: false, writable: false }, + href: { configurable: false }, + toString: { configurable: false, writable: false }, + origin: { configurable: false }, + protocol: { configurable: false } + }); + unforgeablesMap.set(globalObject, unforgeables); + } + return unforgeables; +} + +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, getUnforgeables(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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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 unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -4530,49 +4461,38 @@ exports.install = (globalObject, globalNames) => { 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 } + const ctorRegistry = utils.initCtorRegistry(globalObject); + class LegacyUnforgeable { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(LegacyUnforgeable.prototype, { + [Symbol.toStringTag]: { value: \\"LegacyUnforgeable\\", configurable: true } }); + ctorRegistry[interfaceName] = LegacyUnforgeable; - Object.defineProperty(globalObject, \\"NodeFilter\\", { + Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: NodeFilter + value: LegacyUnforgeable }); }; + +const Impl = require(\\"../implementations/LegacyUnforgeable.js\\"); " `; -exports[`generation with processors Overloads.webidl 1`] = ` +exports[`generation with processors LegacyUnforgeableMap.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 = \\"LegacyUnforgeableMap\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -4584,7 +4504,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 'LegacyUnforgeableMap'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -4594,7 +4514,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"Overloads\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeableMap\\"].prototype; } return Object.create(proto); @@ -4610,7 +4530,32 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => {}; +function getUnforgeables(globalObject) { + let unforgeables = unforgeablesMap.get(globalObject); + if (unforgeables === undefined) { + unforgeables = Object.create(null); + utils.define(unforgeables, { + 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(unforgeables, { + a: { configurable: false } + }); + unforgeablesMap.set(globalObject, unforgeables); + } + return unforgeables; +} + +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, getUnforgeables(globalObject)); +}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -4621,6 +4566,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]); @@ -4629,7 +4576,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); + let wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -4637,6 +4584,8 @@ exports.new = (globalObject, newTarget) => { configurable: true }); + wrapper = new Proxy(wrapper, proxyHandler); + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -4644,6 +4593,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; +const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -4652,10 +4602,879 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Overloads { + class LegacyUnforgeableMap { constructor() { - const args = []; - switch (arguments.length) { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(LegacyUnforgeableMap.prototype, { + [Symbol.toStringTag]: { value: \\"LegacyUnforgeableMap\\", configurable: true } + }); + ctorRegistry[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; + } + 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}\`); + } + } + + 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); + + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + }, + + 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; + + 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); + } + + return true; + } + } + 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); + } + 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); + }, + + 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; + } + + 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); + } + + return true; + } + } + return Reflect.defineProperty(target, P, desc); + }, + + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } + + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + }, + + preventExtensions() { + return false; + } +}; + +const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); +" +`; + +exports[`generation with processors MinArgsLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"MinArgsLegacyFactoryFunctionInterface\\"; + +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 'MinArgsLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"MinArgsLegacyFactoryFunctionInterface\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MinArgsLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(MinArgsLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"MinArgsLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = MinArgsLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MinArgsLegacyFactoryFunctionInterface + }); + + function MinArgsLegacyFactoryFunction(arg1) { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor MinArgsLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to construct 'MinArgsLegacyFactoryFunction': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'MinArgsLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'MinArgsLegacyFactoryFunction': parameter 2\\" + }); + } + args.push(curArg); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(MinArgsLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: MinArgsLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"MinArgsLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: MinArgsLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/MinArgsLegacyFactoryFunctionInterface.js\\"); +" +`; + +exports[`generation with 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, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"MixedIn\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + 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(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 } + }); + ctorRegistry[interfaceName] = MixedIn; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MixedIn + }); +}; + +const Impl = require(\\"../implementations/MixedIn.js\\"); +" +`; + +exports[`generation with processors NoArgLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"NoArgLegacyFactoryFunctionInterface\\"; + +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 'NoArgLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"NoArgLegacyFactoryFunctionInterface\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class NoArgLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(NoArgLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"NoArgLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = NoArgLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunctionInterface + }); + + function NoArgLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor NoArgLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, []); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(NoArgLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: NoArgLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"NoArgLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/NoArgLegacyFactoryFunctionInterface.js\\"); +" +`; + +exports[`generation 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[`generation 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; +}; +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 'Overloads'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"Overloads\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Overloads { + constructor() { + const args = []; + switch (arguments.length) { case 0: break; default: { @@ -8108,56 +8927,375 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { " `; -exports[`generation with processors URLHandlerNonNull.webidl 1`] = ` -"\\"use strict\\"; +exports[`generation with processors URLHandlerNonNull.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + function invokeTheCallbackFunction(url) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + if (typeof value === \\"function\\") { + url = utils.tryWrapperForImpl(url); + + callResult = Reflect.apply(value, thisArg, [url]); + } + + callResult = conversions[\\"any\\"](callResult, { context: context }); + + return callResult; + } + + invokeTheCallbackFunction.construct = url => { + url = utils.tryWrapperForImpl(url); + + let callResult = Reflect.construct(value, [url]); + + callResult = conversions[\\"any\\"](callResult, { context: context }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; +" +`; + +exports[`generation with processors URLList.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"URLList\\"; + +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 'URLList'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"URLList\\"].prototype; + } + + return Object.create(proto); +} + +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 = new Proxy(wrapper, proxyHandler); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = new Proxy(wrapper, proxyHandler); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class URLList { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'item' called on an object that is not a valid instance of URLList.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get length' called on an object that is not a valid instance of URLList.\\"); + } + + return esValue[implSymbol][\\"length\\"]; + } + } + Object.defineProperties(URLList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLList\\", configurable: true }, + [Symbol.iterator]: { + value: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], + configurable: true, + writable: true + }, + keys: { value: ctorRegistry[\\"%Array%\\"].prototype.keys, configurable: true, enumerable: true, writable: true }, + values: { value: ctorRegistry[\\"%Array%\\"].prototype.values, configurable: true, enumerable: true, writable: true }, + entries: { value: ctorRegistry[\\"%Array%\\"].prototype.entries, configurable: true, enumerable: true, writable: true }, + forEach: { value: ctorRegistry[\\"%Array%\\"].prototype.forEach, configurable: true, enumerable: true, writable: true } + }); + ctorRegistry[interfaceName] = URLList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URLList + }); +}; + +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, []); + }, + + 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.supportedPropertyIndices]) { + keys.add(\`\${key}\`); + } + + 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 (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } -exports.convert = (value, { context = \\"The provided value\\" } = {}) => { - function invokeTheCallbackFunction(url) { - const thisArg = utils.tryWrapperForImpl(this); - let callResult; + return Reflect.getOwnPropertyDescriptor(target, P); + }, - if (typeof value === \\"function\\") { - url = utils.tryWrapperForImpl(url); + 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) { + } + let ownDesc; - callResult = Reflect.apply(value, thisArg, [url]); + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } } - callResult = conversions[\\"any\\"](callResult, { context: context }); + 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); + }, - return callResult; - } + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); + } - invokeTheCallbackFunction.construct = url => { - url = utils.tryWrapperForImpl(url); + if (utils.isArrayIndexPropName(P)) { + return false; + } - let callResult = Reflect.construct(value, [url]); + return Reflect.defineProperty(target, P, desc); + }, - callResult = conversions[\\"any\\"](callResult, { context: context }); + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } - return callResult; - }; + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } - invokeTheCallbackFunction[utils.wrapperSymbol] = value; - invokeTheCallbackFunction.objectReference = value; + return Reflect.deleteProperty(target, P); + }, - return invokeTheCallbackFunction; + preventExtensions() { + return false; + } }; + +const Impl = require(\\"../implementations/URLList.js\\"); " `; -exports[`generation with processors URLList.webidl 1`] = ` +exports[`generation with processors URLSearchParams.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const Function = require(\\"./Function.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"URLList\\"; +const interfaceName = \\"URLSearchParams\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -8169,7 +9307,18 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'URLList'.\`); + throw new TypeError(\`\${context} is not of type 'URLSearchParams'.\`); +}; + +exports.createDefaultIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const iteratorPrototype = ctorRegistry[\\"URLSearchParams Iterator\\"]; + const iterator = Object.create(iteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, index: 0 }, + configurable: true + }); + return iterator; }; function makeWrapper(globalObject, newTarget) { @@ -8179,7 +9328,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"URLList\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"URLSearchParams\\"].prototype; } return Object.create(proto); @@ -8206,8 +9355,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]); @@ -8216,7 +9363,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - let wrapper = makeWrapper(globalObject, newTarget); + const wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -8224,8 +9371,6 @@ exports.new = (globalObject, newTarget) => { configurable: true }); - wrapper = new Proxy(wrapper, proxyHandler); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -8233,7 +9378,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Window\\", \\"Worker\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -8241,242 +9386,376 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class URLList { + class URLSearchParams { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (!utils.isObject(nextItem)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + + \\" sequence\\" + + \\"'s element\\" + + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = nextItem; + for (let nextItem of tmp) { + nextItem = conversions[\\"USVString\\"](nextItem, { + context: + \\"Failed to construct 'URLSearchParams': parameter 1\\" + + \\" sequence\\" + + \\"'s element\\" + + \\"'s element\\" + }); + + V.push(nextItem); + } + nextItem = V; + } + + V.push(nextItem); + } + curArg = V; + } + } else { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" + }); + + let typedValue = curArg[key]; + + typedValue = conversions[\\"USVString\\"](typedValue, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" + }); + + result[typedKey] = typedValue; + } + } + curArg = result; + } + } + } else { + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + }); + } + } else { + curArg = \\"\\"; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + append(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'append' called on an object that is not a valid instance of URLSearchParams.\\"); + } + + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); + } + return esValue[implSymbol].append(...args); } - item(index) { + delete(name) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'item' called on an object that is not a valid instance of URLList.\\"); + throw new TypeError(\\"'delete' called on an object that is not a valid instance of URLSearchParams.\\"); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" + \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" }); args.push(curArg); } - return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + return esValue[implSymbol].delete(...args); } - get length() { + get(name) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get length' called on an object that is not a valid instance of URLList.\\"); + throw new TypeError(\\"'get' called on an object that is not a valid instance of URLSearchParams.\\"); } - return esValue[implSymbol][\\"length\\"]; - } - } - Object.defineProperties(URLList.prototype, { - item: { enumerable: true }, - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLList\\", configurable: true }, - [Symbol.iterator]: { - value: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], - configurable: true, - writable: true - }, - keys: { value: ctorRegistry[\\"%Array%\\"].prototype.keys, configurable: true, enumerable: true, writable: true }, - values: { value: ctorRegistry[\\"%Array%\\"].prototype.values, configurable: true, enumerable: true, writable: true }, - entries: { value: ctorRegistry[\\"%Array%\\"].prototype.entries, configurable: true, enumerable: true, writable: true }, - forEach: { value: ctorRegistry[\\"%Array%\\"].prototype.forEach, configurable: true, enumerable: true, writable: true } - }); - ctorRegistry[interfaceName] = URLList; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: URLList - }); -}; - -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; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - 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); + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].get(...args); } - return false; - }, - ownKeys(target) { - const keys = new Set(); + getAll(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'getAll' called on an object that is not a valid instance of URLSearchParams.\\"); + } - for (const key of target[implSymbol][utils.supportedPropertyIndices]) { - keys.add(\`\${key}\`); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args)); } - for (const key of Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - }, + has(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'has' called on an object that is not a valid instance of URLSearchParams.\\"); + } - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].has(...args); } - let ignoreNamedProps = false; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; + set(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set' called on an object that is not a valid instance of URLSearchParams.\\"); + } - if (target[implSymbol][utils.supportsPropertyIndex](index)) { - const indexedValue = target[implSymbol].item(index); - return { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); } - ignoreNamedProps = true; + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); + } + return esValue[implSymbol].set(...args); } - return Reflect.getOwnPropertyDescriptor(target, P); - }, + sort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'sort' called on an object that is not a valid instance of URLSearchParams.\\"); + } - 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) { + return esValue[implSymbol].sort(); } - let ownDesc; - - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - if (target[implSymbol][utils.supportsPropertyIndex](index)) { - const indexedValue = target[implSymbol].item(index); - ownDesc = { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'toString' called on an object that is not a valid instance of URLSearchParams.\\"); } - } - if (ownDesc === undefined) { - ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + return esValue[implSymbol].toString(); } - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - if (parent !== null) { - return Reflect.set(parent, P, V, receiver); + + keys() { + if (!exports.is(this)) { + throw new TypeError(\\"'keys' called on an object that is not a valid instance of URLSearchParams.\\"); } - ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; - } - if (!ownDesc.writable) { - return false; - } - if (!utils.isObject(receiver)) { - return false; + return exports.createDefaultIterator(globalObject, this, \\"key\\"); } - 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 }; + + values() { + if (!exports.is(this)) { + throw new TypeError(\\"'values' called on an object that is not a valid instance of URLSearchParams.\\"); + } + return exports.createDefaultIterator(globalObject, this, \\"value\\"); } - return Reflect.defineProperty(receiver, P, valueDesc); - }, - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); + entries() { + if (!exports.is(this)) { + throw new TypeError(\\"'entries' called on an object that is not a valid instance of URLSearchParams.\\"); + } + return exports.createDefaultIterator(globalObject, this, \\"key+value\\"); } - if (utils.isArrayIndexPropName(P)) { - return false; + forEach(callback) { + if (!exports.is(this)) { + throw new TypeError(\\"'forEach' called on an object that is not a valid instance of URLSearchParams.\\"); + } + if (arguments.length < 1) { + throw new TypeError(\\"Failed to execute 'forEach' on 'iterable': 1 argument required, \\" + \\"but only 0 present.\\"); + } + callback = Function.convert(callback, { + context: \\"Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1\\" + }); + const thisArg = arguments[1]; + let pairs = Array.from(this[implSymbol]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[implSymbol]); + i++; + } } + } + Object.defineProperties(URLSearchParams.prototype, { + append: { enumerable: true }, + delete: { enumerable: true }, + get: { enumerable: true }, + getAll: { enumerable: true }, + has: { enumerable: true }, + set: { enumerable: true }, + sort: { enumerable: true }, + toString: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + forEach: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLSearchParams\\", configurable: true }, + [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = URLSearchParams; - return Reflect.defineProperty(target, P, desc); - }, + ctorRegistry[\\"URLSearchParams Iterator\\"] = Object.assign( + Object.create(ctorRegistry[\\"%IteratorPrototype%\\"], { + [Symbol.toStringTag]: { + configurable: true, + value: \\"URLSearchParams Iterator\\" + } + }), + { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + throw new TypeError(\\"next() called on a value that is not a URLSearchParams iterator object\\"); + } - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + const { target, kind, index } = internal; + const values = Array.from(target[implSymbol]); + const len = values.length; + if (index >= len) { + return { value: undefined, done: true }; + } - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - return !target[implSymbol][utils.supportsPropertyIndex](index); + const pair = values[index]; + internal.index = index + 1; + return utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind); + } } + ); - return Reflect.deleteProperty(target, P); - }, - - preventExtensions() { - return false; - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URLSearchParams + }); }; -const Impl = require(\\"../implementations/URLList.js\\"); +const Impl = require(\\"../implementations/URLSearchParams.js\\"); " `; -exports[`generation with processors URLSearchParams.webidl 1`] = ` +exports[`generation with processors URLSearchParamsCollection.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const Function = require(\\"./Function.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"URLSearchParams\\"; +const interfaceName = \\"URLSearchParamsCollection\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -8488,18 +9767,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'URLSearchParams'.\`); -}; - -exports.createDefaultIterator = (globalObject, target, kind) => { - const ctorRegistry = globalObject[ctorRegistrySymbol]; - const iteratorPrototype = ctorRegistry[\\"URLSearchParams Iterator\\"]; - const iterator = Object.create(iteratorPrototype); - Object.defineProperty(iterator, utils.iterInternalSymbol, { - value: { target, kind, index: 0 }, - configurable: true - }); - return iterator; + throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -8509,7 +9777,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"URLSearchParams\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection\\"].prototype; } return Object.create(proto); @@ -8536,6 +9804,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]); @@ -8544,154 +9814,45 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); - - 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\\", \\"Worker\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - - const ctorRegistry = utils.initCtorRegistry(globalObject); - class URLSearchParams { - constructor() { - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - if (utils.isObject(curArg)) { - if (curArg[Symbol.iterator] !== undefined) { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - if (!utils.isObject(nextItem)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + - \\" sequence\\" + - \\"'s element\\" + - \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = nextItem; - for (let nextItem of tmp) { - nextItem = conversions[\\"USVString\\"](nextItem, { - context: - \\"Failed to construct 'URLSearchParams': parameter 1\\" + - \\" sequence\\" + - \\"'s element\\" + - \\"'s element\\" - }); - - V.push(nextItem); - } - nextItem = V; - } - - V.push(nextItem); - } - curArg = V; - } - } else { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" - ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" - }); - - let typedValue = curArg[key]; - - typedValue = conversions[\\"USVString\\"](typedValue, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" - }); - - result[typedKey] = typedValue; - } - } - curArg = result; - } - } - } else { - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" - }); - } - } else { - curArg = \\"\\"; - } - args.push(curArg); - } - return exports.setup(Object.create(new.target.prototype), globalObject, args); - } - - append(name, value) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'append' called on an object that is not a valid instance of URLSearchParams.\\"); - } + let wrapper = makeWrapper(globalObject, newTarget); - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" - }); - args.push(curArg); - } - return esValue[implSymbol].append(...args); + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = new Proxy(wrapper, proxyHandler); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class URLSearchParamsCollection { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - delete(name) { + item(index) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'delete' called on an object that is not a valid instance of URLSearchParams.\\"); + throw new TypeError(\\"'item' called on an object that is not a valid instance of URLSearchParamsCollection.\\"); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + + \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -8699,23 +9860,25 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" }); args.push(curArg); } - return esValue[implSymbol].delete(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); } - get(name) { + namedItem(name) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'get' called on an object that is not a valid instance of URLSearchParams.\\"); + throw new TypeError( + \\"'namedItem' called on an object that is not a valid instance of URLSearchParamsCollection.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + + \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -8723,220 +9886,243 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" }); args.push(curArg); } - return esValue[implSymbol].get(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); } - getAll(name) { + get length() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'getAll' called on an object that is not a valid instance of URLSearchParams.\\"); - } - if (arguments.length < 1) { + if (!exports.is(esValue)) { throw new TypeError( - \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" + \\"'get length' called on an object that is not a valid instance of URLSearchParamsCollection.\\" ); } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args)); + + return esValue[implSymbol][\\"length\\"]; } + } + Object.defineProperties(URLSearchParamsCollection.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection\\", configurable: true }, + [Symbol.iterator]: { value: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = URLSearchParamsCollection; - has(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'has' called on an object that is not a valid instance of URLSearchParams.\\"); - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URLSearchParamsCollection + }); +}; - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); +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; } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + 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.supportedPropertyIndices]) { + keys.add(\`\${key}\`); + } + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(\`\${key}\`); } - return esValue[implSymbol].has(...args); } - set(name, value) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set' called on an object that is not a valid instance of URLSearchParams.\\"); + 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 (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; } + ignoreNamedProps = true; + } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); + const namedValue = target[implSymbol].namedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + }, + + 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) { + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + } + + 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); } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" - }); - args.push(curArg); + 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; } - return esValue[implSymbol].set(...args); - } - - sort() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'sort' called on an object that is not a valid instance of URLSearchParams.\\"); + if (!existingDesc.writable) { + return false; } - - return esValue[implSymbol].sort(); + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; } + return Reflect.defineProperty(receiver, P, valueDesc); + }, - toString() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'toString' called on an object that is not a valid instance of URLSearchParams.\\"); - } - - return esValue[implSymbol].toString(); + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); } - keys() { - if (!exports.is(this)) { - throw new TypeError(\\"'keys' called on an object that is not a valid instance of URLSearchParams.\\"); - } - return exports.createDefaultIterator(globalObject, this, \\"key\\"); + if (utils.isArrayIndexPropName(P)) { + return false; } - - values() { - if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of URLSearchParams.\\"); + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].namedItem(P) !== null); + if (!creating) { + return false; } - return exports.createDefaultIterator(globalObject, this, \\"value\\"); } + return Reflect.defineProperty(target, P, desc); + }, - entries() { - if (!exports.is(this)) { - throw new TypeError(\\"'entries' called on an object that is not a valid instance of URLSearchParams.\\"); - } - return exports.createDefaultIterator(globalObject, this, \\"key+value\\"); + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); } - forEach(callback) { - if (!exports.is(this)) { - throw new TypeError(\\"'forEach' called on an object that is not a valid instance of URLSearchParams.\\"); - } - if (arguments.length < 1) { - throw new TypeError(\\"Failed to execute 'forEach' on 'iterable': 1 argument required, \\" + \\"but only 0 present.\\"); - } - callback = Function.convert(callback, { - context: \\"Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1\\" - }); - const thisArg = arguments[1]; - let pairs = Array.from(this[implSymbol]); - let i = 0; - while (i < pairs.length) { - const [key, value] = pairs[i].map(utils.tryWrapperForImpl); - callback.call(thisArg, value, key, this); - pairs = Array.from(this[implSymbol]); - i++; - } + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== undefined); } - } - Object.defineProperties(URLSearchParams.prototype, { - append: { enumerable: true }, - delete: { enumerable: true }, - get: { enumerable: true }, - getAll: { enumerable: true }, - has: { enumerable: true }, - set: { enumerable: true }, - sort: { enumerable: true }, - toString: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true }, - forEach: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLSearchParams\\", configurable: true }, - [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } - }); - ctorRegistry[interfaceName] = URLSearchParams; - - ctorRegistry[\\"URLSearchParams Iterator\\"] = Object.assign( - Object.create(ctorRegistry[\\"%IteratorPrototype%\\"], { - [Symbol.toStringTag]: { - configurable: true, - value: \\"URLSearchParams Iterator\\" - } - }), - { - next() { - const internal = this && this[utils.iterInternalSymbol]; - if (!internal) { - throw new TypeError(\\"next() called on a value that is not a URLSearchParams iterator object\\"); - } - - const { target, kind, index } = internal; - const values = Array.from(target[implSymbol]); - const len = values.length; - if (index >= len) { - return { value: undefined, done: true }; - } - const pair = values[index]; - internal.index = index + 1; - return utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind); - } + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; } - ); - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: URLSearchParams - }); + return Reflect.deleteProperty(target, P); + }, + + preventExtensions() { + return false; + } }; -const Impl = require(\\"../implementations/URLSearchParams.js\\"); +const Impl = require(\\"../implementations/URLSearchParamsCollection.js\\"); " `; -exports[`generation with processors URLSearchParamsCollection.webidl 1`] = ` +exports[`generation with processors URLSearchParamsCollection2.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 URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); -const interfaceName = \\"URLSearchParamsCollection\\"; +const interfaceName = \\"URLSearchParamsCollection2\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -8948,7 +10134,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection'.\`); + throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection2'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -8958,7 +10144,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection2\\"].prototype; } return Object.create(proto); @@ -8974,7 +10160,9 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => {}; +exports._internalSetup = (wrapper, globalObject) => { + URLSearchParamsCollection._internalSetup(wrapper, globalObject); +}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -9020,86 +10208,21 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class URLSearchParamsCollection { + class URLSearchParamsCollection2 extends globalObject.URLSearchParamsCollection { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - - item(index) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'item' called on an object that is not a valid instance of URLSearchParamsCollection.\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); - } - - namedItem(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'namedItem' called on an object that is not a valid instance of URLSearchParamsCollection.\\" - ); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); - } - - get length() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError( - \\"'get length' called on an object that is not a valid instance of URLSearchParamsCollection.\\" - ); - } - - return esValue[implSymbol][\\"length\\"]; - } } - Object.defineProperties(URLSearchParamsCollection.prototype, { - item: { enumerable: true }, - namedItem: { enumerable: true }, - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection\\", configurable: true }, + Object.defineProperties(URLSearchParamsCollection2.prototype, { + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection2\\", configurable: true }, [Symbol.iterator]: { value: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], configurable: true, writable: true } }); - ctorRegistry[interfaceName] = URLSearchParamsCollection; + ctorRegistry[interfaceName] = URLSearchParamsCollection2; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URLSearchParamsCollection + value: URLSearchParamsCollection2 }); }; @@ -9184,8 +10307,8 @@ const proxyHandler = { if (namedValue !== null && !(P in target) && !ignoreNamedProps) { return { - writable: false, - enumerable: false, + writable: true, + enumerable: true, configurable: true, value: utils.tryWrapperForImpl(namedValue) }; @@ -9201,6 +10324,22 @@ const proxyHandler = { // 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 = URL.convert(namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + }); + + const creating = !(target[implSymbol].namedItem(P) !== null); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + + return true; + } } let ownDesc; @@ -9258,10 +10397,24 @@ const proxyHandler = { return false; } if (!utils.hasOwn(target, P)) { - const creating = !(target[implSymbol].namedItem(P) !== null); - if (!creating) { + if (desc.get || desc.set) { return false; } + + let namedValue = desc.value; + + namedValue = URL.convert(namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + }); + + const creating = !(target[implSymbol].namedItem(P) !== null); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + + return true; } return Reflect.defineProperty(target, P, desc); }, @@ -9288,22 +10441,20 @@ const proxyHandler = { } }; -const Impl = require(\\"../implementations/URLSearchParamsCollection.js\\"); +const Impl = require(\\"../implementations/URLSearchParamsCollection2.js\\"); " `; -exports[`generation with processors URLSearchParamsCollection2.webidl 1`] = ` +exports[`generation with processors UnderscoredProperties.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 URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); -const interfaceName = \\"URLSearchParamsCollection2\\"; +const interfaceName = \\"UnderscoredProperties\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -9315,7 +10466,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection2'.\`); + throw new TypeError(\`\${context} is not of type 'UnderscoredProperties'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -9325,7 +10476,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection2\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"UnderscoredProperties\\"].prototype; } return Object.create(proto); @@ -9341,9 +10492,7 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => { - URLSearchParamsCollection._internalSetup(wrapper, globalObject); -}; +exports._internalSetup = (wrapper, globalObject) => {}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -9354,8 +10503,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]); @@ -9364,7 +10511,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - let wrapper = makeWrapper(globalObject, newTarget); + const wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -9372,8 +10519,6 @@ exports.new = (globalObject, newTarget) => { configurable: true }); - wrapper = new Proxy(wrapper, proxyHandler); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -9389,253 +10534,293 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class URLSearchParamsCollection2 extends globalObject.URLSearchParamsCollection { + class UnderscoredProperties { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - } - Object.defineProperties(URLSearchParamsCollection2.prototype, { - [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection2\\", configurable: true }, - [Symbol.iterator]: { value: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], configurable: true, writable: true } - }); - ctorRegistry[interfaceName] = URLSearchParamsCollection2; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: URLSearchParamsCollection2 - }); -}; + operation(sequence) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'operation' called on an object that is not a valid instance of UnderscoredProperties.\\"); + } -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; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - 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, []); - }, + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"DOMString\\"](nextItem, { + context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" + }); - 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); + V.push(nextItem); + } + curArg = V; + } + args.push(curArg); + } + return esValue[implSymbol].operation(...args); } - return false; - }, - ownKeys(target) { - const keys = new Set(); + get attribute() { + const esValue = this !== null && this !== undefined ? this : globalObject; - for (const key of target[implSymbol][utils.supportedPropertyIndices]) { - keys.add(\`\${key}\`); + if (!exports.is(esValue)) { + throw new TypeError( + \\"'get attribute' called on an object that is not a valid instance of UnderscoredProperties.\\" + ); + } + + return esValue[implSymbol][\\"attribute\\"]; } - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); + set attribute(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError( + \\"'set attribute' called on an object that is not a valid instance of UnderscoredProperties.\\" + ); } - } - for (const key of Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - }, + V = conversions[\\"byte\\"](V, { + context: \\"Failed to set the 'attribute' property on 'UnderscoredProperties': The provided value\\" + }); - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); + esValue[implSymbol][\\"attribute\\"] = V; } - let ignoreNamedProps = false; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - return { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; + static static(void_) { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - ignoreNamedProps = true; + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" + }); + args.push(curArg); + } + return Impl.implementation.static(...args); } + } + Object.defineProperties(UnderscoredProperties.prototype, { + operation: { enumerable: true }, + attribute: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"UnderscoredProperties\\", configurable: true }, + const: { value: 42, enumerable: true } + }); + Object.defineProperties(UnderscoredProperties, { + static: { enumerable: true }, + const: { value: 42, enumerable: true } + }); + ctorRegistry[interfaceName] = UnderscoredProperties; - const namedValue = target[implSymbol].namedItem(P); + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: UnderscoredProperties + }); +}; + +const Impl = require(\\"../implementations/UnderscoredProperties.js\\"); +" +`; + +exports[`generation with processors Unscopable.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Unscopable\\"; + +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 'Unscopable'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"Unscopable\\"].prototype; + } + + return Object.create(proto); +} + +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; +}; - if (namedValue !== null && !(P in target) && !ignoreNamedProps) { - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; - } +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); - return Reflect.getOwnPropertyDescriptor(target, P); - }, + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); - 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; + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; - namedValue = URL.convert(namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" - }); +const exposed = new Set([\\"Window\\"]); - const creating = !(target[implSymbol].namedItem(P) !== null); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } - return true; - } + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Unscopable { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - let ownDesc; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - ownDesc = { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; - } - } + get unscopableTest() { + const esValue = this !== null && this !== undefined ? this : globalObject; - 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; + if (!exports.is(esValue)) { + throw new TypeError(\\"'get unscopableTest' called on an object that is not a valid instance of Unscopable.\\"); } - 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 esValue[implSymbol][\\"unscopableTest\\"]; } - if (utils.isArrayIndexPropName(P)) { - return false; - } - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; - } + set unscopableTest(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - let namedValue = desc.value; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set unscopableTest' called on an object that is not a valid instance of Unscopable.\\"); + } - namedValue = URL.convert(namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'unscopableTest' property on 'Unscopable': The provided value\\" }); - const creating = !(target[implSymbol].namedItem(P) !== null); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } - - return true; + esValue[implSymbol][\\"unscopableTest\\"] = V; } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + get unscopableMixin() { + const esValue = this !== null && this !== undefined ? this : globalObject; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - return !(target[implSymbol].item(index) !== undefined); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"'get unscopableMixin' called on an object that is not a valid instance of Unscopable.\\"); + } - if (target[implSymbol].namedItem(P) !== null && !(P in target)) { - return false; + return esValue[implSymbol][\\"unscopableMixin\\"]; } - return Reflect.deleteProperty(target, P); - }, + set unscopableMixin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - preventExtensions() { - return false; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set unscopableMixin' called on an object that is not a valid instance of Unscopable.\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'unscopableMixin' property on 'Unscopable': The provided value\\" + }); + + esValue[implSymbol][\\"unscopableMixin\\"] = V; + } } + Object.defineProperties(Unscopable.prototype, { + unscopableTest: { enumerable: true }, + unscopableMixin: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Unscopable\\", configurable: true }, + [Symbol.unscopables]: { + value: { unscopableTest: true, unscopableMixin: true, __proto__: null }, + configurable: true + } + }); + ctorRegistry[interfaceName] = Unscopable; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Unscopable + }); }; -const Impl = require(\\"../implementations/URLSearchParamsCollection2.js\\"); +const Impl = require(\\"../implementations/Unscopable.js\\"); " `; -exports[`generation with processors UnderscoredProperties.webidl 1`] = ` +exports[`generation with processors Variadic.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 = \\"UnderscoredProperties\\"; +const interfaceName = \\"Variadic\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -9647,7 +10832,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'UnderscoredProperties'.\`); + throw new TypeError(\`\${context} is not of type 'Variadic'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -9657,7 +10842,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"UnderscoredProperties\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"Variadic\\"].prototype; } return Object.create(proto); @@ -9715,119 +10900,183 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class UnderscoredProperties { + class Variadic { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - operation(sequence) { + simple1() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'operation' called on an object that is not a valid instance of UnderscoredProperties.\\"); + throw new TypeError(\\"'simple1' called on an object that is not a valid instance of Variadic.\\"); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + return esValue[implSymbol].simple1(...args); + } + + simple2(first) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'simple2' called on an object that is not a valid instance of Variadic.\\"); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" + \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"DOMString\\"](nextItem, { - context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" - }); + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = URL.convert(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); + args.push(curArg); + } + return esValue[implSymbol].simple2(...args); + } - V.push(nextItem); + overloaded1() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'overloaded1' called on an object that is not a valid instance of Variadic.\\"); + } + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } else { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } } - curArg = V; } - args.push(curArg); - } - return esValue[implSymbol].operation(...args); - } - - get attribute() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError( - \\"'get attribute' called on an object that is not a valid instance of UnderscoredProperties.\\" - ); } - - return esValue[implSymbol][\\"attribute\\"]; + return esValue[implSymbol].overloaded1(...args); } - set attribute(V) { + overloaded2(first) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'set attribute' called on an object that is not a valid instance of UnderscoredProperties.\\" - ); + throw new TypeError(\\"'overloaded2' called on an object that is not a valid instance of Variadic.\\"); } - V = conversions[\\"byte\\"](V, { - context: \\"Failed to set the 'attribute' property on 'UnderscoredProperties': The provided value\\" - }); - - esValue[implSymbol][\\"attribute\\"] = V; - } - - static static(void_) { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + + \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" - }); - args.push(curArg); + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } + } + break; + default: { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } + } } - return Impl.implementation.static(...args); + return esValue[implSymbol].overloaded2(...args); } } - Object.defineProperties(UnderscoredProperties.prototype, { - operation: { enumerable: true }, - attribute: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"UnderscoredProperties\\", configurable: true }, - const: { value: 42, enumerable: true } - }); - Object.defineProperties(UnderscoredProperties, { - static: { enumerable: true }, - const: { value: 42, enumerable: true } + Object.defineProperties(Variadic.prototype, { + simple1: { enumerable: true }, + simple2: { enumerable: true }, + overloaded1: { enumerable: true }, + overloaded2: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Variadic\\", configurable: true } }); - ctorRegistry[interfaceName] = UnderscoredProperties; + ctorRegistry[interfaceName] = Variadic; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: UnderscoredProperties + value: Variadic }); }; -const Impl = require(\\"../implementations/UnderscoredProperties.js\\"); +const Impl = require(\\"../implementations/Variadic.js\\"); " `; -exports[`generation with processors Unscopable.webidl 1`] = ` +exports[`generation with processors ZeroArgConstructor.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -9836,7 +11085,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Unscopable\\"; +const interfaceName = \\"ZeroArgConstructor\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -9848,7 +11097,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Unscopable'.\`); + throw new TypeError(\`\${context} is not of type 'ZeroArgConstructor'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -9858,7 +11107,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"Unscopable\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"ZeroArgConstructor\\"].prototype; } return Object.create(proto); @@ -9916,92 +11165,122 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Unscopable { + class ZeroArgConstructor { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); } + } + Object.defineProperties(ZeroArgConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"ZeroArgConstructor\\", configurable: true } + }); + ctorRegistry[interfaceName] = ZeroArgConstructor; - get unscopableTest() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ZeroArgConstructor + }); +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get unscopableTest' called on an object that is not a valid instance of Unscopable.\\"); - } +const Impl = require(\\"../implementations/ZeroArgConstructor.js\\"); +" +`; - return esValue[implSymbol][\\"unscopableTest\\"]; - } +exports[`generation without processors AsyncCallbackFunction.webidl 1`] = ` +"\\"use strict\\"; - set unscopableTest(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - if (!exports.is(esValue)) { - throw new TypeError(\\"'set unscopableTest' called on an object that is not a valid instance of Unscopable.\\"); - } +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (typeof value !== \\"function\\") { + throw new TypeError(context + \\" is not a function\\"); + } - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'unscopableTest' property on 'Unscopable': The provided value\\" - }); + function invokeTheCallbackFunction() { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; - esValue[implSymbol][\\"unscopableTest\\"] = V; + try { + callResult = Reflect.apply(value, thisArg, []); + + callResult = new Promise(resolve => resolve(callResult)); + return callResult; + } catch (err) { + return Promise.reject(err); } + } - get unscopableMixin() { - const esValue = this !== null && this !== undefined ? this : globalObject; + invokeTheCallbackFunction.construct = () => { + let callResult = Reflect.construct(value, []); - if (!exports.is(esValue)) { - throw new TypeError(\\"'get unscopableMixin' called on an object that is not a valid instance of Unscopable.\\"); - } + callResult = new Promise(resolve => resolve(callResult)); + return callResult; + }; - return esValue[implSymbol][\\"unscopableMixin\\"]; - } + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; - set unscopableMixin(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + return invokeTheCallbackFunction; +}; +" +`; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set unscopableMixin' called on an object that is not a valid instance of Unscopable.\\"); - } +exports[`generation without processors AsyncCallbackInterface.webidl 1`] = ` +"\\"use strict\\"; - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'unscopableMixin' property on 'Unscopable': The provided value\\" - }); +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - esValue[implSymbol][\\"unscopableMixin\\"] = V; - } +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + if (!utils.isObject(value)) { + throw new TypeError(\`\${context} is not an object.\`); } - Object.defineProperties(Unscopable.prototype, { - unscopableTest: { enumerable: true }, - unscopableMixin: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Unscopable\\", configurable: true }, - [Symbol.unscopables]: { - value: { unscopableTest: true, unscopableMixin: true, __proto__: null }, - configurable: true + + function callTheUserObjectsOperation() { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + try { + if (typeof O !== \\"function\\") { + X = O[\\"asyncMethod\\"]; + if (typeof X !== \\"function\\") { + throw new TypeError(\`\${context} does not correctly implement AsyncCallbackInterface.\`); + } + thisArg = O; + } + + let callResult = Reflect.apply(X, thisArg, []); + + callResult = new Promise(resolve => resolve(callResult)); + return callResult; + } catch (err) { + return Promise.reject(err); } - }); - ctorRegistry[interfaceName] = Unscopable; + } - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: Unscopable - }); + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; }; -const Impl = require(\\"../implementations/Unscopable.js\\"); +exports.install = (globalObject, globalNames) => {}; " `; -exports[`generation with processors Variadic.webidl 1`] = ` +exports[`generation without processors AsyncIterablePairArgs.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const URL = require(\\"./URL.js\\"); +const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Variadic\\"; +const interfaceName = \\"AsyncIterablePairArgs\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -10013,7 +11292,18 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Variadic'.\`); + throw new TypeError(\`\${context} is not of type 'AsyncIterablePairArgs'.\`); +}; + +exports.createDefaultAsyncIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterablePairArgs AsyncIterator\\"]; + const iterator = Object.create(asyncIteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, ongoingPromise: null, isFinished: false }, + configurable: true + }); + return iterator; }; function makeWrapper(globalObject, newTarget) { @@ -10023,7 +11313,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"Variadic\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"AsyncIterablePairArgs\\"].prototype; } return Object.create(proto); @@ -10081,183 +11371,187 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Variadic { + class AsyncIterablePairArgs { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - simple1() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'simple1' called on an object that is not a valid instance of Variadic.\\"); + keys() { + if (!exports.is(this)) { + throw new TypeError(\\"'keys' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); } + const args = []; - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) + if (arguments[0] !== undefined) { + args[0] = arguments[0]; + args[0] = conversions[\\"boolean\\"](args[0], { + context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 1\\" }); - args.push(curArg); + } else { + args[0] = false; } - return esValue[implSymbol].simple1(...args); - } - simple2(first) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'simple2' called on an object that is not a valid instance of Variadic.\\"); + if (arguments[1] !== undefined) { + args[1] = arguments[1]; + args[1] = conversions[\\"DOMString\\"](args[1], { + context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 2\\" + }); + } else { + args[1] = undefined; } + args[2] = arguments[2]; + args[2] = Dictionary.convert(args[2], { + context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 3\\" + }); - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; + } + + values() { + if (!exports.is(this)) { + throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); } + const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" + if (arguments[0] !== undefined) { + args[0] = arguments[0]; + args[0] = conversions[\\"boolean\\"](args[0], { + context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 1\\" }); - args.push(curArg); + } else { + args[0] = false; } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = URL.convert(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); - args.push(curArg); + + if (arguments[1] !== undefined) { + args[1] = arguments[1]; + args[1] = conversions[\\"DOMString\\"](args[1], { + context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 2\\" + }); + } else { + args[1] = undefined; } - return esValue[implSymbol].simple2(...args); + args[2] = arguments[2]; + args[2] = Dictionary.convert(args[2], { + context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 3\\" + }); + + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; } - overloaded1() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'overloaded1' called on an object that is not a valid instance of Variadic.\\"); + entries() { + if (!exports.is(this)) { + throw new TypeError(\\"'entries' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); } + const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } - } + if (arguments[0] !== undefined) { + args[0] = arguments[0]; + args[0] = conversions[\\"boolean\\"](args[0], { + context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 1\\" + }); + } else { + args[0] = false; } - return esValue[implSymbol].overloaded1(...args); - } - overloaded2(first) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'overloaded2' called on an object that is not a valid instance of Variadic.\\"); + if (arguments[1] !== undefined) { + args[1] = arguments[1]; + args[1] = conversions[\\"DOMString\\"](args[1], { + context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 2\\" + }); + } else { + args[1] = undefined; } + args[2] = arguments[2]; + args[2] = Dictionary.convert(args[2], { + context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 3\\" + }); - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key+value\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - } - } - break; - default: { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } + return asyncIterator; + } + } + Object.defineProperties(AsyncIterablePairArgs.prototype, { + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"AsyncIterablePairArgs\\", configurable: true }, + [Symbol.asyncIterator]: { value: AsyncIterablePairArgs.prototype.entries, configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = AsyncIterablePairArgs; + + ctorRegistry[\\"AsyncIterablePairArgs AsyncIterator\\"] = Object.assign( + Object.create( + utils.AsyncIteratorPrototype, + { + [Symbol.toStringTag]: { + value: \\"AsyncIterablePairArgs AsyncIterator\\", + configurable: true + } + }, + { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + return Promise.reject( + new TypeError(\\"next() called on a value that is not a AsyncIterablePairArgs async iterator object\\") + ); } + + const nextSteps = () => { + if (internal.isFinished) { + return Promise.resolve({ value: undefined, done: true }); + } + + const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); + return nextPromise.then( + next => { + internal.ongoingPromise = null; + if (next === utils.asyncIteratorEOI) { + internal.isFinished = true; + return { value: undefined, done: true }; + } + return utils.iteratorResult(next.map(utils.tryWrapperForImpl), kind); + }, + reason => { + internal.ongoingPromise = null; + internal.isFinished = true; + throw reason; + } + ); + }; + + internal.ongoingPromise = internal.ongoingPromise + ? internal.ongoingPromise.then(nextSteps, nextSteps) + : nextSteps(); + return internal.ongoingPromise; } } - return esValue[implSymbol].overloaded2(...args); - } - } - Object.defineProperties(Variadic.prototype, { - simple1: { enumerable: true }, - simple2: { enumerable: true }, - overloaded1: { enumerable: true }, - overloaded2: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Variadic\\", configurable: true } - }); - ctorRegistry[interfaceName] = Variadic; + ) + ); Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Variadic + value: AsyncIterablePairArgs }); }; -const Impl = require(\\"../implementations/Variadic.js\\"); +const Impl = require(\\"../implementations/AsyncIterablePairArgs.js\\"); " `; -exports[`generation with processors ZeroArgConstructor.webidl 1`] = ` +exports[`generation without processors AsyncIterablePairNoArgs.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -10266,7 +11560,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"ZeroArgConstructor\\"; +const interfaceName = \\"AsyncIterablePairNoArgs\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -10278,7 +11572,18 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'ZeroArgConstructor'.\`); + throw new TypeError(\`\${context} is not of type 'AsyncIterablePairNoArgs'.\`); +}; + +exports.createDefaultAsyncIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterablePairNoArgs AsyncIterator\\"]; + const iterator = Object.create(asyncIteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, ongoingPromise: null, isFinished: false }, + configurable: true + }); + return iterator; }; function makeWrapper(globalObject, newTarget) { @@ -10288,7 +11593,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"ZeroArgConstructor\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"AsyncIterablePairNoArgs\\"].prototype; } return Object.create(proto); @@ -10346,122 +11651,329 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class ZeroArgConstructor { + class AsyncIterablePairNoArgs { constructor() { - return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + throw new TypeError(\\"Illegal constructor\\"); + } + + keys() { + if (!exports.is(this)) { + throw new TypeError(\\"'keys' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); + } + + const args = []; + + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; + } + + values() { + if (!exports.is(this)) { + throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); + } + + const args = []; + + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; + } + + entries() { + if (!exports.is(this)) { + throw new TypeError(\\"'entries' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); + } + + const args = []; + + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key+value\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; } } - Object.defineProperties(ZeroArgConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"ZeroArgConstructor\\", configurable: true } + Object.defineProperties(AsyncIterablePairNoArgs.prototype, { + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"AsyncIterablePairNoArgs\\", configurable: true }, + [Symbol.asyncIterator]: { value: AsyncIterablePairNoArgs.prototype.entries, configurable: true, writable: true } }); - ctorRegistry[interfaceName] = ZeroArgConstructor; + ctorRegistry[interfaceName] = AsyncIterablePairNoArgs; + + ctorRegistry[\\"AsyncIterablePairNoArgs AsyncIterator\\"] = Object.assign( + Object.create( + utils.AsyncIteratorPrototype, + { + [Symbol.toStringTag]: { + value: \\"AsyncIterablePairNoArgs AsyncIterator\\", + configurable: true + } + }, + { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + return Promise.reject( + new TypeError(\\"next() called on a value that is not a AsyncIterablePairNoArgs async iterator object\\") + ); + } + + const nextSteps = () => { + if (internal.isFinished) { + return Promise.resolve({ value: undefined, done: true }); + } + + const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); + return nextPromise.then( + next => { + internal.ongoingPromise = null; + if (next === utils.asyncIteratorEOI) { + internal.isFinished = true; + return { value: undefined, done: true }; + } + return utils.iteratorResult(next.map(utils.tryWrapperForImpl), kind); + }, + reason => { + internal.ongoingPromise = null; + internal.isFinished = true; + throw reason; + } + ); + }; + + internal.ongoingPromise = internal.ongoingPromise + ? internal.ongoingPromise.then(nextSteps, nextSteps) + : nextSteps(); + return internal.ongoingPromise; + } + } + ) + ); Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: ZeroArgConstructor + value: AsyncIterablePairNoArgs }); }; -const Impl = require(\\"../implementations/ZeroArgConstructor.js\\"); +const Impl = require(\\"../implementations/AsyncIterablePairNoArgs.js\\"); " `; -exports[`generation without processors AsyncCallbackFunction.webidl 1`] = ` +exports[`generation without processors AsyncIterableValueArgs.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 = \\"AsyncIterableValueArgs\\"; + +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 (typeof value !== \\"function\\") { - throw new TypeError(context + \\" is not a function\\"); + if (exports.is(value)) { + return utils.implForWrapper(value); } + throw new TypeError(\`\${context} is not of type 'AsyncIterableValueArgs'.\`); +}; - function invokeTheCallbackFunction() { - const thisArg = utils.tryWrapperForImpl(this); - let callResult; +exports.createDefaultAsyncIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableValueArgs AsyncIterator\\"]; + const iterator = Object.create(asyncIteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, ongoingPromise: null, isFinished: false }, + configurable: true + }); + return iterator; +}; - try { - callResult = Reflect.apply(value, thisArg, []); +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableValueArgs\\"].prototype; + } + + return Object.create(proto); +} + +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 + }); - callResult = new Promise(resolve => resolve(callResult)); - return callResult; - } catch (err) { - return Promise.reject(err); - } + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); } + return wrapper; +}; - invokeTheCallbackFunction.construct = () => { - let callResult = Reflect.construct(value, []); - - callResult = new Promise(resolve => resolve(callResult)); - return callResult; - }; +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); - invokeTheCallbackFunction[utils.wrapperSymbol] = value; - invokeTheCallbackFunction.objectReference = value; + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); - return invokeTheCallbackFunction; + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; }; -" -`; - -exports[`generation without processors AsyncCallbackInterface.webidl 1`] = ` -"\\"use strict\\"; -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); +const exposed = new Set([\\"Window\\"]); -exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { - if (!utils.isObject(value)) { - throw new TypeError(\`\${context} is not an object.\`); +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; } - function callTheUserObjectsOperation() { - let thisArg = utils.tryWrapperForImpl(this); - let O = value; - let X = O; + const ctorRegistry = utils.initCtorRegistry(globalObject); + class AsyncIterableValueArgs { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } - try { - if (typeof O !== \\"function\\") { - X = O[\\"asyncMethod\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement AsyncCallbackInterface.\`); - } - thisArg = O; + values() { + if (!exports.is(this)) { + throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableValueArgs.\\"); } - let callResult = Reflect.apply(X, thisArg, []); + const args = []; + if (arguments[0] !== undefined) { + args[0] = arguments[0]; + args[0] = URL.convert(args[0], { + context: \\"Failed to execute 'values' on 'AsyncIterableValueArgs': parameter 1\\" + }); + } else { + args[0] = undefined; + } - callResult = new Promise(resolve => resolve(callResult)); - return callResult; - } catch (err) { - return Promise.reject(err); + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); + if (this[implSymbol][utils.asyncIteratorInit]) { + this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + } + return asyncIterator; } } + Object.defineProperties(AsyncIterableValueArgs.prototype, { + values: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"AsyncIterableValueArgs\\", configurable: true }, + [Symbol.asyncIterator]: { value: AsyncIterableValueArgs.prototype.values, configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = AsyncIterableValueArgs; - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; + ctorRegistry[\\"AsyncIterableValueArgs AsyncIterator\\"] = Object.assign( + Object.create( + utils.AsyncIteratorPrototype, + { + [Symbol.toStringTag]: { + value: \\"AsyncIterableValueArgs AsyncIterator\\", + configurable: true + } + }, + { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + return Promise.reject( + new TypeError(\\"next() called on a value that is not a AsyncIterableValueArgs async iterator object\\") + ); + } - return callTheUserObjectsOperation; + const nextSteps = () => { + if (internal.isFinished) { + return Promise.resolve({ value: undefined, done: true }); + } + + const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); + return nextPromise.then( + next => { + internal.ongoingPromise = null; + if (next === utils.asyncIteratorEOI) { + internal.isFinished = true; + return { value: undefined, done: true }; + } + return { value: utils.tryWrapperForImpl(next), done: false }; + }, + reason => { + internal.ongoingPromise = null; + internal.isFinished = true; + throw reason; + } + ); + }; + + internal.ongoingPromise = internal.ongoingPromise + ? internal.ongoingPromise.then(nextSteps, nextSteps) + : nextSteps(); + return internal.ongoingPromise; + } + } + ) + ); + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: AsyncIterableValueArgs + }); }; -exports.install = (globalObject, globalNames) => {}; +const Impl = require(\\"../implementations/AsyncIterableValueArgs.js\\"); " `; -exports[`generation without processors AsyncIterablePairArgs.webidl 1`] = ` +exports[`generation without processors AsyncIterableValueNoArgs.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"AsyncIterablePairArgs\\"; +const interfaceName = \\"AsyncIterableValueNoArgs\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -10473,12 +11985,12 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'AsyncIterablePairArgs'.\`); + throw new TypeError(\`\${context} is not of type 'AsyncIterableValueNoArgs'.\`); }; exports.createDefaultAsyncIterator = (globalObject, target, kind) => { const ctorRegistry = globalObject[ctorRegistrySymbol]; - const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterablePairArgs AsyncIterator\\"]; + const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableValueNoArgs AsyncIterator\\"]; const iterator = Object.create(asyncIteratorPrototype); Object.defineProperty(iterator, utils.iterInternalSymbol, { value: { target, kind, ongoingPromise: null, isFinished: false }, @@ -10494,7 +12006,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"AsyncIterablePairArgs\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableValueNoArgs\\"].prototype; } return Object.create(proto); @@ -10552,131 +12064,38 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class AsyncIterablePairArgs { + class AsyncIterableValueNoArgs { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - keys() { - if (!exports.is(this)) { - throw new TypeError(\\"'keys' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); - } - - const args = []; - if (arguments[0] !== undefined) { - args[0] = arguments[0]; - args[0] = conversions[\\"boolean\\"](args[0], { - context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 1\\" - }); - } else { - args[0] = false; - } - - if (arguments[1] !== undefined) { - args[1] = arguments[1]; - args[1] = conversions[\\"DOMString\\"](args[1], { - context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 2\\" - }); - } else { - args[1] = undefined; - } - args[2] = arguments[2]; - args[2] = Dictionary.convert(args[2], { - context: \\"Failed to execute 'keys' on 'AsyncIterablePairArgs': parameter 3\\" - }); - - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); - } - return asyncIterator; - } - values() { if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); - } - - const args = []; - if (arguments[0] !== undefined) { - args[0] = arguments[0]; - args[0] = conversions[\\"boolean\\"](args[0], { - context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 1\\" - }); - } else { - args[0] = false; - } - - if (arguments[1] !== undefined) { - args[1] = arguments[1]; - args[1] = conversions[\\"DOMString\\"](args[1], { - context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 2\\" - }); - } else { - args[1] = undefined; - } - args[2] = arguments[2]; - args[2] = Dictionary.convert(args[2], { - context: \\"Failed to execute 'values' on 'AsyncIterablePairArgs': parameter 3\\" - }); - - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); - } - return asyncIterator; - } - - entries() { - if (!exports.is(this)) { - throw new TypeError(\\"'entries' called on an object that is not a valid instance of AsyncIterablePairArgs.\\"); + throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableValueNoArgs.\\"); } const args = []; - if (arguments[0] !== undefined) { - args[0] = arguments[0]; - args[0] = conversions[\\"boolean\\"](args[0], { - context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 1\\" - }); - } else { - args[0] = false; - } - - if (arguments[1] !== undefined) { - args[1] = arguments[1]; - args[1] = conversions[\\"DOMString\\"](args[1], { - context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 2\\" - }); - } else { - args[1] = undefined; - } - args[2] = arguments[2]; - args[2] = Dictionary.convert(args[2], { - context: \\"Failed to execute 'entries' on 'AsyncIterablePairArgs': parameter 3\\" - }); - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key+value\\"); + const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); if (this[implSymbol][utils.asyncIteratorInit]) { this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); } return asyncIterator; } } - Object.defineProperties(AsyncIterablePairArgs.prototype, { - keys: { enumerable: true }, + Object.defineProperties(AsyncIterableValueNoArgs.prototype, { values: { enumerable: true }, - entries: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"AsyncIterablePairArgs\\", configurable: true }, - [Symbol.asyncIterator]: { value: AsyncIterablePairArgs.prototype.entries, configurable: true, writable: true } + [Symbol.toStringTag]: { value: \\"AsyncIterableValueNoArgs\\", configurable: true }, + [Symbol.asyncIterator]: { value: AsyncIterableValueNoArgs.prototype.values, configurable: true, writable: true } }); - ctorRegistry[interfaceName] = AsyncIterablePairArgs; + ctorRegistry[interfaceName] = AsyncIterableValueNoArgs; - ctorRegistry[\\"AsyncIterablePairArgs AsyncIterator\\"] = Object.assign( + ctorRegistry[\\"AsyncIterableValueNoArgs AsyncIterator\\"] = Object.assign( Object.create( utils.AsyncIteratorPrototype, { [Symbol.toStringTag]: { - value: \\"AsyncIterablePairArgs AsyncIterator\\", + value: \\"AsyncIterableValueNoArgs AsyncIterator\\", configurable: true } }, @@ -10685,7 +12104,7 @@ exports.install = (globalObject, globalNames) => { const internal = this && this[utils.iterInternalSymbol]; if (!internal) { return Promise.reject( - new TypeError(\\"next() called on a value that is not a AsyncIterablePairArgs async iterator object\\") + new TypeError(\\"next() called on a value that is not a AsyncIterableValueNoArgs async iterator object\\") ); } @@ -10702,7 +12121,7 @@ exports.install = (globalObject, globalNames) => { internal.isFinished = true; return { value: undefined, done: true }; } - return utils.iteratorResult(next.map(utils.tryWrapperForImpl), kind); + return { value: utils.tryWrapperForImpl(next), done: false }; }, reason => { internal.ongoingPromise = null; @@ -10724,24 +12143,25 @@ exports.install = (globalObject, globalNames) => { Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: AsyncIterablePairArgs + value: AsyncIterableValueNoArgs }); }; -const Impl = require(\\"../implementations/AsyncIterablePairArgs.js\\"); +const Impl = require(\\"../implementations/AsyncIterableValueNoArgs.js\\"); " `; -exports[`generation without processors AsyncIterablePairNoArgs.webidl 1`] = ` +exports[`generation without processors AsyncIterableWithReturn.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"AsyncIterablePairNoArgs\\"; +const interfaceName = \\"AsyncIterableWithReturn\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -10753,12 +12173,12 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'AsyncIterablePairNoArgs'.\`); + throw new TypeError(\`\${context} is not of type 'AsyncIterableWithReturn'.\`); }; exports.createDefaultAsyncIterator = (globalObject, target, kind) => { const ctorRegistry = globalObject[ctorRegistrySymbol]; - const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterablePairNoArgs AsyncIterator\\"]; + const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableWithReturn AsyncIterator\\"]; const iterator = Object.create(asyncIteratorPrototype); Object.defineProperty(iterator, utils.iterInternalSymbol, { value: { target, kind, ongoingPromise: null, isFinished: false }, @@ -10774,7 +12194,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"AsyncIterablePairNoArgs\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableWithReturn\\"].prototype; } return Object.create(proto); @@ -10832,31 +12252,21 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class AsyncIterablePairNoArgs { + class AsyncIterableWithReturn { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - keys() { - if (!exports.is(this)) { - throw new TypeError(\\"'keys' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); - } - - const args = []; - - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); - } - return asyncIterator; - } - values() { if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); + throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableWithReturn.\\"); } const args = []; + args[0] = arguments[0]; + args[0] = Dictionary.convert(args[0], { + context: \\"Failed to execute 'values' on 'AsyncIterableWithReturn': parameter 1\\" + }); const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); if (this[implSymbol][utils.asyncIteratorInit]) { @@ -10864,36 +12274,20 @@ exports.install = (globalObject, globalNames) => { } return asyncIterator; } - - entries() { - if (!exports.is(this)) { - throw new TypeError(\\"'entries' called on an object that is not a valid instance of AsyncIterablePairNoArgs.\\"); - } - - const args = []; - - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"key+value\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); - } - return asyncIterator; - } } - Object.defineProperties(AsyncIterablePairNoArgs.prototype, { - keys: { enumerable: true }, + Object.defineProperties(AsyncIterableWithReturn.prototype, { values: { enumerable: true }, - entries: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"AsyncIterablePairNoArgs\\", configurable: true }, - [Symbol.asyncIterator]: { value: AsyncIterablePairNoArgs.prototype.entries, configurable: true, writable: true } + [Symbol.toStringTag]: { value: \\"AsyncIterableWithReturn\\", configurable: true }, + [Symbol.asyncIterator]: { value: AsyncIterableWithReturn.prototype.values, configurable: true, writable: true } }); - ctorRegistry[interfaceName] = AsyncIterablePairNoArgs; + ctorRegistry[interfaceName] = AsyncIterableWithReturn; - ctorRegistry[\\"AsyncIterablePairNoArgs AsyncIterator\\"] = Object.assign( + ctorRegistry[\\"AsyncIterableWithReturn AsyncIterator\\"] = Object.assign( Object.create( utils.AsyncIteratorPrototype, { [Symbol.toStringTag]: { - value: \\"AsyncIterablePairNoArgs AsyncIterator\\", + value: \\"AsyncIterableWithReturn AsyncIterator\\", configurable: true } }, @@ -10902,7 +12296,7 @@ exports.install = (globalObject, globalNames) => { const internal = this && this[utils.iterInternalSymbol]; if (!internal) { return Promise.reject( - new TypeError(\\"next() called on a value that is not a AsyncIterablePairNoArgs async iterator object\\") + new TypeError(\\"next() called on a value that is not a AsyncIterableWithReturn async iterator object\\") ); } @@ -10919,7 +12313,7 @@ exports.install = (globalObject, globalNames) => { internal.isFinished = true; return { value: undefined, done: true }; } - return utils.iteratorResult(next.map(utils.tryWrapperForImpl), kind); + return { value: utils.tryWrapperForImpl(next), done: false }; }, reason => { internal.ongoingPromise = null; @@ -10933,6 +12327,29 @@ exports.install = (globalObject, globalNames) => { ? internal.ongoingPromise.then(nextSteps, nextSteps) : nextSteps(); return internal.ongoingPromise; + }, + + return(value) { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + return Promise.reject( + new TypeError(\\"return() called on a value that is not a AsyncIterableWithReturn async iterator object\\") + ); + } + + const returnSteps = () => { + if (internal.isFinished) { + return Promise.resolve({ value, done: true }); + } + internal.isFinished = true; + + return internal.target[implSymbol][utils.asyncIteratorReturn](this, value); + }; + + const returnPromise = internal.ongoingPromise + ? internal.ongoingPromise.then(returnSteps, returnSteps) + : returnSteps(); + return returnPromise.then(() => ({ value, done: true })); } } ) @@ -10941,25 +12358,24 @@ exports.install = (globalObject, globalNames) => { Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: AsyncIterablePairNoArgs + value: AsyncIterableWithReturn }); }; -const Impl = require(\\"../implementations/AsyncIterablePairNoArgs.js\\"); +const Impl = require(\\"../implementations/AsyncIterableWithReturn.js\\"); " `; -exports[`generation without processors AsyncIterableValueArgs.webidl 1`] = ` +exports[`generation without processors BufferSourceTypes.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 = \\"AsyncIterableValueArgs\\"; +const interfaceName = \\"BufferSourceTypes\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -10971,18 +12387,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'AsyncIterableValueArgs'.\`); -}; - -exports.createDefaultAsyncIterator = (globalObject, target, kind) => { - const ctorRegistry = globalObject[ctorRegistrySymbol]; - const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableValueArgs AsyncIterator\\"]; - const iterator = Object.create(asyncIteratorPrototype); - Object.defineProperty(iterator, utils.iterInternalSymbol, { - value: { target, kind, ongoingPromise: null, isFinished: false }, - configurable: true - }); - return iterator; + throw new TypeError(\`\${context} is not of type 'BufferSourceTypes'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -10992,7 +12397,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableValueArgs\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"BufferSourceTypes\\"].prototype; } return Object.create(proto); @@ -11050,102 +12455,191 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class AsyncIterableValueArgs { + class BufferSourceTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - values() { - if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableValueArgs.\\"); + bs(source) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'bs' called on an object that is not a valid instance of BufferSourceTypes.\\"); } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'bs' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } const args = []; - if (arguments[0] !== undefined) { - args[0] = arguments[0]; - args[0] = URL.convert(args[0], { - context: \\"Failed to execute 'values' on 'AsyncIterableValueArgs': parameter 1\\" + { + let curArg = arguments[0]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'bs' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].bs(...args); + } + + ab(ab) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'ab' called on an object that is not a valid instance of BufferSourceTypes.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'ab' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"ArrayBuffer\\"](curArg, { + context: \\"Failed to execute 'ab' on 'BufferSourceTypes': parameter 1\\" }); - } else { - args[0] = undefined; + args.push(curArg); + } + return esValue[implSymbol].ab(...args); + } + + abv(abv) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'abv' called on an object that is not a valid instance of BufferSourceTypes.\\"); } - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'abv' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - return asyncIterator; + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'abv' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].abv(...args); } - } - Object.defineProperties(AsyncIterableValueArgs.prototype, { - values: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"AsyncIterableValueArgs\\", configurable: true }, - [Symbol.asyncIterator]: { value: AsyncIterableValueArgs.prototype.values, configurable: true, writable: true } - }); - ctorRegistry[interfaceName] = AsyncIterableValueArgs; - ctorRegistry[\\"AsyncIterableValueArgs AsyncIterator\\"] = Object.assign( - Object.create( - utils.AsyncIteratorPrototype, + u8a(u8) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'u8a' called on an object that is not a valid instance of BufferSourceTypes.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'u8a' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"Uint8Array\\"](curArg, { + context: \\"Failed to execute 'u8a' on 'BufferSourceTypes': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].u8a(...args); + } + + abUnion(ab) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'abUnion' called on an object that is not a valid instance of BufferSourceTypes.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'abUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; { - [Symbol.toStringTag]: { - value: \\"AsyncIterableValueArgs AsyncIterator\\", - configurable: true + let curArg = arguments[0]; + if (utils.isArrayBuffer(curArg)) { + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'abUnion' on 'BufferSourceTypes': parameter 1\\" + }); } - }, - { - next() { - const internal = this && this[utils.iterInternalSymbol]; - if (!internal) { - return Promise.reject( - new TypeError(\\"next() called on a value that is not a AsyncIterableValueArgs async iterator object\\") - ); - } - - const nextSteps = () => { - if (internal.isFinished) { - return Promise.resolve({ value: undefined, done: true }); - } + args.push(curArg); + } + return esValue[implSymbol].abUnion(...args); + } - const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); - return nextPromise.then( - next => { - internal.ongoingPromise = null; - if (next === utils.asyncIteratorEOI) { - internal.isFinished = true; - return { value: undefined, done: true }; - } - return { value: utils.tryWrapperForImpl(next), done: false }; - }, - reason => { - internal.ongoingPromise = null; - internal.isFinished = true; - throw reason; - } - ); - }; + u8aUnion(ab) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'u8aUnion' called on an object that is not a valid instance of BufferSourceTypes.\\"); + } - internal.ongoingPromise = internal.ongoingPromise - ? internal.ongoingPromise.then(nextSteps, nextSteps) - : nextSteps(); - return internal.ongoingPromise; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg) && curArg.constructor.name === \\"Uint8Array\\") { + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': parameter 1\\" + }); } + args.push(curArg); } - ) - ); + return esValue[implSymbol].u8aUnion(...args); + } + } + Object.defineProperties(BufferSourceTypes.prototype, { + bs: { enumerable: true }, + ab: { enumerable: true }, + abv: { enumerable: true }, + u8a: { enumerable: true }, + abUnion: { enumerable: true }, + u8aUnion: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"BufferSourceTypes\\", configurable: true } + }); + ctorRegistry[interfaceName] = BufferSourceTypes; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: AsyncIterableValueArgs + value: BufferSourceTypes }); }; -const Impl = require(\\"../implementations/AsyncIterableValueArgs.js\\"); +const Impl = require(\\"../implementations/BufferSourceTypes.js\\"); " `; -exports[`generation without processors AsyncIterableValueNoArgs.webidl 1`] = ` +exports[`generation without processors CEReactions.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -11154,7 +12648,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"AsyncIterableValueNoArgs\\"; +const interfaceName = \\"CEReactions\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -11166,18 +12660,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'AsyncIterableValueNoArgs'.\`); -}; - -exports.createDefaultAsyncIterator = (globalObject, target, kind) => { - const ctorRegistry = globalObject[ctorRegistrySymbol]; - const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableValueNoArgs AsyncIterator\\"]; - const iterator = Object.create(asyncIteratorPrototype); - Object.defineProperty(iterator, utils.iterInternalSymbol, { - value: { target, kind, ongoingPromise: null, isFinished: false }, - configurable: true - }); - return iterator; + throw new TypeError(\`\${context} is not of type 'CEReactions'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -11187,12 +12670,21 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableValueNoArgs\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"CEReactions\\"].prototype; } return Object.create(proto); } +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + exports.create = (globalObject, constructorArgs, privateData) => { const wrapper = makeWrapper(globalObject); return exports.setup(wrapper, globalObject, constructorArgs, privateData); @@ -11214,6 +12706,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) configurable: true }); + wrapper = makeProxy(wrapper, globalObject); + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -11222,7 +12716,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); + let wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -11230,6 +12724,8 @@ exports.new = (globalObject, newTarget) => { configurable: true }); + wrapper = makeProxy(wrapper, globalObject); + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -11245,309 +12741,359 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class AsyncIterableValueNoArgs { + class CEReactions { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - values() { - if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableValueNoArgs.\\"); + method() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'method' called on an object that is not a valid instance of CEReactions.\\"); } - const args = []; + return esValue[implSymbol].method(); + } - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, 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 CEReactions.\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].promiseOperation()); + } catch (e) { + return Promise.reject(e); } - return asyncIterator; } - } - Object.defineProperties(AsyncIterableValueNoArgs.prototype, { - values: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"AsyncIterableValueNoArgs\\", configurable: true }, - [Symbol.asyncIterator]: { value: AsyncIterableValueNoArgs.prototype.values, configurable: true, writable: true } - }); - ctorRegistry[interfaceName] = AsyncIterableValueNoArgs; - ctorRegistry[\\"AsyncIterableValueNoArgs AsyncIterator\\"] = Object.assign( - Object.create( - utils.AsyncIteratorPrototype, - { - [Symbol.toStringTag]: { - value: \\"AsyncIterableValueNoArgs AsyncIterator\\", - configurable: true - } - }, - { - next() { - const internal = this && this[utils.iterInternalSymbol]; - if (!internal) { - return Promise.reject( - new TypeError(\\"next() called on a value that is not a AsyncIterableValueNoArgs async iterator object\\") - ); - } + get attr() { + const esValue = this !== null && this !== undefined ? this : globalObject; - const nextSteps = () => { - if (internal.isFinished) { - return Promise.resolve({ value: undefined, done: true }); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"'get attr' called on an object that is not a valid instance of CEReactions.\\"); + } - const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); - return nextPromise.then( - next => { - internal.ongoingPromise = null; - if (next === utils.asyncIteratorEOI) { - internal.isFinished = true; - return { value: undefined, done: true }; - } - return { value: utils.tryWrapperForImpl(next), done: false }; - }, - reason => { - internal.ongoingPromise = null; - internal.isFinished = true; - throw reason; - } - ); - }; + return esValue[implSymbol][\\"attr\\"]; + } - internal.ongoingPromise = internal.ongoingPromise - ? internal.ongoingPromise.then(nextSteps, nextSteps) - : nextSteps(); - return internal.ongoingPromise; + set attr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set attr' called on an object that is not a valid instance of CEReactions.\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'attr' property on 'CEReactions': The provided value\\" + }); + + esValue[implSymbol][\\"attr\\"] = V; + } + + 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 CEReactions.\\" + ); } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"promiseAttribute\\"]); + } catch (e) { + return Promise.reject(e); } - ) - ); + } + } + Object.defineProperties(CEReactions.prototype, { + method: { enumerable: true }, + promiseOperation: { enumerable: true }, + attr: { enumerable: true }, + promiseAttribute: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"CEReactions\\", configurable: true } + }); + ctorRegistry[interfaceName] = CEReactions; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: AsyncIterableValueNoArgs + value: CEReactions }); }; -const Impl = require(\\"../implementations/AsyncIterableValueNoArgs.js\\"); -" -`; +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } -exports[`generation without processors AsyncIterableWithReturn.webidl 1`] = ` -"\\"use strict\\"; + 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, []); + } -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + 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; + } -const Dictionary = require(\\"./Dictionary.js\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; + ownKeys(target) { + const keys = new Set(); -const interfaceName = \\"AsyncIterableWithReturn\\"; + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(\`\${key}\`); + } + } -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); + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; } - throw new TypeError(\`\${context} is not of type 'AsyncIterableWithReturn'.\`); -}; -exports.createDefaultAsyncIterator = (globalObject, target, kind) => { - const ctorRegistry = globalObject[ctorRegistrySymbol]; - const asyncIteratorPrototype = ctorRegistry[\\"AsyncIterableWithReturn AsyncIterator\\"]; - const iterator = Object.create(asyncIteratorPrototype); - Object.defineProperty(iterator, utils.iterInternalSymbol, { - value: { target, kind, ongoingPromise: null, isFinished: false }, - configurable: true - }); - return iterator; -}; + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; -function makeWrapper(globalObject, newTarget) { - let proto; - if (newTarget !== undefined) { - proto = newTarget.prototype; - } + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { + const namedValue = target[implSymbol][utils.namedGet](P); - if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"AsyncIterableWithReturn\\"].prototype; - } + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } - return Object.create(proto); -} + return Reflect.getOwnPropertyDescriptor(target, P); + } -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; + 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) { + const globalObject = this._globalObject; -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; + if (typeof P === \\"string\\") { + let namedValue = V; -exports._internalSetup = (wrapper, globalObject) => {}; + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': The provided value\\" + }); -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; + const creating = !target[implSymbol][utils.supportsPropertyName](P); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + return true; + } + } + let ownDesc; - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); + 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); } - return wrapper; -}; -exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); + } - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true - }); + const globalObject = this._globalObject; + if (!utils.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; + } - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; + let namedValue = desc.value; -const exposed = new Set([\\"Window\\"]); + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': The provided value\\" + }); -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - 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; + } + return Reflect.defineProperty(target, P, desc); } - const ctorRegistry = utils.initCtorRegistry(globalObject); - class AsyncIterableWithReturn { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { + target[implSymbol][utils.namedDelete](P); + return true; } - values() { - if (!exports.is(this)) { - throw new TypeError(\\"'values' called on an object that is not a valid instance of AsyncIterableWithReturn.\\"); - } + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require(\\"../implementations/CEReactions.js\\"); +" +`; + +exports[`generation without processors CallbackUsage.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const Function = require(\\"./Function.js\\"); +const URLCallback = require(\\"./URLCallback.js\\"); +const URLHandlerNonNull = require(\\"./URLHandlerNonNull.js\\"); +const VoidFunction = require(\\"./VoidFunction.js\\"); - const args = []; - args[0] = arguments[0]; - args[0] = Dictionary.convert(args[0], { - context: \\"Failed to execute 'values' on 'AsyncIterableWithReturn': parameter 1\\" - }); +exports._convertInherit = (obj, ret, { context = \\"The provided value\\" } = {}) => { + { + const key = \\"function\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = Function.convert(value, { context: context + \\" has member 'function' that\\" }); - const asyncIterator = exports.createDefaultAsyncIterator(globalObject, this, \\"value\\"); - if (this[implSymbol][utils.asyncIteratorInit]) { - this[implSymbol][utils.asyncIteratorInit](asyncIterator, args); - } - return asyncIterator; + ret[key] = value; } } - Object.defineProperties(AsyncIterableWithReturn.prototype, { - values: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"AsyncIterableWithReturn\\", configurable: true }, - [Symbol.asyncIterator]: { value: AsyncIterableWithReturn.prototype.values, configurable: true, writable: true } - }); - ctorRegistry[interfaceName] = AsyncIterableWithReturn; - ctorRegistry[\\"AsyncIterableWithReturn AsyncIterator\\"] = Object.assign( - Object.create( - utils.AsyncIteratorPrototype, - { - [Symbol.toStringTag]: { - value: \\"AsyncIterableWithReturn AsyncIterator\\", - configurable: true - } - }, - { - next() { - const internal = this && this[utils.iterInternalSymbol]; - if (!internal) { - return Promise.reject( - new TypeError(\\"next() called on a value that is not a AsyncIterableWithReturn async iterator object\\") - ); - } + { + const key = \\"urlCallback\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = URLCallback.convert(value, { context: context + \\" has member 'urlCallback' that\\" }); - const nextSteps = () => { - if (internal.isFinished) { - return Promise.resolve({ value: undefined, done: true }); - } + ret[key] = value; + } + } - const nextPromise = internal.target[implSymbol][utils.asyncIteratorNext](this); - return nextPromise.then( - next => { - internal.ongoingPromise = null; - if (next === utils.asyncIteratorEOI) { - internal.isFinished = true; - return { value: undefined, done: true }; - } - return { value: utils.tryWrapperForImpl(next), done: false }; - }, - reason => { - internal.ongoingPromise = null; - internal.isFinished = true; - throw reason; - } - ); - }; + { + const key = \\"urlHandler\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + value = null; + } else { + value = URLHandlerNonNull.convert(value, { context: context + \\" has member 'urlHandler' that\\" }); + } + ret[key] = value; + } + } - internal.ongoingPromise = internal.ongoingPromise - ? internal.ongoingPromise.then(nextSteps, nextSteps) - : nextSteps(); - return internal.ongoingPromise; - }, + { + const key = \\"urlHandlerNonNull\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = URLHandlerNonNull.convert(value, { context: context + \\" has member 'urlHandlerNonNull' that\\" }); - return(value) { - const internal = this && this[utils.iterInternalSymbol]; - if (!internal) { - return Promise.reject( - new TypeError(\\"return() called on a value that is not a AsyncIterableWithReturn async iterator object\\") - ); - } + ret[key] = value; + } + } - const returnSteps = () => { - if (internal.isFinished) { - return Promise.resolve({ value, done: true }); - } - internal.isFinished = true; + { + const key = \\"voidFunction\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = VoidFunction.convert(value, { context: context + \\" has member 'voidFunction' that\\" }); - return internal.target[implSymbol][utils.asyncIteratorReturn](this, value); - }; + ret[key] = value; + } + } +}; - const returnPromise = internal.ongoingPromise - ? internal.ongoingPromise.then(returnSteps, returnSteps) - : returnSteps(); - return returnPromise.then(() => ({ value, done: true })); - } - } - ) - ); +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (obj !== undefined && typeof obj !== \\"object\\" && typeof obj !== \\"function\\") { + throw new TypeError(\`\${context} is not an object.\`); + } - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: AsyncIterableWithReturn - }); + const ret = Object.create(null); + exports._convertInherit(obj, ret, { context }); + return ret; }; - -const Impl = require(\\"../implementations/AsyncIterableWithReturn.js\\"); " `; -exports[`generation without processors BufferSourceTypes.webidl 1`] = ` +exports[`generation without processors DOMImplementation.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -11556,7 +13102,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"BufferSourceTypes\\"; +const interfaceName = \\"DOMImplementation\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -11568,7 +13114,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'BufferSourceTypes'.\`); + throw new TypeError(\`\${context} is not of type 'DOMImplementation'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -11578,7 +13124,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"BufferSourceTypes\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"].prototype; } return Object.create(proto); @@ -11636,48 +13182,22 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class BufferSourceTypes { + class DOMImplementation { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - bs(source) { + createDocumentType(qualifiedName, publicId, systemId) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'bs' called on an object that is not a valid instance of BufferSourceTypes.\\"); - } - - if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'bs' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" + \\"'createDocumentType' called on an object that is not a valid instance of DOMImplementation.\\" ); } - const args = []; - { - let curArg = arguments[0]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'bs' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - return esValue[implSymbol].bs(...args); - } - - ab(ab) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'ab' called on an object that is not a valid instance of BufferSourceTypes.\\"); - } - if (arguments.length < 1) { + if (arguments.length < 3) { throw new TypeError( - \\"Failed to execute 'ab' on 'BufferSourceTypes': 1 argument required, but only \\" + + \\"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only \\" + arguments.length + \\" present.\\" ); @@ -11685,74 +13205,37 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"ArrayBuffer\\"](curArg, { - context: \\"Failed to execute 'ab' on 'BufferSourceTypes': parameter 1\\" + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1\\" }); args.push(curArg); } - return esValue[implSymbol].ab(...args); - } - - abv(abv) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'abv' called on an object that is not a valid instance of BufferSourceTypes.\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'abv' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'abv' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" - ); - } + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2\\" + }); args.push(curArg); } - return esValue[implSymbol].abv(...args); - } - - u8a(u8) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'u8a' called on an object that is not a valid instance of BufferSourceTypes.\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'u8a' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; { - let curArg = arguments[0]; - curArg = conversions[\\"Uint8Array\\"](curArg, { - context: \\"Failed to execute 'u8a' on 'BufferSourceTypes': parameter 1\\" + let curArg = arguments[2]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3\\" }); args.push(curArg); } - return esValue[implSymbol].u8a(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args)); } - abUnion(ab) { + createDocument(namespace, qualifiedName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'abUnion' called on an object that is not a valid instance of BufferSourceTypes.\\"); + throw new TypeError(\\"'createDocument' called on an object that is not a valid instance of DOMImplementation.\\"); } - if (arguments.length < 1) { + if (arguments.length < 2) { throw new TypeError( - \\"Failed to execute 'abUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + + \\"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only \\" + arguments.length + \\" present.\\" ); @@ -11760,76 +13243,99 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - if (utils.isArrayBuffer(curArg)) { + if (curArg === null || curArg === undefined) { + curArg = null; } else { curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'abUnion' on 'BufferSourceTypes': parameter 1\\" + context: \\"Failed to execute 'createDocument' on 'DOMImplementation': parameter 1\\" }); } args.push(curArg); } - return esValue[implSymbol].abUnion(...args); + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createDocument' on 'DOMImplementation': parameter 2\\", + treatNullAsEmptyString: true + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args)); } - u8aUnion(ab) { + createHTMLDocument() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'u8aUnion' called on an object that is not a valid instance of BufferSourceTypes.\\"); - } - - if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" + \\"'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation.\\" ); } const args = []; { let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg) && curArg.constructor.name === \\"Uint8Array\\") { - } else { + if (curArg !== undefined) { curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': parameter 1\\" + context: \\"Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1\\" }); } args.push(curArg); } - return esValue[implSymbol].u8aUnion(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args)); + } + + hasFeature() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'hasFeature' called on an object that is not a valid instance of DOMImplementation.\\"); + } + + return esValue[implSymbol].hasFeature(); } } - Object.defineProperties(BufferSourceTypes.prototype, { - bs: { enumerable: true }, - ab: { enumerable: true }, - abv: { enumerable: true }, - u8a: { enumerable: true }, - abUnion: { enumerable: true }, - u8aUnion: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"BufferSourceTypes\\", configurable: true } + Object.defineProperties(DOMImplementation.prototype, { + createDocumentType: { enumerable: true }, + createDocument: { enumerable: true }, + createHTMLDocument: { enumerable: true }, + hasFeature: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DOMImplementation\\", configurable: true } }); - ctorRegistry[interfaceName] = BufferSourceTypes; + ctorRegistry[interfaceName] = DOMImplementation; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: BufferSourceTypes + value: DOMImplementation }); }; -const Impl = require(\\"../implementations/BufferSourceTypes.js\\"); +const Impl = require(\\"../implementations/DOMImplementation.js\\"); " `; -exports[`generation without processors CEReactions.webidl 1`] = ` +exports[`generation without processors DOMRect.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"CEReactions\\"; +const interfaceName = \\"DOMRect\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -11841,7 +13347,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'CEReactions'.\`); + throw new TypeError(\`\${context} is not of type 'DOMRect'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -11851,21 +13357,12 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"CEReactions\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"DOMRect\\"].prototype; } return Object.create(proto); } -function makeProxy(wrapper, globalObject) { - let proxyHandler = proxyHandlerCache.get(globalObject); - if (proxyHandler === undefined) { - proxyHandler = new ProxyHandler(globalObject); - proxyHandlerCache.set(globalObject, proxyHandler); - } - return new Proxy(wrapper, proxyHandler); -} - exports.create = (globalObject, constructorArgs, privateData) => { const wrapper = makeWrapper(globalObject); return exports.setup(wrapper, globalObject, constructorArgs, privateData); @@ -11887,8 +13384,6 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) configurable: true }); - wrapper = makeProxy(wrapper, globalObject); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -11897,7 +13392,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) }; exports.new = (globalObject, newTarget) => { - let wrapper = makeWrapper(globalObject, newTarget); + const wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { @@ -11905,8 +13400,6 @@ exports.new = (globalObject, newTarget) => { configurable: true }); - wrapper = makeProxy(wrapper, globalObject); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); @@ -11914,7 +13407,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Window\\", \\"Worker\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -11922,340 +13415,251 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class CEReactions { + class DOMRect { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - method() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'method' called on an object that is not a valid instance of CEReactions.\\"); - } - - return esValue[implSymbol].method(); - } - - 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 CEReactions.\\"); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 1\\" + }); + } else { + curArg = 0; } - - return utils.tryWrapperForImpl(esValue[implSymbol].promiseOperation()); - } catch (e) { - return Promise.reject(e); - } - } - - get attr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get attr' called on an object that is not a valid instance of CEReactions.\\"); - } - - return esValue[implSymbol][\\"attr\\"]; - } - - set attr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set attr' called on an object that is not a valid instance of CEReactions.\\"); + args.push(curArg); } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'attr' property on 'CEReactions': The provided value\\" - }); - - esValue[implSymbol][\\"attr\\"] = V; - } - - 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 CEReactions.\\" - ); + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 2\\" + }); + } else { + curArg = 0; } - - return utils.tryWrapperForImpl(esValue[implSymbol][\\"promiseAttribute\\"]); - } catch (e) { - return Promise.reject(e); + args.push(curArg); } - } - } - Object.defineProperties(CEReactions.prototype, { - method: { enumerable: true }, - promiseOperation: { enumerable: true }, - attr: { enumerable: true }, - promiseAttribute: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"CEReactions\\", configurable: true } - }); - ctorRegistry[interfaceName] = CEReactions; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: CEReactions - }); -}; - -const proxyHandlerCache = new WeakMap(); -class ProxyHandler { - constructor(globalObject) { - this._globalObject = globalObject; - } - - 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; + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 3\\" + }); + } else { + curArg = 0; + } + args.push(curArg); } - 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); + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 4\\" + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - return false; - } - ownKeys(target) { - const keys = new Set(); + get x() { + const esValue = this !== null && this !== undefined ? this : globalObject; - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); + if (!exports.is(esValue)) { + throw new TypeError(\\"'get x' called on an object that is not a valid instance of DOMRect.\\"); } - } - for (const key of Reflect.ownKeys(target)) { - keys.add(key); + return esValue[implSymbol][\\"x\\"]; } - return [...keys]; - } - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - let ignoreNamedProps = false; + set x(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { - const namedValue = target[implSymbol][utils.namedGet](P); + if (!exports.is(esValue)) { + throw new TypeError(\\"'set x' called on an object that is not a valid instance of DOMRect.\\"); + } - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'x' property on 'DOMRect': The provided value\\" + }); + + esValue[implSymbol][\\"x\\"] = V; } - return Reflect.getOwnPropertyDescriptor(target, P); - } + get y() { + const esValue = this !== null && this !== undefined ? this : globalObject; - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); + if (!exports.is(esValue)) { + throw new TypeError(\\"'get y' called on an object that is not a valid instance of DOMRect.\\"); + } + + return esValue[implSymbol][\\"y\\"]; } - // 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) { - const globalObject = this._globalObject; - if (typeof P === \\"string\\") { - let namedValue = V; + set y(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': The provided value\\" - }); + if (!exports.is(esValue)) { + throw new TypeError(\\"'set y' called on an object that is not a valid instance of DOMRect.\\"); + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" + }); - return true; - } + esValue[implSymbol][\\"y\\"] = V; } - 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); - } - 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; + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get width' called on an object that is not a valid instance of DOMRect.\\"); } - 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 esValue[implSymbol][\\"width\\"]; } - const globalObject = this._globalObject; - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; - } + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - let namedValue = desc.value; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set width' called on an object that is not a valid instance of DOMRect.\\"); + } - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': The provided value\\" + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'width' property on 'DOMRect': 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); + esValue[implSymbol][\\"width\\"] = V; + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get height' called on an object that is not a valid instance of DOMRect.\\"); } - return true; + return esValue[implSymbol][\\"height\\"]; } - return Reflect.defineProperty(target, P, desc); - } - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - const globalObject = this._globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set height' called on an object that is not a valid instance of DOMRect.\\"); + } - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - target[implSymbol][utils.namedDelete](P); - return true; + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'height' property on 'DOMRect': The provided value\\" + }); + + esValue[implSymbol][\\"height\\"] = V; } - return Reflect.deleteProperty(target, P); + static fromRect() { + const args = []; + { + let curArg = arguments[0]; + curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'fromRect' on 'DOMRect': parameter 1\\" }); + args.push(curArg); + } + return utils.tryWrapperForImpl(Impl.implementation.fromRect(globalObject, ...args)); + } } + Object.defineProperties(DOMRect.prototype, { + x: { enumerable: true }, + y: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DOMRect\\", configurable: true } + }); + Object.defineProperties(DOMRect, { fromRect: { enumerable: true } }); + ctorRegistry[interfaceName] = DOMRect; - preventExtensions() { - return false; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMRect + }); + + if (globalNames.includes(\\"Window\\")) { + Object.defineProperty(globalObject, \\"SVGRect\\", { + configurable: true, + writable: true, + value: DOMRect + }); } -} +}; -const Impl = require(\\"../implementations/CEReactions.js\\"); +const Impl = require(\\"../implementations/DOMRect.js\\"); " `; -exports[`generation without processors CallbackUsage.webidl 1`] = ` +exports[`generation without processors Dictionary.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const Function = require(\\"./Function.js\\"); -const URLCallback = require(\\"./URLCallback.js\\"); -const URLHandlerNonNull = require(\\"./URLHandlerNonNull.js\\"); -const VoidFunction = require(\\"./VoidFunction.js\\"); +const URL = require(\\"./URL.js\\"); +const URLSearchParams = require(\\"./URLSearchParams.js\\"); exports._convertInherit = (obj, ret, { context = \\"The provided value\\" } = {}) => { { - const key = \\"function\\"; + const key = \\"boolWithDefault\\"; let value = obj === undefined || obj === null ? undefined : obj[key]; if (value !== undefined) { - value = Function.convert(value, { context: context + \\" has member 'function' that\\" }); + value = conversions[\\"boolean\\"](value, { context: context + \\" has member 'boolWithDefault' that\\" }); ret[key] = value; + } else { + ret[key] = false; } } { - const key = \\"urlCallback\\"; + const key = \\"requiredInterface\\"; let value = obj === undefined || obj === null ? undefined : obj[key]; if (value !== undefined) { - value = URLCallback.convert(value, { context: context + \\" has member 'urlCallback' that\\" }); + value = URL.convert(value, { context: context + \\" has member 'requiredInterface' that\\" }); ret[key] = value; + } else { + throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); } } { - const key = \\"urlHandler\\"; + const key = \\"seq\\"; let value = obj === undefined || obj === null ? undefined : obj[key]; if (value !== undefined) { if (!utils.isObject(value)) { - value = null; + throw new TypeError(context + \\" has member 'seq' that\\" + \\" is not an iterable object.\\"); } else { - value = URLHandlerNonNull.convert(value, { context: context + \\" has member 'urlHandler' that\\" }); - } - ret[key] = value; - } - } + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = URLSearchParams.convert(nextItem, { context: context + \\" has member 'seq' that\\" + \\"'s element\\" }); - { - const key = \\"urlHandlerNonNull\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - value = URLHandlerNonNull.convert(value, { context: context + \\" has member 'urlHandlerNonNull' that\\" }); + V.push(nextItem); + } + value = V; + } ret[key] = value; } } { - const key = \\"voidFunction\\"; + const key = \\"vanillaString\\"; let value = obj === undefined || obj === null ? undefined : obj[key]; if (value !== undefined) { - value = VoidFunction.convert(value, { context: context + \\" has member 'voidFunction' that\\" }); + value = conversions[\\"DOMString\\"](value, { context: context + \\" has member 'vanillaString' that\\" }); ret[key] = value; } @@ -12274,16 +13678,17 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = " `; -exports[`generation without processors DOMImplementation.webidl 1`] = ` +exports[`generation without processors DictionaryConvert.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"DOMImplementation\\"; +const interfaceName = \\"DictionaryConvert\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12295,7 +13700,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'DOMImplementation'.\`); + throw new TypeError(\`\${context} is not of type 'DictionaryConvert'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12305,7 +13710,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"DictionaryConvert\\"].prototype; } return Object.create(proto); @@ -12363,160 +13768,62 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class DOMImplementation { + class DictionaryConvert { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - createDocumentType(qualifiedName, publicId, systemId) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'createDocumentType' called on an object that is not a valid instance of DOMImplementation.\\" - ); - } - - if (arguments.length < 3) { - throw new TypeError( - \\"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2\\" - }); - args.push(curArg); - } - { - let curArg = arguments[2]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args)); - } - - createDocument(namespace, qualifiedName) { + op() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'createDocument' called on an object that is not a valid instance of DOMImplementation.\\"); - } - - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); + throw new TypeError(\\"'op' called on an object that is not a valid instance of DictionaryConvert.\\"); } const args = []; { let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { + if (curArg !== undefined) { curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocument' on 'DOMImplementation': parameter 1\\" + context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 1\\" }); } args.push(curArg); } { let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocument' on 'DOMImplementation': parameter 2\\", - treatNullAsEmptyString: true - }); - args.push(curArg); - } - { - let curArg = arguments[2]; - if (curArg !== undefined) { - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - curArg = utils.tryImplForWrapper(curArg); - } - } else { - curArg = null; - } - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args)); - } - - createHTMLDocument() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError( - \\"'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1\\" - }); - } + curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); args.push(curArg); } - return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args)); - } - - hasFeature() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'hasFeature' called on an object that is not a valid instance of DOMImplementation.\\"); - } - - return esValue[implSymbol].hasFeature(); + return esValue[implSymbol].op(...args); } } - Object.defineProperties(DOMImplementation.prototype, { - createDocumentType: { enumerable: true }, - createDocument: { enumerable: true }, - createHTMLDocument: { enumerable: true }, - hasFeature: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DOMImplementation\\", configurable: true } + Object.defineProperties(DictionaryConvert.prototype, { + op: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } }); - ctorRegistry[interfaceName] = DOMImplementation; + ctorRegistry[interfaceName] = DictionaryConvert; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: DOMImplementation + value: DictionaryConvert }); }; -const Impl = require(\\"../implementations/DOMImplementation.js\\"); +const Impl = require(\\"../implementations/DictionaryConvert.js\\"); " `; -exports[`generation without processors DOMRect.webidl 1`] = ` +exports[`generation without processors Enum.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const Dictionary = require(\\"./Dictionary.js\\"); +const RequestDestination = require(\\"./RequestDestination.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"DOMRect\\"; +const interfaceName = \\"Enum\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12528,7 +13835,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'DOMRect'.\`); + throw new TypeError(\`\${context} is not of type 'Enum'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12538,7 +13845,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"DOMRect\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"Enum\\"].prototype; } return Object.create(proto); @@ -12588,7 +13895,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\", \\"Worker\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -12596,280 +13903,270 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class DOMRect { + class Enum { constructor() { - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 1\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 2\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 3\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - { - let curArg = arguments[3]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 4\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - return exports.setup(Object.create(new.target.prototype), globalObject, args); - } - - get x() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get x' called on an object that is not a valid instance of DOMRect.\\"); - } - - return esValue[implSymbol][\\"x\\"]; - } - - set x(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set x' called on an object that is not a valid instance of DOMRect.\\"); - } - - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'x' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"x\\"] = V; - } - - get y() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get y' called on an object that is not a valid instance of DOMRect.\\"); - } - - return esValue[implSymbol][\\"y\\"]; + throw new TypeError(\\"Illegal constructor\\"); } - set y(V) { + op(destination) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set y' called on an object that is not a valid instance of DOMRect.\\"); + throw new TypeError(\\"'op' called on an object that is not a valid instance of Enum.\\"); } - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"y\\"] = V; - } - - get width() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get width' called on an object that is not a valid instance of DOMRect.\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'op' on 'Enum': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); } - - return esValue[implSymbol][\\"width\\"]; - } - - set width(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set width' called on an object that is not a valid instance of DOMRect.\\"); + const args = []; + { + let curArg = arguments[0]; + curArg = RequestDestination.convert(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); + args.push(curArg); } - - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'width' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"width\\"] = V; + return esValue[implSymbol].op(...args); } - get height() { + get attr() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'get height' called on an object that is not a valid instance of DOMRect.\\"); + throw new TypeError(\\"'get attr' called on an object that is not a valid instance of Enum.\\"); } - return esValue[implSymbol][\\"height\\"]; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"attr\\"]); } - set height(V) { + set attr(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'set height' called on an object that is not a valid instance of DOMRect.\\"); + throw new TypeError(\\"'set attr' called on an object that is not a valid instance of Enum.\\"); } - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'height' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"height\\"] = V; - } - - static fromRect() { - const args = []; - { - let curArg = arguments[0]; - curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'fromRect' on 'DOMRect': parameter 1\\" }); - args.push(curArg); + V = \`\${V}\`; + if (!RequestDestination.enumerationValues.has(V)) { + return; } - return utils.tryWrapperForImpl(Impl.implementation.fromRect(globalObject, ...args)); + + esValue[implSymbol][\\"attr\\"] = V; } } - Object.defineProperties(DOMRect.prototype, { - x: { enumerable: true }, - y: { enumerable: true }, - width: { enumerable: true }, - height: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DOMRect\\", configurable: true } + Object.defineProperties(Enum.prototype, { + op: { enumerable: true }, + attr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Enum\\", configurable: true } }); - Object.defineProperties(DOMRect, { fromRect: { enumerable: true } }); - ctorRegistry[interfaceName] = DOMRect; + ctorRegistry[interfaceName] = Enum; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: DOMRect + value: Enum }); +}; - if (globalNames.includes(\\"Window\\")) { - Object.defineProperty(globalObject, \\"SVGRect\\", { - configurable: true, - writable: true, - value: DOMRect - }); +const Impl = require(\\"../implementations/Enum.js\\"); +" +`; + +exports[`generation without processors EventListener.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(event) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + if (typeof O !== \\"function\\") { + X = O[\\"handleEvent\\"]; + if (typeof X !== \\"function\\") { + throw new TypeError(\`\${context} does not correctly implement EventListener.\`); + } + thisArg = O; + } + + event = utils.tryWrapperForImpl(event); + + let callResult = Reflect.apply(X, thisArg, [event]); } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; }; -const Impl = require(\\"../implementations/DOMRect.js\\"); +exports.install = (globalObject, globalNames) => {}; " `; -exports[`generation without processors Dictionary.webidl 1`] = ` +exports[`generation without processors EventTarget.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const URL = require(\\"./URL.js\\"); -const URLSearchParams = require(\\"./URLSearchParams.js\\"); +const EventListener = require(\\"./EventListener.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; -exports._convertInherit = (obj, ret, { context = \\"The provided value\\" } = {}) => { - { - const key = \\"boolWithDefault\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - value = conversions[\\"boolean\\"](value, { context: context + \\" has member 'boolWithDefault' that\\" }); +const interfaceName = \\"EventTarget\\"; - ret[key] = value; - } else { - ret[key] = false; - } +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 'EventTarget'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; } - { - const key = \\"requiredInterface\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - value = URL.convert(value, { context: context + \\" has member 'requiredInterface' that\\" }); + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"EventTarget\\"].prototype; + } - ret[key] = value; - } else { - throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); - } + return Object.create(proto); +} + +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; +}; - { - const key = \\"seq\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - if (!utils.isObject(value)) { - throw new TypeError(context + \\" has member 'seq' that\\" + \\" is not an iterable object.\\"); - } else { - const V = []; - const tmp = value; - for (let nextItem of tmp) { - nextItem = URLSearchParams.convert(nextItem, { context: context + \\" has member 'seq' that\\" + \\"'s element\\" }); +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); - V.push(nextItem); - } - value = V; - } + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); - ret[key] = value; - } + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); } + return wrapper[implSymbol]; +}; - { - const key = \\"vanillaString\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - value = conversions[\\"DOMString\\"](value, { context: context + \\" has member 'vanillaString' that\\" }); +const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); - ret[key] = value; +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class EventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + addEventListener(type, callback) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'addEventListener' called on an object that is not a valid instance of EventTarget.\\"); + } + + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'addEventListener' on 'EventTarget': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = EventListener.convert(curArg, { + context: \\"Failed to execute 'addEventListener' on 'EventTarget': parameter 2\\" + }); + } + args.push(curArg); + } + return esValue[implSymbol].addEventListener(...args); } } -}; - -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (obj !== undefined && typeof obj !== \\"object\\" && typeof obj !== \\"function\\") { - throw new TypeError(\`\${context} is not an object.\`); - } + Object.defineProperties(EventTarget.prototype, { + addEventListener: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"EventTarget\\", configurable: true } + }); + ctorRegistry[interfaceName] = EventTarget; - const ret = Object.create(null); - exports._convertInherit(obj, ret, { context }); - return ret; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: EventTarget + }); }; + +const Impl = require(\\"../implementations/EventTarget.js\\"); " `; -exports[`generation without processors DictionaryConvert.webidl 1`] = ` +exports[`generation without processors Global.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"DictionaryConvert\\"; +const interfaceName = \\"Global\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12881,7 +14178,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'DictionaryConvert'.\`); + throw new TypeError(\`\${context} is not of type 'Global'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12891,7 +14188,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"DictionaryConvert\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"Global\\"].prototype; } return Object.create(proto); @@ -12907,7 +14204,101 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => {}; +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, { + op() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'op' called on an object that is not a valid instance of Global.\\"); + } + + return esValue[implSymbol].op(); + }, + unforgeableOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'unforgeableOp' called on an object that is not a valid instance of Global.\\"); + } + + return esValue[implSymbol].unforgeableOp(); + }, + get attr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get attr' called on an object that is not a valid instance of Global.\\"); + } + + return esValue[implSymbol][\\"attr\\"]; + }, + set attr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set attr' called on an object that is not a valid instance of Global.\\"); + } + + V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'attr' property on 'Global': The provided value\\" }); + + esValue[implSymbol][\\"attr\\"] = V; + }, + get unforgeableAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get unforgeableAttr' called on an object that is not a valid instance of Global.\\"); + } + + return esValue[implSymbol][\\"unforgeableAttr\\"]; + }, + set unforgeableAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'set unforgeableAttr' called on an object that is not a valid instance of Global.\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'unforgeableAttr' property on 'Global': The provided value\\" + }); + + esValue[implSymbol][\\"unforgeableAttr\\"] = V; + }, + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + 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; + + 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]: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], + keys: ctorRegistry[\\"%Array%\\"].prototype.keys, + values: ctorRegistry[\\"%Array%\\"].prototype.values, + entries: ctorRegistry[\\"%Array%\\"].prototype.entries, + forEach: ctorRegistry[\\"%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; @@ -12941,7 +14332,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Global\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -12949,62 +14340,56 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class DictionaryConvert { + class Global { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - op() { + static staticOp() { + return Impl.implementation.staticOp(); + } + + static get staticAttr() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'op' called on an object that is not a valid instance of DictionaryConvert.\\"); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 1\\" - }); - } - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); - args.push(curArg); - } - return esValue[implSymbol].op(...args); + + 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(DictionaryConvert.prototype, { - op: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } - }); - ctorRegistry[interfaceName] = DictionaryConvert; + Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); + Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); + ctorRegistry[interfaceName] = Global; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: DictionaryConvert + value: Global }); }; -const Impl = require(\\"../implementations/DictionaryConvert.js\\"); +const Impl = require(\\"../implementations/Global.js\\"); " `; -exports[`generation without processors Enum.webidl 1`] = ` +exports[`generation without processors HTMLAudioElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const RequestDestination = require(\\"./RequestDestination.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Enum\\"; +const interfaceName = \\"HTMLAudioElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13016,7 +14401,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Enum'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLAudioElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -13026,7 +14411,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"Enum\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLAudioElement\\"].prototype; } return Object.create(proto); @@ -13084,124 +14469,82 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Enum { + class HTMLAudioElement { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - - op(destination) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'op' called on an object that is not a valid instance of Enum.\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'op' on 'Enum': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = RequestDestination.convert(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); - args.push(curArg); - } - return esValue[implSymbol].op(...args); - } - - get attr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get attr' called on an object that is not a valid instance of Enum.\\"); - } - - return utils.tryWrapperForImpl(esValue[implSymbol][\\"attr\\"]); - } - - set attr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set attr' called on an object that is not a valid instance of Enum.\\"); - } - - V = \`\${V}\`; - if (!RequestDestination.enumerationValues.has(V)) { - return; - } - - esValue[implSymbol][\\"attr\\"] = V; - } } - Object.defineProperties(Enum.prototype, { - op: { enumerable: true }, - attr: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Enum\\", configurable: true } + Object.defineProperties(HTMLAudioElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLAudioElement\\", configurable: true } }); - ctorRegistry[interfaceName] = Enum; + ctorRegistry[interfaceName] = HTMLAudioElement; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Enum + value: HTMLAudioElement }); -}; - -const Impl = require(\\"../implementations/Enum.js\\"); -" -`; - -exports[`generation without processors EventListener.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(event) { - let thisArg = utils.tryWrapperForImpl(this); - let O = value; - let X = O; + function Audio() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); + } - if (typeof O !== \\"function\\") { - X = O[\\"handleEvent\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement EventListener.\`); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); } - thisArg = O; + args.push(curArg); } - event = utils.tryWrapperForImpl(event); + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); - let callResult = Reflect.apply(X, thisArg, [event]); + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; } - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; + Object.defineProperty(Audio, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLAudioElement.prototype + }); - return callTheUserObjectsOperation; + Object.defineProperty(globalObject, \\"Audio\\", { + configurable: true, + writable: true, + value: Audio + }); }; -exports.install = (globalObject, globalNames) => {}; +const Impl = require(\\"../implementations/HTMLAudioElement.js\\"); " `; -exports[`generation without processors EventTarget.webidl 1`] = ` +exports[`generation without processors HTMLConstructor.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const EventListener = require(\\"./EventListener.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"EventTarget\\"; +const interfaceName = \\"HTMLConstructor\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13213,7 +14556,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'EventTarget'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLConstructor'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -13223,7 +14566,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"EventTarget\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"].prototype; } return Object.create(proto); @@ -13273,7 +14616,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -13281,64 +14624,28 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class EventTarget { + class HTMLConstructor { constructor() { - return exports.setup(Object.create(new.target.prototype), globalObject, undefined); - } - - addEventListener(type, callback) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'addEventListener' called on an object that is not a valid instance of EventTarget.\\"); - } - - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'addEventListener' on 'EventTarget': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - curArg = EventListener.convert(curArg, { - context: \\"Failed to execute 'addEventListener' on 'EventTarget': parameter 2\\" - }); - } - args.push(curArg); - } - return esValue[implSymbol].addEventListener(...args); + throw new TypeError(\\"Illegal constructor\\"); } } - Object.defineProperties(EventTarget.prototype, { - addEventListener: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"EventTarget\\", configurable: true } + Object.defineProperties(HTMLConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } }); - ctorRegistry[interfaceName] = EventTarget; + ctorRegistry[interfaceName] = HTMLConstructor; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: EventTarget + value: HTMLConstructor }); }; -const Impl = require(\\"../implementations/EventTarget.js\\"); +const Impl = require(\\"../implementations/HTMLConstructor.js\\"); " `; -exports[`generation without processors Global.webidl 1`] = ` +exports[`generation without processors HTMLImageElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13347,7 +14654,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Global\\"; +const interfaceName = \\"HTMLImageElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13359,7 +14666,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Global'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLImageElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -13369,7 +14676,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"Global\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLImageElement\\"].prototype; } return Object.create(proto); @@ -13385,101 +14692,7 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => { return utils.implForWrapper(wrapper); }; -exports._internalSetup = (wrapper, globalObject) => { - utils.define(wrapper, { - op() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'op' called on an object that is not a valid instance of Global.\\"); - } - - return esValue[implSymbol].op(); - }, - unforgeableOp() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'unforgeableOp' called on an object that is not a valid instance of Global.\\"); - } - - return esValue[implSymbol].unforgeableOp(); - }, - get attr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get attr' called on an object that is not a valid instance of Global.\\"); - } - - return esValue[implSymbol][\\"attr\\"]; - }, - set attr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set attr' called on an object that is not a valid instance of Global.\\"); - } - - V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'attr' property on 'Global': The provided value\\" }); - - esValue[implSymbol][\\"attr\\"] = V; - }, - get unforgeableAttr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'get unforgeableAttr' called on an object that is not a valid instance of Global.\\"); - } - - return esValue[implSymbol][\\"unforgeableAttr\\"]; - }, - set unforgeableAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set unforgeableAttr' called on an object that is not a valid instance of Global.\\"); - } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'unforgeableAttr' property on 'Global': The provided value\\" - }); - - esValue[implSymbol][\\"unforgeableAttr\\"] = V; - }, - get length() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - 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; - - 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]: ctorRegistry[\\"%Array%\\"].prototype[Symbol.iterator], - keys: ctorRegistry[\\"%Array%\\"].prototype.keys, - values: ctorRegistry[\\"%Array%\\"].prototype.values, - entries: ctorRegistry[\\"%Array%\\"].prototype.entries, - forEach: ctorRegistry[\\"%Array%\\"].prototype.forEach - }); - - Object.defineProperties(wrapper, { - unforgeableOp: { configurable: false, writable: false }, - unforgeableAttr: { configurable: false }, - [Symbol.iterator]: { enumerable: false } - }); -}; +exports._internalSetup = (wrapper, globalObject) => {}; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; @@ -13513,7 +14726,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Global\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { @@ -13521,47 +14734,80 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Global { + class HTMLImageElement { constructor() { throw new TypeError(\\"Illegal constructor\\"); } + } + Object.defineProperties(HTMLImageElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLImageElement\\", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLImageElement; - static staticOp() { - return Impl.implementation.staticOp(); - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLImageElement + }); - static get staticAttr() { - const esValue = this !== null && this !== undefined ? this : globalObject; + function Image() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); + } - return Impl.implementation[\\"staticAttr\\"]; + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); + } + args.push(curArg); } - static set staticAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'staticAttr' property on 'Global': The provided value\\" - }); + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); - Impl.implementation[\\"staticAttr\\"] = V; + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); } + return wrapper; } - Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); - Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); - ctorRegistry[interfaceName] = Global; - Object.defineProperty(globalObject, interfaceName, { + Object.defineProperty(Image, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLImageElement.prototype + }); + + Object.defineProperty(globalObject, \\"Image\\", { configurable: true, writable: true, - value: Global + value: Image }); }; -const Impl = require(\\"../implementations/Global.js\\"); +const Impl = require(\\"../implementations/HTMLImageElement.js\\"); " `; -exports[`generation without processors HTMLConstructor.webidl 1`] = ` +exports[`generation without processors HTMLOptionElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13570,7 +14816,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"HTMLConstructor\\"; +const interfaceName = \\"HTMLOptionElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13582,7 +14828,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 'HTMLOptionElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -13592,7 +14838,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLOptionElement\\"].prototype; } return Object.create(proto); @@ -13649,25 +14895,97 @@ exports.install = (globalObject, globalNames) => { return; } - const ctorRegistry = utils.initCtorRegistry(globalObject); - class HTMLConstructor { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOptionElement { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(HTMLOptionElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLOptionElement\\", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLOptionElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOptionElement + }); + + function Option() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); + } + + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); + } else { + curArg = \\"\\"; + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); + } else { + curArg = false; + } + args.push(curArg); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); } + return wrapper; } - Object.defineProperties(HTMLConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + + Object.defineProperty(Option, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLOptionElement.prototype }); - ctorRegistry[interfaceName] = HTMLConstructor; - Object.defineProperty(globalObject, interfaceName, { + Object.defineProperty(globalObject, \\"Option\\", { configurable: true, writable: true, - value: HTMLConstructor + value: Option }); }; -const Impl = require(\\"../implementations/HTMLConstructor.js\\"); +const Impl = require(\\"../implementations/HTMLOptionElement.js\\"); " `; @@ -14547,6 +15865,177 @@ const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); " `; +exports[`generation without processors MinArgsLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"MinArgsLegacyFactoryFunctionInterface\\"; + +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 'MinArgsLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"MinArgsLegacyFactoryFunctionInterface\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MinArgsLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(MinArgsLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"MinArgsLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = MinArgsLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MinArgsLegacyFactoryFunctionInterface + }); + + function MinArgsLegacyFactoryFunction(arg1) { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor MinArgsLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to construct 'MinArgsLegacyFactoryFunction': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'MinArgsLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'MinArgsLegacyFactoryFunction': parameter 2\\" + }); + } + args.push(curArg); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, args); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(MinArgsLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: MinArgsLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"MinArgsLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: MinArgsLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/MinArgsLegacyFactoryFunctionInterface.js\\"); +" +`; + exports[`generation without processors MixedIn.webidl 1`] = ` "\\"use strict\\"; @@ -14733,6 +16222,152 @@ const Impl = require(\\"../implementations/MixedIn.js\\"); " `; +exports[`generation without processors NoArgLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"NoArgLegacyFactoryFunctionInterface\\"; + +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 'NoArgLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"NoArgLegacyFactoryFunctionInterface\\"].prototype; + } + + return Object.create(proto); +} + +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, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + 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; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class NoArgLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(NoArgLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"NoArgLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = NoArgLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunctionInterface + }); + + function NoArgLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor NoArgLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const wrapper = makeWrapper(globalObject, newTarget); + exports._internalSetup(wrapper, globalObject); + + const thisValue = Object.create(Impl.implementation.prototype); + const implResult = Impl.legacyFactoryFunction(thisValue, globalObject, []); + + Object.defineProperty(wrapper, implSymbol, { + value: utils.isObject(implResult) ? implResult : thisValue, + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; + } + + Object.defineProperty(NoArgLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: NoArgLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"NoArgLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/NoArgLegacyFactoryFunctionInterface.js\\"); +" +`; + exports[`generation without processors NodeFilter.webidl 1`] = ` "\\"use strict\\"; diff --git a/test/cases/HTMLAudioElement.webidl b/test/cases/HTMLAudioElement.webidl new file mode 100644 index 00000000..04b2d5cc --- /dev/null +++ b/test/cases/HTMLAudioElement.webidl @@ -0,0 +1,6 @@ +// Simplified from https://html.spec.whatwg.org/multipage/media.html#htmlaudioelement + +[Exposed=Window, + HTMLConstructor, + LegacyFactoryFunction=Audio(optional DOMString src)] +interface HTMLAudioElement {}; diff --git a/test/cases/HTMLImageElement.webidl b/test/cases/HTMLImageElement.webidl new file mode 100644 index 00000000..f83415b3 --- /dev/null +++ b/test/cases/HTMLImageElement.webidl @@ -0,0 +1,6 @@ +// Simplified from https://html.spec.whatwg.org/multipage/embedded-content.html#htmlimageelement + +[Exposed=Window, + HTMLConstructor, + LegacyFactoryFunction=Image(optional unsigned long width, optional unsigned long height)] +interface HTMLImageElement {}; diff --git a/test/cases/HTMLOptionElement.webidl b/test/cases/HTMLOptionElement.webidl new file mode 100644 index 00000000..27381907 --- /dev/null +++ b/test/cases/HTMLOptionElement.webidl @@ -0,0 +1,6 @@ +// Simplified from https://html.spec.whatwg.org/multipage/form-elements.html#htmloptionelement + +[Exposed=Window, + HTMLConstructor, + LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] +interface HTMLOptionElement {}; diff --git a/test/cases/MinArgsLegacyFactoryFunctionInterface.webidl b/test/cases/MinArgsLegacyFactoryFunctionInterface.webidl new file mode 100644 index 00000000..6ccc9007 --- /dev/null +++ b/test/cases/MinArgsLegacyFactoryFunctionInterface.webidl @@ -0,0 +1,3 @@ +[Exposed=Window, + LegacyFactoryFunction=MinArgsLegacyFactoryFunction(long arg1, optional long arg2)] +interface MinArgsLegacyFactoryFunctionInterface {}; diff --git a/test/cases/NoArgLegacyFactoryFunctionInterface.webidl b/test/cases/NoArgLegacyFactoryFunctionInterface.webidl new file mode 100644 index 00000000..d326d105 --- /dev/null +++ b/test/cases/NoArgLegacyFactoryFunctionInterface.webidl @@ -0,0 +1,3 @@ +[Exposed=Window, + LegacyFactoryFunction=NoArgLegacyFactoryFunction()] +interface NoArgLegacyFactoryFunctionInterface {};