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..463a985f 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.legacyFactoryFunctions = []; this.indexedGetter = null; this.indexedSetter = null; @@ -391,6 +392,28 @@ class Interface { throw new Error(msg); } } + + let legacyFactoryFunctionName; + 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`); + } + + const name = attr.rhs.value; + if (legacyFactoryFunctionName === undefined) { + legacyFactoryFunctionName = name; + } else if (legacyFactoryFunctionName !== name) { + // 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 with different names are not supported on ${this.name}` + ); + } + + this.legacyFactoryFunctions.push(attr); + } + } } get supportsIndexedProperties() { @@ -1644,6 +1667,73 @@ class Interface { `; } + generateLegacyFactoryFunction() { + const { legacyFactoryFunctions } = this; + if (legacyFactoryFunctions.length === 0) { + return; + } + + const name = legacyFactoryFunctions[0].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 += ` + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, ${argsParam}, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + 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 +1802,8 @@ class Interface { } } + this.generateLegacyFactoryFunction(); + this.str += ` }; `; diff --git a/lib/overloads.js b/lib/overloads.js index 53668234..03d00221 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.legacyFactoryFunctions; } 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..2ced9f23 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,73 @@ 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 thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + 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 +3479,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 +3489,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 +3547,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 +3590,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 +3600,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 +3658,80 @@ 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); } - - set abc(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"'set abc' called on an object that is not a valid instance of LegacyNoInterfaceObject.\\"); + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'abc' property on 'LegacyNoInterfaceObject': The provided value\\" - }); - - esValue[implSymbol][\\"abc\\"] = V; + args.push(curArg); } + + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); } - 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 +3743,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 +3753,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 +3769,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.\\"); - } - - 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._internalSetup = (wrapper, globalObject) => {}; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get href' called on an object that is not a valid instance of LegacyUnforgeable.\\"); - } +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; - return esValue[implSymbol][\\"href\\"]; - }, - set href(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - 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 +3803,6 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -3960,28 +3811,90 @@ 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 thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + 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 +3903,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 +3915,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 +3925,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 +3941,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 +3952,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 +3960,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 +3968,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 +3975,6 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; -const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -4100,205 +3983,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]; - }, + get lenientThisSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"lenientThisSetter\\"]; } - let ignoreNamedProps = false; - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { - const namedValue = target[implSymbol][utils.namedGet](P); + set lenientThisSetter(V) {} - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; - } + get lenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; - return Reflect.getOwnPropertyDescriptor(target, P); - }, + if (!exports.is(esValue)) { + return; + } - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); + return esValue[implSymbol][\\"lenientThis\\"]; } - // 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); - } + set lenientThis(V) { + 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 Reflect.defineProperty(receiver, P, valueDesc); - }, + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" + }); - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); + esValue[implSymbol][\\"lenientThis\\"] = V; } - 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); - } + get readonlyLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; - return true; + 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 +4107,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 +4119,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 +4129,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 +4187,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; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - if (typeof O !== \\"function\\") { - X = O[\\"acceptNode\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement NodeFilter.\`); - } - thisArg = O; - } +const interfaceName = \\"LegacyUnforgeable\\"; - node = utils.tryWrapperForImpl(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'.\`); +}; - let callResult = Reflect.apply(X, thisArg, [node]); +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } - callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"].prototype; + } - return callResult; + 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); +}; + +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; +} - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, getUnforgeables(globalObject)); +}; - return callTheUserObjectsOperation; +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 +4431,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 +4474,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 +4484,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 +4500,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 +4536,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 +4546,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 +4554,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 +4563,7 @@ exports.new = (globalObject, newTarget) => { return wrapper[implSymbol]; }; +const unforgeablesMap = new WeakMap(); const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { @@ -4652,23 +4572,879 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class Overloads { + class LegacyUnforgeableMap { constructor() { - const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (URL.is(curArg)) { - { - let curArg = arguments[0]; - curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; + 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 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 thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, [], { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + 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 OverloadedLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"OverloadedLegacyFactoryFunctionInterface\\"; + +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 'OverloadedLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"OverloadedLegacyFactoryFunctionInterface\\"].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 OverloadedLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(OverloadedLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"OverloadedLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = OverloadedLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunctionInterface + }); + + function OverloadedLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const args = []; + switch (arguments.length) { + case 0: + break; + case 1: + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" + }); + args.push(curArg); + } + } + + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: OverloadedLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/OverloadedLegacyFactoryFunctionInterface.js\\"); +" +`; + +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: { + let curArg = arguments[0]; + if (URL.is(curArg)) { + { + let curArg = arguments[0]; + curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); args.push(curArg); } @@ -12224,66 +13000,299 @@ exports._convertInherit = (obj, ret, { context = \\"The provided value\\" } = {} if (value !== undefined) { value = URLCallback.convert(value, { context: context + \\" has member 'urlCallback' that\\" }); - ret[key] = value; + ret[key] = value; + } + } + + { + 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; + } + } + + { + 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\\" }); + + ret[key] = value; + } + } + + { + 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\\" }); + + ret[key] = value; + } + } +}; + +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.\`); + } + + const ret = Object.create(null); + exports._convertInherit(obj, ret, { context }); + return ret; +}; +" +`; + +exports[`generation without processors DOMImplementation.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"DOMImplementation\\"; + +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 'DOMImplementation'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"].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 DOMImplementation { + 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) { + 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.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createDocument' on 'DOMImplementation': 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)); } - } - { - 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\\" }); + 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.\\" + ); } - ret[key] = value; + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args)); } - } - { - 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\\" }); + 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.\\"); + } - ret[key] = value; + return esValue[implSymbol].hasFeature(); } } + Object.defineProperties(DOMImplementation.prototype, { + createDocumentType: { enumerable: true }, + createDocument: { enumerable: true }, + createHTMLDocument: { enumerable: true }, + hasFeature: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DOMImplementation\\", configurable: true } + }); + ctorRegistry[interfaceName] = DOMImplementation; - { - 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\\" }); - - ret[key] = value; - } - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMImplementation + }); }; -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.\`); - } - - const ret = Object.create(null); - exports._convertInherit(obj, ret, { context }); - return ret; -}; +const Impl = require(\\"../implementations/DOMImplementation.js\\"); " `; -exports[`generation without processors DOMImplementation.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 = \\"DOMImplementation\\"; +const interfaceName = \\"DOMRect\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12295,7 +13304,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 'DOMRect'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12304,209 +13313,329 @@ function makeWrapper(globalObject, newTarget) { proto = newTarget.prototype; } - if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"].prototype; - } + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"DOMRect\\"].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\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DOMRect { + 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; - return Object.create(proto); -} + if (!exports.is(esValue)) { + throw new TypeError(\\"'get y' called on an object that is not a valid instance of DOMRect.\\"); + } -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; + return esValue[implSymbol][\\"y\\"]; + } -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; + set y(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -exports._internalSetup = (wrapper, globalObject) => {}; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set y' called on an object that is not a valid instance of DOMRect.\\"); + } -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" + }); - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + esValue[implSymbol][\\"y\\"] = V; + } - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper; -}; + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; -exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); + if (!exports.is(esValue)) { + throw new TypeError(\\"'get width' called on an object that is not a valid instance of DOMRect.\\"); + } - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true - }); + return esValue[implSymbol][\\"width\\"]; + } - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -const exposed = new Set([\\"Window\\"]); + if (!exports.is(esValue)) { + throw new TypeError(\\"'set width' called on an object that is not a valid instance of DOMRect.\\"); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'width' property on 'DOMRect': The provided value\\" + }); - const ctorRegistry = utils.initCtorRegistry(globalObject); - class DOMImplementation { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + esValue[implSymbol][\\"width\\"] = V; } - createDocumentType(qualifiedName, publicId, systemId) { + get height() { 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.\\" - ); + throw new TypeError(\\"'get height' called on an object that is not a valid instance of DOMRect.\\"); } - 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)); + return esValue[implSymbol][\\"height\\"]; } - createDocument(namespace, qualifiedName) { + set height(V) { 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.\\"); + throw new TypeError(\\"'set height' called on an object that is not a valid instance of DOMRect.\\"); } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } + 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]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'createDocument' on 'DOMImplementation': 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; - } + curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'fromRect' on 'DOMRect': parameter 1\\" }); args.push(curArg); } - return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args)); + 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; - 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\\" - }); + 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/DOMRect.js\\"); +" +`; + +exports[`generation without processors Dictionary.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const URL = require(\\"./URL.js\\"); +const URLSearchParams = require(\\"./URLSearchParams.js\\"); + +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\\" }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + 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\\" }); + + ret[key] = value; + } else { + throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); + } + } + + { + 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\\" }); + + V.push(nextItem); } - args.push(curArg); + value = V; } - return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args)); + + ret[key] = value; } + } - 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.\\"); - } + { + 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\\" }); - return esValue[implSymbol].hasFeature(); + ret[key] = value; } } - Object.defineProperties(DOMImplementation.prototype, { - createDocumentType: { enumerable: true }, - createDocument: { enumerable: true }, - createHTMLDocument: { enumerable: true }, - hasFeature: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DOMImplementation\\", configurable: true } - }); - ctorRegistry[interfaceName] = DOMImplementation; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: DOMImplementation - }); }; -const Impl = require(\\"../implementations/DOMImplementation.js\\"); +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.\`); + } + + const ret = Object.create(null); + exports._convertInherit(obj, ret, { context }); + return ret; +}; " `; -exports[`generation without processors DOMRect.webidl 1`] = ` +exports[`generation without processors DictionaryConvert.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -12516,7 +13645,7 @@ const Dictionary = require(\\"./Dictionary.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"DOMRect\\"; +const interfaceName = \\"DictionaryConvert\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12528,7 +13657,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 'DictionaryConvert'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12538,7 +13667,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"DOMRect\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"DictionaryConvert\\"].prototype; } return Object.create(proto); @@ -12588,7 +13717,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 +13725,405 @@ exports.install = (globalObject, globalNames) => { } const ctorRegistry = utils.initCtorRegistry(globalObject); - class DOMRect { + class DictionaryConvert { constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + 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 DictionaryConvert.\\"); + } const args = []; { let curArg = arguments[0]; if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 1\\" + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'op' on 'DictionaryConvert': 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; - } + curArg = Dictionary.convert(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); args.push(curArg); } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + return esValue[implSymbol].op(...args); } + } + Object.defineProperties(DictionaryConvert.prototype, { + op: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } + }); + ctorRegistry[interfaceName] = DictionaryConvert; - get x() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DictionaryConvert + }); +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get x' called on an object that is not a valid instance of DOMRect.\\"); - } +const Impl = require(\\"../implementations/DictionaryConvert.js\\"); +" +`; - return esValue[implSymbol][\\"x\\"]; - } +exports[`generation without processors Enum.webidl 1`] = ` +"\\"use strict\\"; - set x(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 x' called on an object that is not a valid instance of DOMRect.\\"); - } +const RequestDestination = require(\\"./RequestDestination.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'x' property on 'DOMRect': The provided value\\" - }); +const interfaceName = \\"Enum\\"; - esValue[implSymbol][\\"x\\"] = V; - } +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 'Enum'.\`); +}; - get y() { - const esValue = this !== null && this !== undefined ? this : globalObject; +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } - if (!exports.is(esValue)) { - throw new TypeError(\\"'get y' called on an object that is not a valid instance of DOMRect.\\"); - } + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"Enum\\"].prototype; + } - return esValue[implSymbol][\\"y\\"]; - } + return Object.create(proto); +} - set y(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set y' called on an object that is not a valid instance of DOMRect.\\"); - } +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" - }); +exports._internalSetup = (wrapper, globalObject) => {}; - esValue[implSymbol][\\"y\\"] = V; - } +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; - get width() { - const esValue = this !== null && this !== undefined ? this : globalObject; + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - if (!exports.is(esValue)) { - throw new TypeError(\\"'get width' called on an object that is not a valid instance of DOMRect.\\"); - } + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; - return esValue[implSymbol][\\"width\\"]; +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 Enum { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - set width(V) { + op(destination) { 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.\\"); + 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 'width' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"width\\"] = V; + 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 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'.\`); +}; - { - 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\\" }); +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } - ret[key] = value; - } else { - throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); - } + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"EventTarget\\"].prototype; } - { - 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\\" }); + return Object.create(proto); +} - V.push(nextItem); - } - value = V; - } +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; - ret[key] = value; - } +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 = \\"vanillaString\\"; - let value = obj === undefined || obj === null ? undefined : obj[key]; - if (value !== undefined) { - value = conversions[\\"DOMString\\"](value, { context: context + \\" has member 'vanillaString' that\\" }); +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); - ret[key] = value; - } + 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]; }; -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.\`); +const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); + +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); + } } + 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 +14135,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 +14145,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 +14161,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 +14289,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 +14297,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 +14358,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 +14368,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 +14426,72 @@ 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 - }); -}; - -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; + writable: true, + value: HTMLAudioElement + }); + + function Audio() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); } - event = utils.tryWrapperForImpl(event); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); + } + args.push(curArg); + } - let callResult = Reflect.apply(X, thisArg, [event]); + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); } - 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 +14503,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 +14513,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 +14563,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 +14571,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 +14601,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 +14613,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 +14623,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 +14639,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 +14673,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 +14681,70 @@ 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(); - } - - static get staticAttr() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLImageElement + }); - return Impl.implementation[\\"staticAttr\\"]; + function Image() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); } - 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; + 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); + } + + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); } - 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 +14753,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 +14765,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 +14775,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(proto)) { - proto = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"].prototype; + proto = globalObject[ctorRegistrySymbol][\\"HTMLOptionElement\\"].prototype; } return Object.create(proto); @@ -13644,30 +14827,92 @@ exports.new = (globalObject, newTarget) => { const exposed = new Set([\\"Window\\"]); -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + 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 thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); } - const ctorRegistry = utils.initCtorRegistry(globalObject); - class HTMLConstructor { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - } - 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\\"); " `; @@ -14733,6 +15978,142 @@ 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 thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, [], { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + 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\\"; @@ -14811,6 +16192,174 @@ exports.install = (globalObject, globalNames) => { " `; +exports[`generation without processors OverloadedLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"OverloadedLegacyFactoryFunctionInterface\\"; + +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 'OverloadedLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol][\\"OverloadedLegacyFactoryFunctionInterface\\"].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 OverloadedLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(OverloadedLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"OverloadedLegacyFactoryFunctionInterface\\", configurable: true } + }); + ctorRegistry[interfaceName] = OverloadedLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunctionInterface + }); + + function OverloadedLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const args = []; + switch (arguments.length) { + case 0: + break; + case 1: + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" + }); + args.push(curArg); + } + } + + const thisValue = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction(thisValue, globalObject, args, { + wrapper: utils.wrapperForImpl(thisValue), + newTarget: new.target + }); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisValue); + } + + Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: OverloadedLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/OverloadedLegacyFactoryFunctionInterface.js\\"); +" +`; + exports[`generation without processors Overloads.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/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 {}; diff --git a/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl b/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl new file mode 100644 index 00000000..8a9ac26a --- /dev/null +++ b/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl @@ -0,0 +1,4 @@ +[Exposed=Window, + LegacyFactoryFunction=OverloadedLegacyFactoryFunction(optional DOMString src), + LegacyFactoryFunction=OverloadedLegacyFactoryFunction(long arg1, long arg2)] +interface OverloadedLegacyFactoryFunctionInterface {};