diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index e28aa171..52aed154 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -73,8 +73,18 @@ class Interface { const global = utils.getExtAttr(this.idl.extAttrs, "Global"); this.isGlobal = Boolean(global); - if (global && !global.rhs) { - throw new Error(`[Global] must take an identifier or an identifier list in interface ${this.name}`); + if (global) { + if (!global.rhs || (global.rhs.type !== "identifier" && global.rhs.type !== "identifier-list")) { + throw new Error(`[Global] must take an identifier or an identifier list in interface ${this.name}`); + } + + if (global.rhs.type === "identifier") { + this.globalNames = new Set([global.rhs.value]); + } else { + this.globalNames = new Set(global.rhs.value.map(token => token.value)); + } + } else { + this.globalNames = null; } const exposed = utils.getExtAttr(this.idl.extAttrs, "Exposed"); @@ -1193,6 +1203,27 @@ class Interface { return obj; }; `; + + if (this.isGlobal) { + const bundleEntry = this.requires.addRelative("./webidl2js-globals.js"); + + this.str += ` + const globalNames = ${JSON.stringify([...this.globalNames])}; + + /** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ + exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + ${bundleEntry}.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); + }; + `; + } } addConstructor() { diff --git a/lib/context.js b/lib/context.js index e03a7eda..37cc21b5 100644 --- a/lib/context.js +++ b/lib/context.js @@ -1,5 +1,6 @@ "use strict"; const webidl = require("webidl2"); +const Globals = require("./globals.js"); const Typedef = require("./constructs/typedef"); const builtinTypedefs = webidl.parse(` @@ -38,6 +39,7 @@ class Context { this.callbackInterfaces = new Map(); this.dictionaries = new Map(); this.enumerations = new Map(); + this.globals = new Globals(this); for (const typedef of builtinTypedefs) { this.typedefs.set(typedef.name, new Typedef(this, typedef)); diff --git a/lib/globals.js b/lib/globals.js new file mode 100644 index 00000000..dfed8aa0 --- /dev/null +++ b/lib/globals.js @@ -0,0 +1,119 @@ +"use strict"; +const utils = require("./utils.js"); + +class Globals { + constructor(ctx) { + this.ctx = ctx; + this.requires = new utils.RequiresMap(ctx); + + this.str = null; + + this._analyzed = false; + this._constructs = null; + } + + _analyzeMembers() { + const { ctx } = this; + + const constructs = []; + + // This is needed to ensure that the interface order is deterministic + // regardless of filesystem case sensitivity: + const ifaceNames = [...ctx.interfaces.keys(), ...ctx.callbackInterfaces.keys()].sort(); + + function addExtendingInterfaces(parent) { + for (const ifaceName of ifaceNames) { + const iface = ctx.interfaces.get(ifaceName); + if (iface && iface.idl.inheritance === parent.name) { + constructs.push(iface); + addExtendingInterfaces(iface); + } + } + } + + for (const ifaceName of ifaceNames) { + const cb = ctx.callbackInterfaces.get(ifaceName); + if (cb) { + // Callback interface + if (cb.constants.size > 0) { + constructs.push(cb); + } + continue; + } + + const iface = ctx.interfaces.get(ifaceName); + if (!iface.idl.inheritance) { + constructs.push(iface); + addExtendingInterfaces(iface); + } + } + + this._constructs = constructs; + } + + generate() { + this.generateInterfaces(); + this.generateInstall(); + this.generateRequires(); + } + + generateInterfaces() { + this.str += ` + /** + * This object defines the mapping between the interface name and the generated interface wrapper code. + * + * Note: The mapping needs to stay as-is in order due to interface evaluation. + * We cannot "refactor" this to something less duplicative because that would break bundlers which depend + * on static analysis of require()s. + */ + exports.interfaces = { + `; + + for (const { name } of this._constructs) { + this.str += `${utils.stringifyPropertyKey(name)}: require("./${name}.js"),`; + } + + this.str += ` + }; + `; + } + + generateInstall() { + this.str += ` + /** + * Initializes the passed object as a new global. + * + * The object is expected to contain all the global object properties + * as specified in the ECMAScript specification. + * + * This function has to be added to the exports object + * to avoid circular dependency issues. + */ + exports.installInterfaces = (globalObject, globalNames) => { + for (const iface of Object.values(exports.interfaces)) { + iface.install(globalObject, globalNames); + } + }; + `; + } + + generateRequires() { + this.str = ` + ${this.requires.generate()} + + ${this.str} + `; + } + + toString() { + this.str = ""; + if (!this._analyzed) { + this._analyzed = true; + this._analyzeMembers(); + } + this.generate(); + return this.str; + } +} + +module.exports = Globals; diff --git a/lib/transformer.js b/lib/transformer.js index 02211d7a..ac8f6c20 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -252,6 +252,14 @@ class Transformer { `); await fs.writeFile(path.join(outputDir, obj.name + ".js"), source); } + + const source = this._prettify(` + "use strict"; + + const utils = require("${relativeUtils}"); + ${this.ctx.globals.toString()} + `); + await fs.writeFile(path.join(outputDir, "webidl2js-globals.js"), source); } _prettify(source) { diff --git a/lib/utils.js b/lib/utils.js index cde06397..b8667187 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -95,6 +95,10 @@ const defaultDefinePropertyDescriptor = { }; function toKey(type, func = "") { + if (extname(type) === ".js") { + type = type.slice(0, -3); + } + return String(func + type).replace(/[./-]+/g, " ").trim().replace(/ /g, "_"); } @@ -126,7 +130,7 @@ class RequiresMap extends Map { const key = toKey(type, func); const path = type.startsWith(".") ? type : `./${type}`; - let req = `require("${path}.js")`; + let req = `require("${!extname(path) ? `${path}.js` : path}")`; if (func) { req += `.${func}`; diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 87638119..bdf0e345 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -1,5 +1,76 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`webidl2js-globals.js 1`] = ` +"\\"use strict\\"; + +const utils = require(\\"./utils.js\\"); + +/** + * This object defines the mapping between the interface name and the generated interface wrapper code. + * + * Note: The mapping needs to stay as-is in order due to interface evaluation. + * We cannot \\"refactor\\" this to something less duplicative because that would break bundlers which depend + * on static analysis of require()s. + */ +exports.interfaces = { + BufferSourceTypes: require(\\"./BufferSourceTypes.js\\"), + CEReactions: require(\\"./CEReactions.js\\"), + DOMImplementation: require(\\"./DOMImplementation.js\\"), + DOMRect: require(\\"./DOMRect.js\\"), + DictionaryConvert: require(\\"./DictionaryConvert.js\\"), + Enum: require(\\"./Enum.js\\"), + EventTarget: require(\\"./EventTarget.js\\"), + Node: require(\\"./Node.js\\"), + Element: require(\\"./Element.js\\"), + HTMLElement: require(\\"./HTMLElement.js\\"), + Window: require(\\"./Window.js\\"), + Global: require(\\"./Global.js\\"), + HTMLConstructor: require(\\"./HTMLConstructor.js\\"), + LegacyArrayClass: require(\\"./LegacyArrayClass.js\\"), + MixedIn: require(\\"./MixedIn.js\\"), + MultiGlobal: require(\\"./MultiGlobal.js\\"), + NodeFilter: require(\\"./NodeFilter.js\\"), + Overloads: require(\\"./Overloads.js\\"), + PromiseTypes: require(\\"./PromiseTypes.js\\"), + Reflect: require(\\"./Reflect.js\\"), + SeqAndRec: require(\\"./SeqAndRec.js\\"), + Static: require(\\"./Static.js\\"), + Storage: require(\\"./Storage.js\\"), + StringifierAttribute: require(\\"./StringifierAttribute.js\\"), + StringifierDefaultOperation: require(\\"./StringifierDefaultOperation.js\\"), + StringifierNamedOperation: require(\\"./StringifierNamedOperation.js\\"), + StringifierOperation: require(\\"./StringifierOperation.js\\"), + TypedefsAndUnions: require(\\"./TypedefsAndUnions.js\\"), + URL: require(\\"./URL.js\\"), + URLList: require(\\"./URLList.js\\"), + URLSearchParams: require(\\"./URLSearchParams.js\\"), + URLSearchParamsCollection: require(\\"./URLSearchParamsCollection.js\\"), + URLSearchParamsCollection2: require(\\"./URLSearchParamsCollection2.js\\"), + UnderscoredProperties: require(\\"./UnderscoredProperties.js\\"), + Unforgeable: require(\\"./Unforgeable.js\\"), + UnforgeableMap: require(\\"./UnforgeableMap.js\\"), + Unscopable: require(\\"./Unscopable.js\\"), + Variadic: require(\\"./Variadic.js\\"), + ZeroArgConstructor: require(\\"./ZeroArgConstructor.js\\") +}; + +/** + * Initializes the passed object as a new global. + * + * The object is expected to contain all the global object properties + * as specified in the ECMAScript specification. + * + * This function has to be added to the exports object + * to avoid circular dependency issues. + */ +exports.installInterfaces = (globalObject, globalNames) => { + for (const iface of Object.values(exports.interfaces)) { + iface.install(globalObject, globalNames); + } +}; +" +`; + exports[`with processors AsyncCallbackInterface.webidl 1`] = ` "\\"use strict\\"; @@ -1307,6 +1378,274 @@ const Impl = require(\\"../implementations/DictionaryConvert.js\\"); " `; +exports[`with processors Element.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const CEReactions = require(\\"../CEReactions.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Node = require(\\"./Node.js\\"); + +const interfaceName = \\"Element\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Element'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Element\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Element is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Node._internalSetup(obj, globalObject); +}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + if (globalObject.Node === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Element before Node\\"); + } + class Element extends globalObject.Node { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + get namespaceURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"namespaceURI\\"]; + } + + get prefix() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"prefix\\"]; + } + + get localName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"localName\\"]; + } + + get tagName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"tagName\\"]; + } + + get id() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"id\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set id(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'id' property on 'Element': The provided value\\" }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"id\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + + get className() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"className\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set className(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'className' property on 'Element': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"className\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + + get classList() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.getSameObject(this, \\"classList\\", () => { + return utils.tryWrapperForImpl(esValue[implSymbol][\\"classList\\"]); + }); + } + + set classList(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + this.classList.value = V; + } + + get slot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"slot\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set slot(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'slot' property on 'Element': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"slot\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + } + Object.defineProperties(Element.prototype, { + namespaceURI: { enumerable: true }, + prefix: { enumerable: true }, + localName: { enumerable: true }, + tagName: { enumerable: true }, + id: { enumerable: true }, + className: { enumerable: true }, + classList: { enumerable: true }, + slot: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Element\\", configurable: true }, + [Symbol.unscopables]: { value: { slot: true, __proto__: null }, configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Element; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Element + }); +}; + +const Impl = require(\\"../implementations/Element.js\\"); +" +`; + exports[`with processors Enum.webidl 1`] = ` "\\"use strict\\"; @@ -1615,6 +1954,7 @@ exports[`with processors Global.webidl 1`] = ` const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const webidl2js_globals = require(\\"./webidl2js-globals.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; @@ -1767,6 +2107,21 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; +const globalNames = [\\"Global\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + const exposed = new Set([\\"Global\\"]); exports.install = (globalObject, globalNames) => { @@ -1902,16 +2257,19 @@ const Impl = require(\\"../implementations/HTMLConstructor.js\\"); " `; -exports[`with processors LegacyArrayClass.webidl 1`] = ` +exports[`with processors HTMLElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const HTMLConstructor_HTMLConstructor = require(\\"../HTMLConstructor.js\\").HTMLConstructor; +const CEReactions = require(\\"../CEReactions.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Element = require(\\"./Element.js\\"); -const interfaceName = \\"LegacyArrayClass\\"; +const interfaceName = \\"HTMLElement\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -1923,7 +2281,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'LegacyArrayClass'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLElement'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -1931,9 +2289,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyArrayClass\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"HTMLElement\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyArrayClass is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor HTMLElement is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -1944,7 +2302,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Element._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -1967,25 +2327,258 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyArrayClass { + + if (globalObject.Element === undefined) { + throw new Error(\\"Internal error: attempting to evaluate HTMLElement before Element\\"); + } + class HTMLElement extends globalObject.Element { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); } - get length() { + get title() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"length\\"]; + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"title\\"]; + } finally { + CEReactions.postSteps(globalObject); + } } - } - Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); - Object.defineProperties(LegacyArrayClass.prototype, { - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"LegacyArrayClass\\", configurable: true } + + set title(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'title' property on 'HTMLElement': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"title\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + + get lang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"lang\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set lang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'lang' property on 'HTMLElement': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"lang\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + + get translate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"translate\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set translate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'translate' property on 'HTMLElement': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"translate\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + + get dir() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + CEReactions.preSteps(globalObject); + try { + return esValue[implSymbol][\\"dir\\"]; + } finally { + CEReactions.postSteps(globalObject); + } + } + + set dir(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'dir' property on 'HTMLElement': The provided value\\" + }); + + CEReactions.preSteps(globalObject); + try { + esValue[implSymbol][\\"dir\\"] = V; + } finally { + CEReactions.postSteps(globalObject); + } + } + } + Object.defineProperties(HTMLElement.prototype, { + title: { enumerable: true }, + lang: { enumerable: true }, + translate: { enumerable: true }, + dir: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"HTMLElement\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = HTMLElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLElement + }); +}; + +const Impl = require(\\"../implementations/HTMLElement.js\\"); +" +`; + +exports[`with processors LegacyArrayClass.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"LegacyArrayClass\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'LegacyArrayClass'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyArrayClass\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor LegacyArrayClass is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class LegacyArrayClass { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"length\\"]; + } + } + Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); + Object.defineProperties(LegacyArrayClass.prototype, { + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyArrayClass\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); @@ -2168,95 +2761,139 @@ const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`with processors NodeFilter.webidl 1`] = ` +exports[`with processors MultiGlobal.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]); +const webidl2js_globals = require(\\"./webidl2js-globals.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); +const interfaceName = \\"MultiGlobal\\"; - return callResult; +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); } - - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; - - return callTheUserObjectsOperation; + throw new TypeError(\`\${context} is not of type 'MultiGlobal'.\`); }; -const exposed = new Set([\\"Window\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); } - const NodeFilter = () => { - throw new TypeError(\\"Illegal invocation\\"); - }; + const ctor = globalObject[ctorRegistrySymbol][\\"MultiGlobal\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor MultiGlobal is not installed on the passed global object\\"); + } - 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 } + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + get self() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"self\\"]); + } + }) + ); + + Object.defineProperties(obj, { self: { configurable: false } }); +}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true }); - Object.defineProperty(globalObject, \\"NodeFilter\\", { + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const globalNames = [\\"Global1\\", \\"Global2\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + +const exposed = new Set([\\"Global1\\", \\"Global2\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class MultiGlobal { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(MultiGlobal.prototype, { + [Symbol.toStringTag]: { value: \\"MultiGlobal\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = MultiGlobal; + + Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: NodeFilter + value: MultiGlobal }); }; + +const Impl = require(\\"../implementations/MultiGlobal.js\\"); " `; -exports[`with processors Overloads.webidl 1`] = ` +exports[`with processors Node.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 EventTarget = require(\\"./EventTarget.js\\"); -const interfaceName = \\"Overloads\\"; +const interfaceName = \\"Node\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -2268,7 +2905,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Overloads'.\`); + throw new TypeError(\`\${context} is not of type 'Node'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -2276,9 +2913,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Node\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Node is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -2289,7 +2926,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + EventTarget._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -2312,498 +2951,310 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Overloads { + + if (globalObject.EventTarget === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Node before EventTarget\\"); + } + class Node extends globalObject.EventTarget { constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + getRootNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (URL.is(curArg)) { - { - let curArg = arguments[0]; - curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } - } + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = utils.tryImplForWrapper(curArg); } + args.push(curArg); } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + return utils.tryWrapperForImpl(esValue[implSymbol].getRootNode(...args)); } - compatible(arg1) { + hasChildNodes() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - break; - case 2: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - } - return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); + return esValue[implSymbol].hasChildNodes(); } - incompatible1(arg1) { + get nodeType() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - } - } - return esValue[implSymbol].incompatible1(...args); + return esValue[implSymbol][\\"nodeType\\"]; } - incompatible2(arg1) { + get nodeName() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - } - return esValue[implSymbol].incompatible2(...args); + return esValue[implSymbol][\\"nodeName\\"]; } - incompatible3(arg1) { + get baseURI() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"baseURI\\"]; + } + + get isConnected() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - break; - case 2: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg === undefined) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = URL.convert(curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - } - args.push(curArg); - } - } else if (URL.is(curArg)) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = URL.convert(curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - } - args.push(curArg); - } - } else if (utils.isArrayBuffer(curArg)) { - { - let curArg = arguments[1]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - } else if (ArrayBuffer.isView(curArg)) { - { - let curArg = arguments[1]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - } else { - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - } - } - break; - case 3: - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" - ); - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - { - let curArg = arguments[2]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - { - let curArg = arguments[3]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } + + return esValue[implSymbol][\\"isConnected\\"]; + } + + get ownerDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].incompatible3(...args); + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"ownerDocument\\"]); + } + + get parentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parentNode\\"]); + } + + get parentElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parentElement\\"]); + } + + get childNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.getSameObject(this, \\"childNodes\\", () => { + return utils.tryWrapperForImpl(esValue[implSymbol][\\"childNodes\\"]); + }); + } + + get firstChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"firstChild\\"]); + } + + get lastChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"lastChild\\"]); + } + + get previousSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"previousSibling\\"]); + } + + get nextSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"nextSibling\\"]); } } - Object.defineProperties(Overloads.prototype, { - compatible: { enumerable: true }, - incompatible1: { enumerable: true }, - incompatible2: { enumerable: true }, - incompatible3: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Overloads\\", configurable: true } + Object.defineProperties(Node.prototype, { + getRootNode: { enumerable: true }, + hasChildNodes: { enumerable: true }, + nodeType: { enumerable: true }, + nodeName: { enumerable: true }, + baseURI: { enumerable: true }, + isConnected: { enumerable: true }, + ownerDocument: { enumerable: true }, + parentNode: { enumerable: true }, + parentElement: { enumerable: true }, + childNodes: { enumerable: true }, + firstChild: { enumerable: true }, + lastChild: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Node\\", configurable: true }, + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true } + }); + Object.defineProperties(Node, { + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Overloads; + globalObject[ctorRegistrySymbol][interfaceName] = Node; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Overloads + value: Node }); }; -const Impl = require(\\"../implementations/Overloads.js\\"); +const Impl = require(\\"../implementations/Node.js\\"); " `; -exports[`with processors PromiseTypes.webidl 1`] = ` +exports[`with processors NodeFilter.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + if (!utils.isObject(value)) { + throw new TypeError(\`\${context} is not an object.\`); + } -const interfaceName = \\"PromiseTypes\\"; + function callTheUserObjectsOperation(node) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); + 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; } - throw new TypeError(\`\${context} is not of type 'PromiseTypes'.\`); + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; }; -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } +const exposed = new Set([\\"Window\\"]); - const ctor = globalObject[ctorRegistrySymbol][\\"PromiseTypes\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor PromiseTypes is not installed on the passed global object\\"); +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; } - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; - - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; - -const exposed = new Set([\\"Window\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class PromiseTypes { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - voidPromiseConsumer(p) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = Promise.resolve(curArg).then( - value => {}, - reason => reason - ); - args.push(curArg); - } - return esValue[implSymbol].voidPromiseConsumer(...args); - } - - promiseConsumer(p) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = Promise.resolve(curArg).then( - value => { - value = conversions[\\"double\\"](value, { - context: \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': parameter 1\\" + \\" promise value\\" - }); + const NodeFilter = () => { + throw new TypeError(\\"Illegal invocation\\"); + }; - return value; - }, - reason => reason - ); - args.push(curArg); - } - return esValue[implSymbol].promiseConsumer(...args); - } - } - Object.defineProperties(PromiseTypes.prototype, { - voidPromiseConsumer: { enumerable: true }, - promiseConsumer: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"PromiseTypes\\", configurable: true } + 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 } }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = PromiseTypes; - Object.defineProperty(globalObject, interfaceName, { + Object.defineProperty(globalObject, \\"NodeFilter\\", { configurable: true, writable: true, - value: PromiseTypes + value: NodeFilter }); }; - -const Impl = require(\\"../implementations/PromiseTypes.js\\"); " `; -exports[`with processors Reflect.webidl 1`] = ` +exports[`with processors Overloads.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const whatwg_url = require(\\"whatwg-url\\"); +const URL = require(\\"./URL.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Reflect\\"; +const interfaceName = \\"Overloads\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -2815,7 +3266,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Reflect'.\`); + throw new TypeError(\`\${context} is not of type 'Overloads'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -2823,9 +3274,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Reflect\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Reflect is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -2859,263 +3310,1610 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Reflect { + class Overloads { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - get reflectedBoolean() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (URL.is(curArg)) { + { + let curArg = arguments[0]; + curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } + } } - - return esValue[implSymbol].hasAttributeNS(null, \\"reflectedboolean\\"); + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - set reflectedBoolean(V) { + compatible(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'reflectedBoolean' property on 'Reflect': The provided value\\" - }); - - if (V) { - esValue[implSymbol].setAttributeNS(null, \\"reflectedboolean\\", \\"\\"); - } else { - esValue[implSymbol].removeAttributeNS(null, \\"reflectedboolean\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - } - - get reflectedDOMString() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" + }); + } else { + curArg = 0; + } + args.push(curArg); + } } - - const value = esValue[implSymbol].getAttributeNS(null, \\"reflecteddomstring\\"); - return value === null ? \\"\\" : value; + return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); } - set reflectedDOMString(V) { + incompatible1(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'reflectedDOMString' property on 'Reflect': The provided value\\" - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } + } + return esValue[implSymbol].incompatible1(...args); + } + + incompatible2(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + } + return esValue[implSymbol].incompatible2(...args); + } + + incompatible3(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === undefined) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = URL.convert(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); + } + } else if (URL.is(curArg)) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = URL.convert(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); + } + } else if (utils.isArrayBuffer(curArg)) { + { + let curArg = arguments[1]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[1]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } else { + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + } + } + break; + case 3: + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" + ); + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } + return esValue[implSymbol].incompatible3(...args); + } + } + Object.defineProperties(Overloads.prototype, { + compatible: { enumerable: true }, + incompatible1: { enumerable: true }, + incompatible2: { enumerable: true }, + incompatible3: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Overloads\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Overloads; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Overloads + }); +}; + +const Impl = require(\\"../implementations/Overloads.js\\"); +" +`; + +exports[`with processors PromiseTypes.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"PromiseTypes\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'PromiseTypes'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"PromiseTypes\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor PromiseTypes is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class PromiseTypes { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + voidPromiseConsumer(p) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Promise.resolve(curArg).then( + value => {}, + reason => reason + ); + args.push(curArg); + } + return esValue[implSymbol].voidPromiseConsumer(...args); + } + + promiseConsumer(p) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Promise.resolve(curArg).then( + value => { + value = conversions[\\"double\\"](value, { + context: \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': parameter 1\\" + \\" promise value\\" + }); + + return value; + }, + reason => reason + ); + args.push(curArg); + } + return esValue[implSymbol].promiseConsumer(...args); + } + } + Object.defineProperties(PromiseTypes.prototype, { + voidPromiseConsumer: { enumerable: true }, + promiseConsumer: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"PromiseTypes\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = PromiseTypes; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PromiseTypes + }); +}; + +const Impl = require(\\"../implementations/PromiseTypes.js\\"); +" +`; + +exports[`with processors Reflect.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const whatwg_url = require(\\"whatwg-url\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Reflect\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Reflect'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Reflect\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Reflect is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Reflect { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + get reflectedBoolean() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].hasAttributeNS(null, \\"reflectedboolean\\"); + } + + set reflectedBoolean(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'reflectedBoolean' property on 'Reflect': The provided value\\" + }); + + if (V) { + esValue[implSymbol].setAttributeNS(null, \\"reflectedboolean\\", \\"\\"); + } else { + esValue[implSymbol].removeAttributeNS(null, \\"reflectedboolean\\"); + } + } + + get reflectedDOMString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = esValue[implSymbol].getAttributeNS(null, \\"reflecteddomstring\\"); + return value === null ? \\"\\" : value; + } + + set reflectedDOMString(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'reflectedDOMString' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflecteddomstring\\", V); + } + + get reflectedLong() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedlong\\")); + return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value; + } + + set reflectedLong(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"long\\"](V, { + context: \\"Failed to set the 'reflectedLong' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflectedlong\\", String(V)); + } + + get reflectedUnsignedLong() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedunsignedlong\\")); + return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value; + } + + set reflectedUnsignedLong(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"unsigned long\\"](V, { + context: \\"Failed to set the 'reflectedUnsignedLong' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflectedunsignedlong\\", String(V > 2147483647 ? 0 : V)); + } + + get reflectedUSVStringURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = esValue[implSymbol].getAttributeNS(null, \\"reflectedusvstringurl\\"); + if (value === null) { + return \\"\\"; + } + const urlRecord = whatwg_url.parseURL(value, { baseURL: \\"http://localhost:8080/\\" }); + return urlRecord === null ? conversions.USVString(value) : whatwg_url.serializeURL(urlRecord); + } + + set reflectedUSVStringURL(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'reflectedUSVStringURL' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflectedusvstringurl\\", V); + } + + get reflectionTest() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = esValue[implSymbol].getAttributeNS(null, \\"reflection\\"); + return value === null ? \\"\\" : value; + } + + set reflectionTest(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'reflectionTest' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"reflection\\", V); + } + + get withUnderscore() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + const value = esValue[implSymbol].getAttributeNS(null, \\"with-underscore\\"); + return value === null ? \\"\\" : value; + } + + set withUnderscore(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'withUnderscore' property on 'Reflect': The provided value\\" + }); + + esValue[implSymbol].setAttributeNS(null, \\"with-underscore\\", V); + } + } + Object.defineProperties(Reflect.prototype, { + reflectedBoolean: { enumerable: true }, + reflectedDOMString: { enumerable: true }, + reflectedLong: { enumerable: true }, + reflectedUnsignedLong: { enumerable: true }, + reflectedUSVStringURL: { enumerable: true }, + reflectionTest: { enumerable: true }, + withUnderscore: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Reflect\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Reflect; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Reflect + }); +}; + +const Impl = require(\\"../implementations/Reflect.js\\"); +" +`; + +exports[`with processors RequestDestination.webidl 1`] = ` +"\\"use strict\\"; + +const enumerationValues = new Set([ + \\"\\", + \\"audio\\", + \\"document\\", + \\"embed\\", + \\"font\\", + \\"image\\", + \\"manifest\\", + \\"object\\", + \\"report\\", + \\"script\\", + \\"sharedworker\\", + \\"style\\", + \\"track\\", + \\"video\\", + \\"worker\\", + \\"xslt\\" +]); +exports.enumerationValues = enumerationValues; + +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + const string = \`\${value}\`; + if (!enumerationValues.has(value)) { + throw new TypeError(\`\${context} '\${value}' is not a valid enumeration value for RequestDestination\`); + } + return string; +}; +" +`; + +exports[`with processors SeqAndRec.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 = \\"SeqAndRec\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'SeqAndRec'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"SeqAndRec\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor SeqAndRec is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class SeqAndRec { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + recordConsumer(rec) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'recordConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError(\\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); + + let typedValue = curArg[key]; + + typedValue = conversions[\\"double\\"](typedValue, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); + + result[typedKey] = typedValue; + } + } + curArg = result; + } + args.push(curArg); + } + return esValue[implSymbol].recordConsumer(...args); + } + + recordConsumer2(rec) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError(\\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); + + let typedValue = curArg[key]; + + typedValue = URL.convert(typedValue, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); + + result[typedKey] = typedValue; + } + } + curArg = result; + } + args.push(curArg); + } + return esValue[implSymbol].recordConsumer2(...args); + } + + sequenceConsumer(seq) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"USVString\\"](nextItem, { + context: \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" + }); + + V.push(nextItem); + } + curArg = V; + } + args.push(curArg); + } + return esValue[implSymbol].sequenceConsumer(...args); + } + + sequenceConsumer2(seq) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + curArg = V; + } + args.push(curArg); + } + return esValue[implSymbol].sequenceConsumer2(...args); + } + + frozenArrayConsumer(arr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"double\\"](nextItem, { + context: \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" + }); + + V.push(nextItem); + } + curArg = V; + } + curArg = Object.freeze(curArg); + args.push(curArg); + } + return esValue[implSymbol].frozenArrayConsumer(...args); + } + } + Object.defineProperties(SeqAndRec.prototype, { + recordConsumer: { enumerable: true }, + recordConsumer2: { enumerable: true }, + sequenceConsumer: { enumerable: true }, + sequenceConsumer2: { enumerable: true }, + frozenArrayConsumer: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"SeqAndRec\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = SeqAndRec; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SeqAndRec + }); +}; + +const Impl = require(\\"../implementations/SeqAndRec.js\\"); +" +`; + +exports[`with processors Static.webidl 1`] = ` +"\\"use strict\\"; - esValue[implSymbol].setAttributeNS(null, \\"reflecteddomstring\\", V); +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Static\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Static'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Static\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Static is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Static { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - get reflectedLong() { + def() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedlong\\")); - return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value; + return esValue[implSymbol].def(); } - set reflectedLong(V) { + get abc() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"long\\"](V, { - context: \\"Failed to set the 'reflectedLong' property on 'Reflect': The provided value\\" - }); - - esValue[implSymbol].setAttributeNS(null, \\"reflectedlong\\", String(V)); + return esValue[implSymbol][\\"abc\\"]; } - get reflectedUnsignedLong() { + set abc(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - const value = parseInt(esValue[implSymbol].getAttributeNS(null, \\"reflectedunsignedlong\\")); - return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value; + V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'abc' property on 'Static': The provided value\\" }); + + esValue[implSymbol][\\"abc\\"] = V; } - set reflectedUnsignedLong(V) { + static def() { + return Impl.implementation.def(); + } + + static get abc() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + return Impl.implementation[\\"abc\\"]; + } - V = conversions[\\"unsigned long\\"](V, { - context: \\"Failed to set the 'reflectedUnsignedLong' property on 'Reflect': The provided value\\" - }); + static set abc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - esValue[implSymbol].setAttributeNS(null, \\"reflectedunsignedlong\\", String(V > 2147483647 ? 0 : V)); + return Impl.implementation[\\"abc\\"]; } + } + Object.defineProperties(Static.prototype, { + def: { enumerable: true }, + abc: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Static\\", configurable: true } + }); + Object.defineProperties(Static, { def: { enumerable: true }, abc: { enumerable: true } }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Static; - get reflectedUSVStringURL() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Static + }); +}; + +const Impl = require(\\"../implementations/Static.js\\"); +" +`; +exports[`with processors Storage.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Storage\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Storage'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Storage\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Storage is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj = new Proxy(obj, proxyHandler); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Storage { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + key(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - const value = esValue[implSymbol].getAttributeNS(null, \\"reflectedusvstringurl\\"); - if (value === null) { - return \\"\\"; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'key' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); } - const urlRecord = whatwg_url.parseURL(value, { baseURL: \\"http://localhost:8080/\\" }); - return urlRecord === null ? conversions.USVString(value) : whatwg_url.serializeURL(urlRecord); + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'key' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + return esValue[implSymbol].key(...args); } - set reflectedUSVStringURL(V) { + getItem(key) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'reflectedUSVStringURL' property on 'Reflect': The provided value\\" - }); - - esValue[implSymbol].setAttributeNS(null, \\"reflectedusvstringurl\\", V); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'getItem' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + return esValue[implSymbol].getItem(...args); } - get reflectionTest() { + setItem(key, value) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - - const value = esValue[implSymbol].getAttributeNS(null, \\"reflection\\"); - return value === null ? \\"\\" : value; + + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'setItem' on 'Storage': 2 arguments required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 2\\" }); + args.push(curArg); + } + return esValue[implSymbol].setItem(...args); } - set reflectionTest(V) { + removeItem(key) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'reflectionTest' property on 'Reflect': The provided value\\" - }); - - esValue[implSymbol].setAttributeNS(null, \\"reflection\\", V); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'removeItem' on 'Storage': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].removeItem(...args); } - get withUnderscore() { + clear() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - const value = esValue[implSymbol].getAttributeNS(null, \\"with-underscore\\"); - return value === null ? \\"\\" : value; + return esValue[implSymbol].clear(); } - set withUnderscore(V) { + get length() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'withUnderscore' property on 'Reflect': The provided value\\" - }); - - esValue[implSymbol].setAttributeNS(null, \\"with-underscore\\", V); + return esValue[implSymbol][\\"length\\"]; } } - Object.defineProperties(Reflect.prototype, { - reflectedBoolean: { enumerable: true }, - reflectedDOMString: { enumerable: true }, - reflectedLong: { enumerable: true }, - reflectedUnsignedLong: { enumerable: true }, - reflectedUSVStringURL: { enumerable: true }, - reflectionTest: { enumerable: true }, - withUnderscore: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Reflect\\", configurable: true } + Object.defineProperties(Storage.prototype, { + key: { enumerable: true }, + getItem: { enumerable: true }, + setItem: { enumerable: true }, + removeItem: { enumerable: true }, + clear: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Storage\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Reflect; + globalObject[ctorRegistrySymbol][interfaceName] = Storage; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Reflect + value: Storage }); }; -const Impl = require(\\"../implementations/Reflect.js\\"); -" -`; +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, []); + }, -exports[`with processors RequestDestination.webidl 1`] = ` -"\\"use strict\\"; + has(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + }, -const enumerationValues = new Set([ - \\"\\", - \\"audio\\", - \\"document\\", - \\"embed\\", - \\"font\\", - \\"image\\", - \\"manifest\\", - \\"object\\", - \\"report\\", - \\"script\\", - \\"sharedworker\\", - \\"style\\", - \\"track\\", - \\"video\\", - \\"worker\\", - \\"xslt\\" -]); -exports.enumerationValues = enumerationValues; + ownKeys(target) { + const keys = new Set(); -exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { - const string = \`\${value}\`; - if (!enumerationValues.has(value)) { - throw new TypeError(\`\${context} '\${value}' is not a valid enumeration value for RequestDestination\`); + 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].getItem(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); + } + if (target === receiver) { + if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + let namedValue = V; + + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'Storage': The provided value\\" + }); + + target[implSymbol].setItem(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 (!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 'Storage': The provided value\\" + }); + + target[implSymbol].setItem(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)) { + target[implSymbol].removeItem(P); + return true; + } + + return Reflect.deleteProperty(target, P); + }, + + preventExtensions() { + return false; } - return string; }; + +const Impl = require(\\"../implementations/Storage.js\\"); " `; -exports[`with processors SeqAndRec.webidl 1`] = ` +exports[`with processors StringifierAttribute.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 = \\"SeqAndRec\\"; +const interfaceName = \\"StringifierAttribute\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -3127,7 +4925,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'SeqAndRec'.\`); + throw new TypeError(\`\${context} is not of type 'StringifierAttribute'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -3135,9 +4933,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"SeqAndRec\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"StringifierAttribute\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor SeqAndRec is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor StringifierAttribute is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -3171,236 +4969,153 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class SeqAndRec { + class StringifierAttribute { constructor() { - return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + throw new TypeError(\\"Illegal constructor\\"); } - recordConsumer(rec) { + get attr() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'recordConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError(\\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); - - let typedValue = curArg[key]; - - typedValue = conversions[\\"double\\"](typedValue, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); - - result[typedKey] = typedValue; - } - } - curArg = result; - } - args.push(curArg); - } - return esValue[implSymbol].recordConsumer(...args); + return esValue[implSymbol][\\"attr\\"]; } - recordConsumer2(rec) { - const esValue = this !== null && this !== undefined ? this : globalObject; + toString() { + const esValue = this; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError(\\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; + return esValue[implSymbol][\\"attr\\"]; + } + } + Object.defineProperties(StringifierAttribute.prototype, { + attr: { enumerable: true }, + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierAttribute\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = StringifierAttribute; - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StringifierAttribute + }); +}; - let typedValue = curArg[key]; +const Impl = require(\\"../implementations/StringifierAttribute.js\\"); +" +`; - typedValue = URL.convert(typedValue, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); +exports[`with processors StringifierDefaultOperation.webidl 1`] = ` +"\\"use strict\\"; - result[typedKey] = typedValue; - } - } - curArg = result; - } - args.push(curArg); - } - return esValue[implSymbol].recordConsumer2(...args); - } +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - sequenceConsumer(seq) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"USVString\\"](nextItem, { - context: \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" - }); +const interfaceName = \\"StringifierDefaultOperation\\"; - V.push(nextItem); - } - curArg = V; - } - args.push(curArg); - } - return esValue[implSymbol].sequenceConsumer(...args); - } +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'StringifierDefaultOperation'.\`); +}; - sequenceConsumer2(seq) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = utils.tryImplForWrapper(nextItem); + const ctor = globalObject[ctorRegistrySymbol][\\"StringifierDefaultOperation\\"]; + if (ctor === undefined) { + throw new Error( + \\"Internal error: constructor StringifierDefaultOperation is not installed on the passed global object\\" + ); + } - V.push(nextItem); - } - curArg = V; - } - args.push(curArg); - } - return esValue[implSymbol].sequenceConsumer2(...args); - } + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; - frozenArrayConsumer(arr) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"double\\"](nextItem, { - context: \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" - }); + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); - V.push(nextItem); - } - curArg = V; - } - curArg = Object.freeze(curArg); - args.push(curArg); +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class StringifierDefaultOperation { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].frozenArrayConsumer(...args); + + return esValue[implSymbol].toString(); } } - Object.defineProperties(SeqAndRec.prototype, { - recordConsumer: { enumerable: true }, - recordConsumer2: { enumerable: true }, - sequenceConsumer: { enumerable: true }, - sequenceConsumer2: { enumerable: true }, - frozenArrayConsumer: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"SeqAndRec\\", configurable: true } + Object.defineProperties(StringifierDefaultOperation.prototype, { + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierDefaultOperation\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = SeqAndRec; + globalObject[ctorRegistrySymbol][interfaceName] = StringifierDefaultOperation; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: SeqAndRec + value: StringifierDefaultOperation }); }; -const Impl = require(\\"../implementations/SeqAndRec.js\\"); +const Impl = require(\\"../implementations/StringifierDefaultOperation.js\\"); " `; -exports[`with processors Static.webidl 1`] = ` +exports[`with processors StringifierNamedOperation.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -3409,7 +5124,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Static\\"; +const interfaceName = \\"StringifierNamedOperation\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -3421,7 +5136,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Static'.\`); + throw new TypeError(\`\${context} is not of type 'StringifierNamedOperation'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -3429,9 +5144,11 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Static\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"StringifierNamedOperation\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Static is not installed on the passed global object\\"); + throw new Error( + \\"Internal error: constructor StringifierNamedOperation is not installed on the passed global object\\" + ); } let obj = Object.create(ctor.prototype); @@ -3465,90 +5182,161 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Static { + class StringifierNamedOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - def() { + operation() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].def(); + return esValue[implSymbol].operation(); } - get abc() { + toString() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"abc\\"]; + return esValue[implSymbol].operation(); } + } + Object.defineProperties(StringifierNamedOperation.prototype, { + operation: { enumerable: true }, + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierNamedOperation\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = StringifierNamedOperation; - set abc(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StringifierNamedOperation + }); +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const Impl = require(\\"../implementations/StringifierNamedOperation.js\\"); +" +`; - V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'abc' property on 'Static': The provided value\\" }); +exports[`with processors StringifierOperation.webidl 1`] = ` +"\\"use strict\\"; - esValue[implSymbol][\\"abc\\"] = V; - } +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - static def() { - return Impl.implementation.def(); - } +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - static get abc() { - const esValue = this !== null && this !== undefined ? this : globalObject; +const interfaceName = \\"StringifierOperation\\"; - return Impl.implementation[\\"abc\\"]; +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'StringifierOperation'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"StringifierOperation\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor StringifierOperation is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class StringifierOperation { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - static set abc(V) { + toString() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return Impl.implementation[\\"abc\\"]; + return esValue[implSymbol].toString(); } } - Object.defineProperties(Static.prototype, { - def: { enumerable: true }, - abc: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Static\\", configurable: true } + Object.defineProperties(StringifierOperation.prototype, { + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierOperation\\", configurable: true } }); - Object.defineProperties(Static, { def: { enumerable: true }, abc: { enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Static; + globalObject[ctorRegistrySymbol][interfaceName] = StringifierOperation; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Static + value: StringifierOperation }); }; -const Impl = require(\\"../implementations/Static.js\\"); +const Impl = require(\\"../implementations/StringifierOperation.js\\"); " `; -exports[`with processors Storage.webidl 1`] = ` +exports[`with processors TypedefsAndUnions.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const RequestDestination = require(\\"./RequestDestination.js\\"); +const URL = require(\\"./URL.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Storage\\"; +const interfaceName = \\"TypedefsAndUnions\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -3560,7 +5348,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Storage'.\`); + throw new TypeError(\`\${context} is not of type 'TypedefsAndUnions'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -3568,9 +5356,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Storage\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"TypedefsAndUnions\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Storage is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor TypedefsAndUnions is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -3591,8 +5379,6 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD configurable: true }); - obj = new Proxy(obj, proxyHandler); - obj[implSymbol][utils.wrapperSymbol] = obj; if (Impl.init) { Impl.init(obj[implSymbol], privateData); @@ -3606,12 +5392,12 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Storage { + class TypedefsAndUnions { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - key(index) { + numOrStrConsumer(a) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); @@ -3619,19 +5405,30 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'key' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'key' on 'Storage': parameter 1\\" }); + if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } args.push(curArg); } - return esValue[implSymbol].key(...args); + return esValue[implSymbol].numOrStrConsumer(...args); } - getItem(key) { + numOrEnumConsumer(a) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); @@ -3639,44 +5436,33 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'getItem' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - return esValue[implSymbol].getItem(...args); - } - - setItem(key, value) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'setItem' on 'Storage': 2 arguments required, but only \\" + arguments.length + \\" present.\\" + \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 2\\" }); + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } else { + curArg = RequestDestination.convert(curArg, { + context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } + } args.push(curArg); } - return esValue[implSymbol].setItem(...args); + return esValue[implSymbol].numOrEnumConsumer(...args); } - removeItem(key) { + numOrStrOrNullConsumer(a) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); @@ -3684,339 +5470,384 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'removeItem' on 'Storage': parameter 1\\" - }); + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true, + enforceRange: true + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + enforceRange: true + }); + } + } args.push(curArg); } - return esValue[implSymbol].removeItem(...args); + return esValue[implSymbol].numOrStrOrNullConsumer(...args); } - clear() { + numOrStrOrURLOrNullConsumer(a) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].clear(); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (URL.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true, + enforceRange: true + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + enforceRange: true + }); + } + } + args.push(curArg); + } + return esValue[implSymbol].numOrStrOrURLOrNullConsumer(...args); } - get length() { + urlMapInnerConsumer(a) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"length\\"]; - } - } - Object.defineProperties(Storage.prototype, { - key: { enumerable: true }, - getItem: { enumerable: true }, - setItem: { enumerable: true }, - removeItem: { enumerable: true }, - clear: { enumerable: true }, - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Storage\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = Storage; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: Storage - }); -}; - -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}\`); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - } - - 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].getItem(P); - - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; - } - - return Reflect.getOwnPropertyDescriptor(target, P); - }, + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); - } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { - let namedValue = V; + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + }); - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'Storage': The provided value\\" - }); + let typedValue = curArg[key]; - target[implSymbol].setItem(P, namedValue); + typedValue = URL.convert(typedValue, { + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + }); - return true; + result[typedKey] = typedValue; + } + } + curArg = result; + } + args.push(curArg); } + return esValue[implSymbol].urlMapInnerConsumer(...args); } - let ownDesc; - if (ownDesc === undefined) { - ownDesc = Reflect.getOwnPropertyDescriptor(target, P); - } - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - if (parent !== null) { - return Reflect.set(parent, P, V, receiver); - } - 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; + urlMapConsumer(a) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - 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 (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; - let namedValue = desc.value; + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + }); - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'Storage': The provided value\\" - }); + let typedValue = curArg[key]; - target[implSymbol].setItem(P, namedValue); + typedValue = URL.convert(typedValue, { + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + }); - return true; + result[typedKey] = typedValue; + } + } + curArg = result; + } + } + args.push(curArg); + } + return esValue[implSymbol].urlMapConsumer(...args); } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + bufferSourceOrURLConsumer(b) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - target[implSymbol].removeItem(P); - return true; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (URL.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].bufferSourceOrURLConsumer(...args); } - return Reflect.deleteProperty(target, P); - }, - - preventExtensions() { - return false; - } -}; + arrayBufferViewOrURLMapConsumer(b) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -const Impl = require(\\"../implementations/Storage.js\\"); -" -`; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (ArrayBuffer.isView(curArg)) { + } else if (utils.isObject(curArg)) { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; -exports[`with processors StringifierAttribute.webidl 1`] = ` -"\\"use strict\\"; + typedKey = conversions[\\"USVString\\"](typedKey, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s key\\" + }); -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + let typedValue = curArg[key]; -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; + typedValue = URL.convert(typedValue, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s value\\" + }); -const interfaceName = \\"StringifierAttribute\\"; + result[typedKey] = typedValue; + } + } + curArg = result; + } + } else { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" is not of any supported type.\\" + ); + } + } + args.push(curArg); + } + return esValue[implSymbol].arrayBufferViewOrURLMapConsumer(...args); + } -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'StringifierAttribute'.\`); -}; + arrayBufferViewDupConsumer(b) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].arrayBufferViewDupConsumer(...args); + } - const ctor = globalObject[ctorRegistrySymbol][\\"StringifierAttribute\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor StringifierAttribute is not installed on the passed global object\\"); - } + get buf() { + const esValue = this !== null && this !== undefined ? this : globalObject; - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + return utils.tryWrapperForImpl(esValue[implSymbol][\\"buf\\"]); + } - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; + set buf(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -const exposed = new Set([\\"Window\\"]); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class StringifierAttribute { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + if (utils.isArrayBuffer(V)) { + } else if ( + ArrayBuffer.isView(V) && + (V.constructor.name === \\"Uint8Array\\" || V.constructor.name === \\"Uint16Array\\") + ) { + } else { + throw new TypeError( + \\"Failed to set the 'buf' property on 'TypedefsAndUnions': The provided value\\" + + \\" is not of any supported type.\\" + ); + } + esValue[implSymbol][\\"buf\\"] = V; } - get attr() { + get time() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"attr\\"]; + return esValue[implSymbol][\\"time\\"]; } - toString() { - const esValue = this; + set time(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"attr\\"]; + V = conversions[\\"unsigned long long\\"](V, { + context: \\"Failed to set the 'time' property on 'TypedefsAndUnions': The provided value\\" + }); + + esValue[implSymbol][\\"time\\"] = V; } } - Object.defineProperties(StringifierAttribute.prototype, { - attr: { enumerable: true }, - toString: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"StringifierAttribute\\", configurable: true } + Object.defineProperties(TypedefsAndUnions.prototype, { + numOrStrConsumer: { enumerable: true }, + numOrEnumConsumer: { enumerable: true }, + numOrStrOrNullConsumer: { enumerable: true }, + numOrStrOrURLOrNullConsumer: { enumerable: true }, + urlMapInnerConsumer: { enumerable: true }, + urlMapConsumer: { enumerable: true }, + bufferSourceOrURLConsumer: { enumerable: true }, + arrayBufferViewOrURLMapConsumer: { enumerable: true }, + arrayBufferViewDupConsumer: { enumerable: true }, + buf: { enumerable: true }, + time: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"TypedefsAndUnions\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = StringifierAttribute; + globalObject[ctorRegistrySymbol][interfaceName] = TypedefsAndUnions; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: StringifierAttribute + value: TypedefsAndUnions }); }; -const Impl = require(\\"../implementations/StringifierAttribute.js\\"); +const Impl = require(\\"../implementations/TypedefsAndUnions.js\\"); " `; -exports[`with processors StringifierDefaultOperation.webidl 1`] = ` +exports[`with processors URL.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -4025,7 +5856,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"StringifierDefaultOperation\\"; +const interfaceName = \\"URL\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -4037,7 +5868,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'StringifierDefaultOperation'.\`); + throw new TypeError(\`\${context} is not of type 'URL'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -4045,11 +5876,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"StringifierDefaultOperation\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"URL\\"]; if (ctor === undefined) { - throw new Error( - \\"Internal error: constructor StringifierDefaultOperation is not installed on the passed global object\\" - ); + throw new Error(\\"Internal error: constructor URL is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -4077,568 +5906,419 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Window\\", \\"Worker\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class StringifierDefaultOperation { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + class URL { + constructor(url) { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to construct 'URL': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 1\\" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 2\\" }); + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - toString() { + toJSON() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].toString(); + return esValue[implSymbol].toJSON(); } - } - Object.defineProperties(StringifierDefaultOperation.prototype, { - toString: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"StringifierDefaultOperation\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = StringifierDefaultOperation; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: StringifierDefaultOperation - }); -}; - -const Impl = require(\\"../implementations/StringifierDefaultOperation.js\\"); -" -`; - -exports[`with processors StringifierNamedOperation.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"StringifierNamedOperation\\"; - -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'StringifierNamedOperation'.\`); -}; - -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } - - const ctor = globalObject[ctorRegistrySymbol][\\"StringifierNamedOperation\\"]; - if (ctor === undefined) { - throw new Error( - \\"Internal error: constructor StringifierNamedOperation is not installed on the passed global object\\" - ); - } - - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; - - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const exposed = new Set([\\"Window\\"]); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class StringifierNamedOperation { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return esValue[implSymbol][\\"href\\"]; } - operation() { + set href(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].operation(); + V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'href' property on 'URL': The provided value\\" }); + + esValue[implSymbol][\\"href\\"] = V; } toString() { - const esValue = this !== null && this !== undefined ? this : globalObject; + const esValue = this; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].operation(); + return esValue[implSymbol][\\"href\\"]; } - } - Object.defineProperties(StringifierNamedOperation.prototype, { - operation: { enumerable: true }, - toString: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"StringifierNamedOperation\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = StringifierNamedOperation; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: StringifierNamedOperation - }); -}; - -const Impl = require(\\"../implementations/StringifierNamedOperation.js\\"); -" -`; - -exports[`with processors StringifierOperation.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const interfaceName = \\"StringifierOperation\\"; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'StringifierOperation'.\`); -}; + return esValue[implSymbol][\\"origin\\"]; + } -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; - const ctor = globalObject[ctorRegistrySymbol][\\"StringifierOperation\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor StringifierOperation is not installed on the passed global object\\"); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; + return esValue[implSymbol][\\"protocol\\"]; + } - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -const exposed = new Set([\\"Window\\"]); + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'protocol' property on 'URL': The provided value\\" + }); -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class StringifierOperation { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + esValue[implSymbol][\\"protocol\\"] = V; } - toString() { + get username() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].toString(); + return esValue[implSymbol][\\"username\\"]; } - } - Object.defineProperties(StringifierOperation.prototype, { - toString: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"StringifierOperation\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = StringifierOperation; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: StringifierOperation - }); -}; + set username(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -const Impl = require(\\"../implementations/StringifierOperation.js\\"); -" -`; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports[`with processors TypedefsAndUnions.webidl 1`] = ` -"\\"use strict\\"; + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'username' property on 'URL': The provided value\\" + }); -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + esValue[implSymbol][\\"username\\"] = V; + } -const RequestDestination = require(\\"./RequestDestination.js\\"); -const URL = require(\\"./URL.js\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; + get password() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const interfaceName = \\"TypedefsAndUnions\\"; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'TypedefsAndUnions'.\`); -}; + return esValue[implSymbol][\\"password\\"]; + } -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } + set password(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - const ctor = globalObject[ctorRegistrySymbol][\\"TypedefsAndUnions\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor TypedefsAndUnions is not installed on the passed global object\\"); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'password' property on 'URL': The provided value\\" + }); - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + esValue[implSymbol][\\"password\\"] = V; + } - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const exposed = new Set([\\"Window\\"]); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class TypedefsAndUnions { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return esValue[implSymbol][\\"host\\"]; } - numOrStrConsumer(a) { + set host(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true - }); - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\" - }); - } - args.push(curArg); - } - return esValue[implSymbol].numOrStrConsumer(...args); + V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'host' property on 'URL': The provided value\\" }); + + esValue[implSymbol][\\"host\\"] = V; } - numOrEnumConsumer(a) { + get hostname() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" - }); - } else { - curArg = RequestDestination.convert(curArg, { - context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" - }); - } - } - args.push(curArg); - } - return esValue[implSymbol].numOrEnumConsumer(...args); + return esValue[implSymbol][\\"hostname\\"]; } - numOrStrOrNullConsumer(a) { + set hostname(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'hostname' property on 'URL': The provided value\\" + }); + + esValue[implSymbol][\\"hostname\\"] = V; + } + + get port() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true, - enforceRange: true - }); - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - enforceRange: true - }); - } - } - args.push(curArg); + + return esValue[implSymbol][\\"port\\"]; + } + + set port(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].numOrStrOrNullConsumer(...args); + + V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'port' property on 'URL': The provided value\\" }); + + esValue[implSymbol][\\"port\\"] = V; } - numOrStrOrURLOrNullConsumer(a) { + get pathname() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (URL.is(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true, - enforceRange: true - }); - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - enforceRange: true - }); - } - } - args.push(curArg); + return esValue[implSymbol][\\"pathname\\"]; + } + + set pathname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].numOrStrOrURLOrNullConsumer(...args); + + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'pathname' property on 'URL': The provided value\\" + }); + + esValue[implSymbol][\\"pathname\\"] = V; } - urlMapInnerConsumer(a) { + get search() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"search\\"]; + } + + set search(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" - ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" - }); + V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'search' property on 'URL': The provided value\\" }); - let typedValue = curArg[key]; + esValue[implSymbol][\\"search\\"] = V; + } - typedValue = URL.convert(typedValue, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" - }); + get searchParams() { + const esValue = this !== null && this !== undefined ? this : globalObject; - result[typedKey] = typedValue; - } - } - curArg = result; - } - args.push(curArg); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].urlMapInnerConsumer(...args); + + return utils.getSameObject(this, \\"searchParams\\", () => { + return utils.tryWrapperForImpl(esValue[implSymbol][\\"searchParams\\"]); + }); } - urlMapConsumer(a) { + get hash() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"hash\\"]; + } + + set hash(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" - ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" - }); + V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'hash' property on 'URL': The provided value\\" }); - let typedValue = curArg[key]; + esValue[implSymbol][\\"hash\\"] = V; + } + } + Object.defineProperties(URL.prototype, { + toJSON: { enumerable: true }, + href: { enumerable: true }, + toString: { enumerable: true }, + origin: { enumerable: true }, + protocol: { enumerable: true }, + username: { enumerable: true }, + password: { enumerable: true }, + host: { enumerable: true }, + hostname: { enumerable: true }, + port: { enumerable: true }, + pathname: { enumerable: true }, + search: { enumerable: true }, + searchParams: { enumerable: true }, + hash: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URL\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = URL; - typedValue = URL.convert(typedValue, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" - }); + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URL + }); - result[typedKey] = typedValue; - } - } - curArg = result; - } - } - args.push(curArg); - } - return esValue[implSymbol].urlMapConsumer(...args); + if (globalNames.includes(\\"Window\\")) { + Object.defineProperty(globalObject, \\"webkitURL\\", { + configurable: true, + writable: true, + value: URL + }); + } +}; + +const Impl = require(\\"../implementations/URL.js\\"); +" +`; + +exports[`with processors URLList.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"URLList\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'URLList'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"URLList\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor URLList is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj = new Proxy(obj, proxyHandler); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class URLList { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - bufferSourceOrURLConsumer(b) { + item(index) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); @@ -4646,210 +6326,217 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" + \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; - if (URL.is(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" - ); - } + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" + }); args.push(curArg); } - return esValue[implSymbol].bufferSourceOrURLConsumer(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); } - arrayBufferViewOrURLMapConsumer(b) { + get length() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (ArrayBuffer.isView(curArg)) { - } else if (utils.isObject(curArg)) { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\" is not an object.\\" - ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; + return esValue[implSymbol][\\"length\\"]; + } + } + Object.defineProperties(URLList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLList\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }, + keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true }, + values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true }, + entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true }, + forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = URLList; - typedKey = conversions[\\"USVString\\"](typedKey, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s key\\" - }); + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URLList + }); +}; - let typedValue = curArg[key]; +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, []); + }, - typedValue = URL.convert(typedValue, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s value\\" - }); + 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; + }, - result[typedKey] = typedValue; - } - } - curArg = result; - } - } else { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" - ); - } - } - args.push(curArg); - } - return esValue[implSymbol].arrayBufferViewOrURLMapConsumer(...args); + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(\`\${key}\`); } - arrayBufferViewDupConsumer(b) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + }, - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" - ); - } - args.push(curArg); - } - return esValue[implSymbol].arrayBufferViewDupConsumer(...args); + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); } + let ignoreNamedProps = false; - get buf() { - const esValue = this !== null && this !== undefined ? this : globalObject; + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; } + ignoreNamedProps = true; + } - return utils.tryWrapperForImpl(esValue[implSymbol][\\"buf\\"]); + return Reflect.getOwnPropertyDescriptor(target, P); + }, + + set(target, P, V, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.set(target, P, V, receiver); + } + if (target === receiver) { + utils.isArrayIndexPropName(P); } + let ownDesc; - set buf(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + 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); + }, - if (utils.isArrayBuffer(V)) { - } else if ( - ArrayBuffer.isView(V) && - (V.constructor.name === \\"Uint8Array\\" || V.constructor.name === \\"Uint16Array\\") - ) { - } else { - throw new TypeError( - \\"Failed to set the 'buf' property on 'TypedefsAndUnions': The provided value\\" + - \\" is not of any supported type.\\" - ); - } - esValue[implSymbol][\\"buf\\"] = V; + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); } - get time() { - const esValue = this !== null && this !== undefined ? this : globalObject; + if (utils.isArrayIndexPropName(P)) { + return false; + } - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + return Reflect.defineProperty(target, P, desc); + }, - return esValue[implSymbol][\\"time\\"]; + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); } - set time(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } - V = conversions[\\"unsigned long long\\"](V, { - context: \\"Failed to set the 'time' property on 'TypedefsAndUnions': The provided value\\" - }); + return Reflect.deleteProperty(target, P); + }, - esValue[implSymbol][\\"time\\"] = V; - } - } - Object.defineProperties(TypedefsAndUnions.prototype, { - numOrStrConsumer: { enumerable: true }, - numOrEnumConsumer: { enumerable: true }, - numOrStrOrNullConsumer: { enumerable: true }, - numOrStrOrURLOrNullConsumer: { enumerable: true }, - urlMapInnerConsumer: { enumerable: true }, - urlMapConsumer: { enumerable: true }, - bufferSourceOrURLConsumer: { enumerable: true }, - arrayBufferViewOrURLMapConsumer: { enumerable: true }, - arrayBufferViewDupConsumer: { enumerable: true }, - buf: { enumerable: true }, - time: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"TypedefsAndUnions\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); + preventExtensions() { + return false; } - globalObject[ctorRegistrySymbol][interfaceName] = TypedefsAndUnions; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: TypedefsAndUnions - }); }; -const Impl = require(\\"../implementations/TypedefsAndUnions.js\\"); +const Impl = require(\\"../implementations/URLList.js\\"); " `; -exports[`with processors URL.webidl 1`] = ` +exports[`with processors URLSearchParams.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -4858,7 +6545,46 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"URL\\"; +const interfaceName = \\"URLSearchParams\\"; + +const IteratorPrototype = Object.create(utils.IteratorPrototype, { + next: { + value: function next() { + const internal = this[utils.iterInternalSymbol]; + const { target, kind, index } = internal; + const values = Array.from(target[implSymbol]); + const len = values.length; + if (index >= len) { + return { value: undefined, done: true }; + } + + const pair = values[index]; + internal.index = index + 1; + const [key, value] = pair.map(utils.tryWrapperForImpl); + + let result; + switch (kind) { + case \\"key\\": + result = key; + break; + case \\"value\\": + result = value; + break; + case \\"key+value\\": + result = [key, value]; + break; + } + return { value: result, done: false }; + }, + writable: true, + enumerable: true, + configurable: true + }, + [Symbol.toStringTag]: { + value: \\"URLSearchParams Iterator\\", + configurable: true + } +}); exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -4870,7 +6596,16 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'URL'.\`); + throw new TypeError(\`\${context} is not of type 'URLSearchParams'.\`); +}; + +exports.createDefaultIterator = function createDefaultIterator(target, kind) { + const iterator = Object.create(IteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, index: 0 }, + configurable: true + }); + return iterator; }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -4878,9 +6613,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"URL\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParams\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor URL is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor URLSearchParams is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -4914,341 +6649,344 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class URL { - constructor(url) { - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to construct 'URL': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } + class URLSearchParams { + constructor() { const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 1\\" }); - args.push(curArg); - } - { - let curArg = arguments[1]; if (curArg !== undefined) { - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 2\\" }); - } - args.push(curArg); - } - return exports.setup(Object.create(new.target.prototype), globalObject, args); - } - - toJSON() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol].toJSON(); - } - - get href() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"href\\"]; - } - - set href(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'href' property on 'URL': The provided value\\" }); - - esValue[implSymbol][\\"href\\"] = V; - } - - toString() { - const esValue = this; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"href\\"]; - } - - get origin() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (!utils.isObject(nextItem)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + + \\" sequence\\" + + \\"'s element\\" + + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = nextItem; + for (let nextItem of tmp) { + nextItem = conversions[\\"USVString\\"](nextItem, { + context: + \\"Failed to construct 'URLSearchParams': parameter 1\\" + + \\" sequence\\" + + \\"'s element\\" + + \\"'s element\\" + }); - return esValue[implSymbol][\\"origin\\"]; - } + V.push(nextItem); + } + nextItem = V; + } - get protocol() { - const esValue = this !== null && this !== undefined ? this : globalObject; + V.push(nextItem); + } + curArg = V; + } + } else { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" + }); - return esValue[implSymbol][\\"protocol\\"]; - } + let typedValue = curArg[key]; - set protocol(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + typedValue = conversions[\\"USVString\\"](typedValue, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" + }); - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + result[typedKey] = typedValue; + } + } + curArg = result; + } + } + } else { + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + }); + } + } else { + curArg = \\"\\"; + } + args.push(curArg); } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'protocol' property on 'URL': The provided value\\" - }); - - esValue[implSymbol][\\"protocol\\"] = V; + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - get username() { + append(name, value) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"username\\"]; - } - - set username(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'username' property on 'URL': The provided value\\" - }); - - esValue[implSymbol][\\"username\\"] = V; - } - - get password() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); } - - return esValue[implSymbol][\\"password\\"]; - } - - set password(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'password' property on 'URL': The provided value\\" - }); - - esValue[implSymbol][\\"password\\"] = V; + return esValue[implSymbol].append(...args); } - get host() { + delete(name) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"host\\"]; - } - - set host(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - - V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'host' property on 'URL': The provided value\\" }); - - esValue[implSymbol][\\"host\\"] = V; - } - - get hostname() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); } - - return esValue[implSymbol][\\"hostname\\"]; + return esValue[implSymbol].delete(...args); } - set hostname(V) { + get(name) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'hostname' property on 'URL': The provided value\\" - }); - - esValue[implSymbol][\\"hostname\\"] = V; - } - - get port() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - - return esValue[implSymbol][\\"port\\"]; - } - - set port(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); } - - V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'port' property on 'URL': The provided value\\" }); - - esValue[implSymbol][\\"port\\"] = V; + return esValue[implSymbol].get(...args); } - get pathname() { + getAll(name) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"pathname\\"]; - } - - set pathname(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'pathname' property on 'URL': The provided value\\" - }); - - esValue[implSymbol][\\"pathname\\"] = V; + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args)); } - get search() { + has(name) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"search\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].has(...args); } - set search(V) { + set(name, value) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'search' property on 'URL': The provided value\\" }); - - esValue[implSymbol][\\"search\\"] = V; + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); + } + return esValue[implSymbol].set(...args); } - get searchParams() { + sort() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return utils.getSameObject(this, \\"searchParams\\", () => { - return utils.tryWrapperForImpl(esValue[implSymbol][\\"searchParams\\"]); - }); + return esValue[implSymbol].sort(); } - get hash() { + toString() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"hash\\"]; + return esValue[implSymbol].toString(); } - set hash(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + keys() { + if (!this || !exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return exports.createDefaultIterator(this, \\"key\\"); + } - if (!exports.is(esValue)) { + values() { + if (!this || !exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } + return exports.createDefaultIterator(this, \\"value\\"); + } - V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'hash' property on 'URL': The provided value\\" }); + entries() { + if (!this || !exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return exports.createDefaultIterator(this, \\"key+value\\"); + } - esValue[implSymbol][\\"hash\\"] = V; + forEach(callback) { + if (!this || !exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + if (arguments.length < 1) { + throw new TypeError(\\"Failed to execute 'forEach' on 'iterable': 1 argument required, \\" + \\"but only 0 present.\\"); + } + if (typeof callback !== \\"function\\") { + throw new TypeError( + \\"Failed to execute 'forEach' on 'iterable': The callback provided \\" + \\"as parameter 1 is not a function.\\" + ); + } + const thisArg = arguments[1]; + let pairs = Array.from(this[implSymbol]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[implSymbol]); + i++; + } } } - Object.defineProperties(URL.prototype, { - toJSON: { enumerable: true }, - href: { enumerable: true }, + Object.defineProperties(URLSearchParams.prototype, { + append: { enumerable: true }, + delete: { enumerable: true }, + get: { enumerable: true }, + getAll: { enumerable: true }, + has: { enumerable: true }, + set: { enumerable: true }, + sort: { enumerable: true }, toString: { enumerable: true }, - origin: { enumerable: true }, - protocol: { enumerable: true }, - username: { enumerable: true }, - password: { enumerable: true }, - host: { enumerable: true }, - hostname: { enumerable: true }, - port: { enumerable: true }, - pathname: { enumerable: true }, - search: { enumerable: true }, - searchParams: { enumerable: true }, - hash: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URL\\", configurable: true } + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + forEach: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLSearchParams\\", configurable: true }, + [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = URL; + globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParams; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URL + value: URLSearchParams }); - - if (globalNames.includes(\\"Window\\")) { - Object.defineProperty(globalObject, \\"webkitURL\\", { - configurable: true, - writable: true, - value: URL - }); - } }; -const Impl = require(\\"../implementations/URL.js\\"); +const Impl = require(\\"../implementations/URLSearchParams.js\\"); " `; -exports[`with processors URLList.webidl 1`] = ` +exports[`with processors URLSearchParamsCollection.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -5257,7 +6995,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"URLList\\"; +const interfaceName = \\"URLSearchParamsCollection\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -5269,7 +7007,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'URLList'.\`); + throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -5277,9 +7015,11 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"URLList\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor URLList is not installed on the passed global object\\"); + throw new Error( + \\"Internal error: constructor URLSearchParamsCollection is not installed on the passed global object\\" + ); } let obj = Object.create(ctor.prototype); @@ -5315,7 +7055,7 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class URLList { + class URLSearchParamsCollection { constructor() { throw new TypeError(\\"Illegal constructor\\"); } @@ -5328,20 +7068,46 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" + \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } const args = []; { let curArg = arguments[0]; curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" + context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); } + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); + } + get length() { const esValue = this !== null && this !== undefined ? this : globalObject; @@ -5352,25 +7118,22 @@ exports.install = (globalObject, globalNames) => { return esValue[implSymbol][\\"length\\"]; } } - Object.defineProperties(URLList.prototype, { + Object.defineProperties(URLSearchParamsCollection.prototype, { item: { enumerable: true }, + namedItem: { enumerable: true }, length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLList\\", configurable: true }, - [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }, - keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true }, - values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true }, - entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true }, - forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true } + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = URLList; + globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParamsCollection; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URLList + value: URLSearchParamsCollection }); }; @@ -5419,6 +7182,12 @@ const proxyHandler = { keys.add(\`\${key}\`); } + 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); } @@ -5433,9 +7202,8 @@ const proxyHandler = { if (utils.isArrayIndexPropName(P)) { const index = P >>> 0; - - if (target[implSymbol][utils.supportsPropertyIndex](index)) { - const indexedValue = target[implSymbol].item(index); + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { return { writable: false, enumerable: true, @@ -5446,6 +7214,17 @@ const proxyHandler = { ignoreNamedProps = true; } + const namedValue = target[implSymbol].namedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + return Reflect.getOwnPropertyDescriptor(target, P); }, @@ -5455,14 +7234,15 @@ const proxyHandler = { } if (target === receiver) { utils.isArrayIndexPropName(P); + + typeof P === \\"string\\" && !utils.isArrayIndexPropName(P); } let ownDesc; if (utils.isArrayIndexPropName(P)) { const index = P >>> 0; - - if (target[implSymbol][utils.supportsPropertyIndex](index)) { - const indexedValue = target[implSymbol].item(index); + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { ownDesc = { writable: false, enumerable: true, @@ -5512,7 +7292,12 @@ const proxyHandler = { if (utils.isArrayIndexPropName(P)) { return false; } - + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].namedItem(P) !== null); + if (!creating) { + return false; + } + } return Reflect.defineProperty(target, P, desc); }, @@ -5523,70 +7308,37 @@ const proxyHandler = { if (utils.isArrayIndexPropName(P)) { const index = P >>> 0; - return !target[implSymbol][utils.supportsPropertyIndex](index); + return !(target[implSymbol].item(index) !== undefined); + } + + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; } return Reflect.deleteProperty(target, P); }, - preventExtensions() { - return false; - } -}; - -const Impl = require(\\"../implementations/URLList.js\\"); -" -`; - -exports[`with processors URLSearchParams.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"URLSearchParams\\"; - -const IteratorPrototype = Object.create(utils.IteratorPrototype, { - next: { - value: function next() { - const internal = this[utils.iterInternalSymbol]; - const { target, kind, index } = internal; - const values = Array.from(target[implSymbol]); - const len = values.length; - if (index >= len) { - return { value: undefined, done: true }; - } - - const pair = values[index]; - internal.index = index + 1; - const [key, value] = pair.map(utils.tryWrapperForImpl); - - let result; - switch (kind) { - case \\"key\\": - result = key; - break; - case \\"value\\": - result = value; - break; - case \\"key+value\\": - result = [key, value]; - break; - } - return { value: result, done: false }; - }, - writable: true, - enumerable: true, - configurable: true - }, - [Symbol.toStringTag]: { - value: \\"URLSearchParams Iterator\\", - configurable: true + preventExtensions() { + return false; } -}); +}; + +const Impl = require(\\"../implementations/URLSearchParamsCollection.js\\"); +" +`; + +exports[`with processors URLSearchParamsCollection2.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const URL = require(\\"./URL.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); + +const interfaceName = \\"URLSearchParamsCollection2\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -5598,16 +7350,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'URLSearchParams'.\`); -}; - -exports.createDefaultIterator = function createDefaultIterator(target, kind) { - const iterator = Object.create(IteratorPrototype); - Object.defineProperty(iterator, utils.iterInternalSymbol, { - value: { target, kind, index: 0 }, - configurable: true - }); - return iterator; + throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection2'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -5615,9 +7358,11 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParams\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection2\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor URLSearchParams is not installed on the passed global object\\"); + throw new Error( + \\"Internal error: constructor URLSearchParamsCollection2 is not installed on the passed global object\\" + ); } let obj = Object.create(ctor.prototype); @@ -5628,7 +7373,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + URLSearchParamsCollection._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -5638,6 +7385,8 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD configurable: true }); + obj = new Proxy(obj, proxyHandler); + obj[implSymbol][utils.wrapperSymbol] = obj; if (Impl.init) { Impl.init(obj[implSymbol], privateData); @@ -5645,350 +7394,259 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\", \\"Worker\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class URLSearchParams { - constructor() { - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - if (utils.isObject(curArg)) { - if (curArg[Symbol.iterator] !== undefined) { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - if (!utils.isObject(nextItem)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + - \\" sequence\\" + - \\"'s element\\" + - \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = nextItem; - for (let nextItem of tmp) { - nextItem = conversions[\\"USVString\\"](nextItem, { - context: - \\"Failed to construct 'URLSearchParams': parameter 1\\" + - \\" sequence\\" + - \\"'s element\\" + - \\"'s element\\" - }); - - V.push(nextItem); - } - nextItem = V; - } - - V.push(nextItem); - } - curArg = V; - } - } else { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" - ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" - }); - - let typedValue = curArg[key]; - - typedValue = conversions[\\"USVString\\"](typedValue, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" - }); - result[typedKey] = typedValue; - } - } - curArg = result; - } - } - } else { - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" - }); - } - } else { - curArg = \\"\\"; - } - args.push(curArg); - } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + if (globalObject.URLSearchParamsCollection === undefined) { + throw new Error( + \\"Internal error: attempting to evaluate URLSearchParamsCollection2 before URLSearchParamsCollection\\" + ); + } + class URLSearchParamsCollection2 extends globalObject.URLSearchParamsCollection { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } + } + Object.defineProperties(URLSearchParamsCollection2.prototype, { + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection2\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParamsCollection2; - append(name, value) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: URLSearchParamsCollection2 + }); +}; - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" - }); - args.push(curArg); - } - return esValue[implSymbol].append(...args); +const proxyHandler = { + get(target, P, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.get(target, P, receiver); } - - delete(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + 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, []); + }, - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - return esValue[implSymbol].delete(...args); + 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; + }, - get(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + ownKeys(target) { + const keys = new Set(); - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - return esValue[implSymbol].get(...args); + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(\`\${key}\`); } - getAll(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(\`\${key}\`); } + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args)); + for (const key of Reflect.ownKeys(target)) { + keys.add(key); } + return [...keys]; + }, - has(name) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; } - return esValue[implSymbol].has(...args); + ignoreNamedProps = true; } - set(name, value) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + const namedValue = target[implSymbol].namedItem(P); - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" - }); - args.push(curArg); - } - return esValue[implSymbol].set(...args); + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; } - sort() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + return Reflect.getOwnPropertyDescriptor(target, P); + }, - return esValue[implSymbol].sort(); + set(target, P, V, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.set(target, P, V, receiver); } + if (target === receiver) { + utils.isArrayIndexPropName(P); - toString() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + let namedValue = V; - return esValue[implSymbol].toString(); - } + namedValue = URL.convert(namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + }); - keys() { - if (!this || !exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + const creating = !(target[implSymbol].namedItem(P) !== null); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + + return true; } - return exports.createDefaultIterator(this, \\"key\\"); } + let ownDesc; - values() { - if (!this || !exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== undefined) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; } - return exports.createDefaultIterator(this, \\"value\\"); } - entries() { - if (!this || !exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + 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); } - return exports.createDefaultIterator(this, \\"key+value\\"); + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; } - - forEach(callback) { - if (!this || !exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; } - if (arguments.length < 1) { - throw new TypeError(\\"Failed to execute 'forEach' on 'iterable': 1 argument required, \\" + \\"but only 0 present.\\"); + if (!existingDesc.writable) { + return false; } - if (typeof callback !== \\"function\\") { - throw new TypeError( - \\"Failed to execute 'forEach' on 'iterable': The callback provided \\" + \\"as parameter 1 is not a function.\\" - ); + 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 (utils.isArrayIndexPropName(P)) { + return false; + } + if (!utils.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; } - const thisArg = arguments[1]; - let pairs = Array.from(this[implSymbol]); - let i = 0; - while (i < pairs.length) { - const [key, value] = pairs[i].map(utils.tryWrapperForImpl); - callback.call(thisArg, value, key, this); - pairs = Array.from(this[implSymbol]); - i++; + + let namedValue = desc.value; + + namedValue = URL.convert(namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + }); + + const creating = !(target[implSymbol].namedItem(P) !== null); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); } + + return true; + } + return Reflect.defineProperty(target, P, desc); + }, + + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); } - } - Object.defineProperties(URLSearchParams.prototype, { - append: { enumerable: true }, - delete: { enumerable: true }, - get: { enumerable: true }, - getAll: { enumerable: true }, - has: { enumerable: true }, - set: { enumerable: true }, - sort: { enumerable: true }, - toString: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true }, - forEach: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLSearchParams\\", configurable: true }, - [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParams; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: URLSearchParams - }); + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== undefined); + } + + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + }, + + preventExtensions() { + return false; + } }; -const Impl = require(\\"../implementations/URLSearchParams.js\\"); +const Impl = require(\\"../implementations/URLSearchParamsCollection2.js\\"); " `; -exports[`with processors URLSearchParamsCollection.webidl 1`] = ` +exports[`with processors UnderscoredProperties.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -5997,7 +7655,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"URLSearchParamsCollection\\"; +const interfaceName = \\"UnderscoredProperties\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -6009,7 +7667,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection'.\`); + throw new TypeError(\`\${context} is not of type 'UnderscoredProperties'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -6017,11 +7675,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"UnderscoredProperties\\"]; if (ctor === undefined) { - throw new Error( - \\"Internal error: constructor URLSearchParamsCollection is not installed on the passed global object\\" - ); + throw new Error(\\"Internal error: constructor UnderscoredProperties is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -6042,8 +7698,6 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD configurable: true }); - obj = new Proxy(obj, proxyHandler); - obj[implSymbol][utils.wrapperSymbol] = obj; if (Impl.init) { Impl.init(obj[implSymbol], privateData); @@ -6057,12 +7711,12 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class URLSearchParamsCollection { + class UnderscoredProperties { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - item(index) { + operation(sequence) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); @@ -6070,7 +7724,7 @@ exports.install = (globalObject, globalNames) => { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -6078,23 +7732,55 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" - }); + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"DOMString\\"](nextItem, { + context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" + }); + + V.push(nextItem); + } + curArg = V; + } args.push(curArg); } - return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + return esValue[implSymbol].operation(...args); } - namedItem(name) { + get attribute() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"attribute\\"]; + } + + set attribute(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } + V = conversions[\\"byte\\"](V, { + context: \\"Failed to set the 'attribute' property on 'UnderscoredProperties': The provided value\\" + }); + + esValue[implSymbol][\\"attribute\\"] = V; + } + + static static(void_) { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -6103,244 +7789,236 @@ exports.install = (globalObject, globalNames) => { { let curArg = arguments[0]; curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" + context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" }); args.push(curArg); } - return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); - } - - get length() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"length\\"]; + return Impl.implementation.static(...args); } } - Object.defineProperties(URLSearchParamsCollection.prototype, { - item: { enumerable: true }, - namedItem: { enumerable: true }, - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection\\", configurable: true }, - [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } + Object.defineProperties(UnderscoredProperties.prototype, { + operation: { enumerable: true }, + attribute: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"UnderscoredProperties\\", configurable: true }, + const: { value: 42, enumerable: true } + }); + Object.defineProperties(UnderscoredProperties, { + static: { enumerable: true }, + const: { value: 42, enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParamsCollection; + globalObject[ctorRegistrySymbol][interfaceName] = UnderscoredProperties; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URLSearchParamsCollection + value: UnderscoredProperties }); }; -const proxyHandler = { - get(target, P, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.get(target, P, receiver); - } - const desc = this.getOwnPropertyDescriptor(target, P); - if (desc === undefined) { - const parent = Object.getPrototypeOf(target); - if (parent === null) { - return undefined; - } - return Reflect.get(target, P, receiver); - } - if (!desc.get && !desc.set) { - return desc.value; - } - const getter = desc.get; - if (getter === undefined) { - return undefined; - } - return Reflect.apply(getter, receiver, []); - }, +const Impl = require(\\"../implementations/UnderscoredProperties.js\\"); +" +`; - has(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.has(target, P); - } - const desc = this.getOwnPropertyDescriptor(target, P); - if (desc !== undefined) { - return true; - } - const parent = Object.getPrototypeOf(target); - if (parent !== null) { - return Reflect.has(parent, P); - } - return false; - }, +exports[`with processors Unforgeable.webidl 1`] = ` +"\\"use strict\\"; - ownKeys(target) { - const keys = new Set(); +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - for (const key of target[implSymbol][utils.supportedPropertyIndices]) { - keys.add(\`\${key}\`); - } +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); - } - } +const interfaceName = \\"Unforgeable\\"; - for (const key of Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - }, +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Unforgeable'.\`); +}; - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - let ignoreNamedProps = false; +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Unforgeable\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Unforgeable is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + assign(url) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'assign' on 'Unforgeable': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'assign' on 'Unforgeable': 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(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"href\\"]; + }, + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - return { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; - } - ignoreNamedProps = true; - } + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'href' property on 'Unforgeable': The provided value\\" + }); - const namedValue = target[implSymbol].namedItem(P); + esValue[implSymbol][\\"href\\"] = V; + }, + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (namedValue !== null && !(P in target) && !ignoreNamedProps) { - return { - writable: false, - enumerable: false, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; - } + return esValue[implSymbol][\\"href\\"]; + }, + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; - return Reflect.getOwnPropertyDescriptor(target, P); - }, + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); - } - if (target === receiver) { - utils.isArrayIndexPropName(P); + return esValue[implSymbol][\\"origin\\"]; + }, + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; - typeof P === \\"string\\" && !utils.isArrayIndexPropName(P); - } - let ownDesc; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - ownDesc = { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; - } - } + return esValue[implSymbol][\\"protocol\\"]; + }, + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - if (ownDesc === undefined) { - ownDesc = Reflect.getOwnPropertyDescriptor(target, P); - } - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - if (parent !== null) { - return Reflect.set(parent, P, V, receiver); - } - ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; - } - if (!ownDesc.writable) { - return false; - } - if (!utils.isObject(receiver)) { - return false; - } - const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); - let valueDesc; - if (existingDesc !== undefined) { - if (existingDesc.get || existingDesc.set) { - return false; - } - if (!existingDesc.writable) { - return false; - } - valueDesc = { value: V }; - } else { - valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; - } - return Reflect.defineProperty(receiver, P, valueDesc); - }, + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); - } + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'protocol' property on 'Unforgeable': The provided value\\" + }); - if (utils.isArrayIndexPropName(P)) { - return false; - } - if (!utils.hasOwn(target, P)) { - const creating = !(target[implSymbol].namedItem(P) !== null); - if (!creating) { - return false; + esValue[implSymbol][\\"protocol\\"] = V; } - } - return Reflect.defineProperty(target, P, desc); - }, + }) + ); - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + Object.defineProperties(obj, { + assign: { configurable: false, writable: false }, + href: { configurable: false }, + toString: { configurable: false, writable: false }, + origin: { configurable: false }, + protocol: { configurable: false } + }); +}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - return !(target[implSymbol].item(index) !== undefined); - } + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - if (target[implSymbol].namedItem(P) !== null && !(P in target)) { - return false; - } + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; - return Reflect.deleteProperty(target, P); - }, +const exposed = new Set([\\"Window\\"]); - preventExtensions() { - return false; +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Unforgeable { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(Unforgeable.prototype, { + [Symbol.toStringTag]: { value: \\"Unforgeable\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); } + globalObject[ctorRegistrySymbol][interfaceName] = Unforgeable; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Unforgeable + }); }; -const Impl = require(\\"../implementations/URLSearchParamsCollection.js\\"); +const Impl = require(\\"../implementations/Unforgeable.js\\"); " `; -exports[`with processors URLSearchParamsCollection2.webidl 1`] = ` +exports[`with processors UnforgeableMap.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const URL = require(\\"./URL.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); -const interfaceName = \\"URLSearchParamsCollection2\\"; +const interfaceName = \\"UnforgeableMap\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -6352,7 +8030,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'URLSearchParamsCollection2'.\`); + throw new TypeError(\`\${context} is not of type 'UnforgeableMap'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -6360,11 +8038,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"URLSearchParamsCollection2\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"UnforgeableMap\\"]; if (ctor === undefined) { - throw new Error( - \\"Internal error: constructor URLSearchParamsCollection2 is not installed on the passed global object\\" - ); + throw new Error(\\"Internal error: constructor UnforgeableMap is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -6376,7 +8052,22 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD return utils.implForWrapper(obj); }; exports._internalSetup = function _internalSetup(obj, globalObject) { - URLSearchParamsCollection._internalSetup(obj, globalObject); + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + get a() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"a\\"]; + } + }) + ); + + Object.defineProperties(obj, { a: { configurable: false } }); }; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -6402,30 +8093,23 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - - if (globalObject.URLSearchParamsCollection === undefined) { - throw new Error( - \\"Internal error: attempting to evaluate URLSearchParamsCollection2 before URLSearchParamsCollection\\" - ); - } - class URLSearchParamsCollection2 extends globalObject.URLSearchParamsCollection { + class UnforgeableMap { constructor() { throw new TypeError(\\"Illegal constructor\\"); } } - Object.defineProperties(URLSearchParamsCollection2.prototype, { - [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection2\\", configurable: true }, - [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } + Object.defineProperties(UnforgeableMap.prototype, { + [Symbol.toStringTag]: { value: \\"UnforgeableMap\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParamsCollection2; + globalObject[ctorRegistrySymbol][interfaceName] = UnforgeableMap; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: URLSearchParamsCollection2 + value: UnforgeableMap }); }; @@ -6470,10 +8154,6 @@ const proxyHandler = { ownKeys(target) { const keys = new Set(); - for (const key of target[implSymbol][utils.supportedPropertyIndices]) { - keys.add(\`\${key}\`); - } - for (const key of target[implSymbol][utils.supportedPropertyNames]) { if (!(key in target)) { keys.add(\`\${key}\`); @@ -6492,23 +8172,9 @@ const proxyHandler = { } let ignoreNamedProps = false; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - return { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; - } - ignoreNamedProps = true; - } - - const namedValue = target[implSymbol].namedItem(P); + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { + const namedValue = target[implSymbol][utils.namedGet](P); - if (namedValue !== null && !(P in target) && !ignoreNamedProps) { return { writable: true, enumerable: true, @@ -6525,16 +8191,14 @@ const proxyHandler = { return Reflect.set(target, P, V, receiver); } if (target === receiver) { - utils.isArrayIndexPropName(P); - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { let namedValue = V; - namedValue = URL.convert(namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': The provided value\\" + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'UnforgeableMap': The provided value\\" }); - const creating = !(target[implSymbol].namedItem(P) !== null); + const creating = !target[implSymbol][utils.supportsPropertyName](P); if (creating) { target[implSymbol][utils.namedSetNew](P, namedValue); } else { @@ -6546,19 +8210,6 @@ const proxyHandler = { } let ownDesc; - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - const indexedValue = target[implSymbol].item(index); - if (indexedValue !== undefined) { - ownDesc = { - writable: false, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(indexedValue) - }; - } - } - if (ownDesc === undefined) { ownDesc = Reflect.getOwnPropertyDescriptor(target, P); } @@ -6595,29 +8246,27 @@ const proxyHandler = { 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; + } - if (utils.isArrayIndexPropName(P)) { - return false; - } - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; - } + let namedValue = desc.value; - let namedValue = desc.value; + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'UnforgeableMap': The provided value\\" + }); - namedValue = URL.convert(namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'URLSearchParamsCollection2': 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); + } - const creating = !(target[implSymbol].namedItem(P) !== null); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); + return true; } - - return true; } return Reflect.defineProperty(target, P, desc); }, @@ -6627,12 +8276,7 @@ const proxyHandler = { return Reflect.deleteProperty(target, P); } - if (utils.isArrayIndexPropName(P)) { - const index = P >>> 0; - return !(target[implSymbol].item(index) !== undefined); - } - - if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { return false; } @@ -6644,11 +8288,11 @@ const proxyHandler = { } }; -const Impl = require(\\"../implementations/URLSearchParamsCollection2.js\\"); +const Impl = require(\\"../implementations/UnforgeableMap.js\\"); " `; -exports[`with processors UnderscoredProperties.webidl 1`] = ` +exports[`with processors Unscopable.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -6657,7 +8301,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"UnderscoredProperties\\"; +const interfaceName = \\"Unscopable\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -6669,7 +8313,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'UnderscoredProperties'.\`); + throw new TypeError(\`\${context} is not of type 'Unscopable'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -6677,9 +8321,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"UnderscoredProperties\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Unscopable\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor UnderscoredProperties is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Unscopable is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -6713,127 +8357,341 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class UnderscoredProperties { + class Unscopable { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - operation(sequence) { + get unscopableTest() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"unscopableTest\\"]; + } + + set unscopableTest(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'unscopableTest' property on 'Unscopable': The provided value\\" + }); + + esValue[implSymbol][\\"unscopableTest\\"] = V; + } + + get unscopableMixin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"unscopableMixin\\"]; + } + + set unscopableMixin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'unscopableMixin' property on 'Unscopable': The provided value\\" + }); + + esValue[implSymbol][\\"unscopableMixin\\"] = V; + } + } + Object.defineProperties(Unscopable.prototype, { + unscopableTest: { enumerable: true }, + unscopableMixin: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Unscopable\\", configurable: true }, + [Symbol.unscopables]: { + value: { unscopableTest: true, unscopableMixin: true, __proto__: null }, + configurable: true + } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Unscopable; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Unscopable + }); +}; + +const Impl = require(\\"../implementations/Unscopable.js\\"); +" +`; + +exports[`with processors Variadic.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const URL = require(\\"./URL.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Variadic\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Variadic'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Variadic\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Variadic is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class Variadic { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + simple1() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"DOMString\\"](nextItem, { - context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" - }); + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + return esValue[implSymbol].simple1(...args); + } + + simple2(first) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - V.push(nextItem); - } - curArg = V; - } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" + }); args.push(curArg); } - return esValue[implSymbol].operation(...args); + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = URL.convert(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); + args.push(curArg); + } + return esValue[implSymbol].simple2(...args); } - get attribute() { + overloaded1() { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - - return esValue[implSymbol][\\"attribute\\"]; + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } else { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } + } + } + return esValue[implSymbol].overloaded1(...args); } - set attribute(V) { + overloaded2(first) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"byte\\"](V, { - context: \\"Failed to set the 'attribute' property on 'UnderscoredProperties': The provided value\\" - }); - - esValue[implSymbol][\\"attribute\\"] = V; - } - - static static(void_) { if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + + \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" - }); - args.push(curArg); + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } + } + break; + default: { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } + } } - return Impl.implementation.static(...args); + return esValue[implSymbol].overloaded2(...args); } } - Object.defineProperties(UnderscoredProperties.prototype, { - operation: { enumerable: true }, - attribute: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"UnderscoredProperties\\", configurable: true }, - const: { value: 42, enumerable: true } - }); - Object.defineProperties(UnderscoredProperties, { - static: { enumerable: true }, - const: { value: 42, enumerable: true } + Object.defineProperties(Variadic.prototype, { + simple1: { enumerable: true }, + simple2: { enumerable: true }, + overloaded1: { enumerable: true }, + overloaded2: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Variadic\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = UnderscoredProperties; + globalObject[ctorRegistrySymbol][interfaceName] = Variadic; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: UnderscoredProperties + value: Variadic }); }; -const Impl = require(\\"../implementations/UnderscoredProperties.js\\"); +const Impl = require(\\"../implementations/Variadic.js\\"); " `; -exports[`with processors Unforgeable.webidl 1`] = ` +exports[`with processors Window.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const webidl2js_globals = require(\\"./webidl2js-globals.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require(\\"./EventTarget.js\\"); -const interfaceName = \\"Unforgeable\\"; +const interfaceName = \\"Window\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -6845,7 +8703,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Unforgeable'.\`); + throw new TypeError(\`\${context} is not of type 'Window'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -6853,9 +8711,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Unforgeable\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Window\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Unforgeable is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Window is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -6867,102 +8725,198 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD return utils.implForWrapper(obj); }; exports._internalSetup = function _internalSetup(obj, globalObject) { + EventTarget._internalSetup(obj, globalObject); + Object.defineProperties( obj, Object.getOwnPropertyDescriptors({ - assign(url) { + get window() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'assign' on 'Unforgeable': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return utils.tryWrapperForImpl(esValue[implSymbol][\\"window\\"]); + }, + get self() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'assign' on 'Unforgeable': parameter 1\\" - }); - args.push(curArg); + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"self\\"]); + }, + set self(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].assign(...args); + + Object.defineProperty(esValue, \\"self\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); }, - get href() { + get document() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"document\\"]); + }, + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"name\\"]; + }, + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'name' property on 'Window': The provided value\\" + }); + + esValue[implSymbol][\\"name\\"] = V; + }, + get location() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"location\\"]); + }, + set location(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + this.location.href = V; + }, + get frames() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"frames\\"]); + }, + set frames(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(esValue, \\"frames\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + }, + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"length\\"]; + }, + set length(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"href\\"]; + Object.defineProperty(esValue, \\"length\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); }, - set href(V) { + get top() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'href' property on 'Unforgeable': The provided value\\" - }); - - esValue[implSymbol][\\"href\\"] = V; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"top\\"]); }, - toString() { - const esValue = this; + get opener() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"href\\"]; + return esValue[implSymbol][\\"opener\\"]; }, - get origin() { + set opener(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"origin\\"]; + V = conversions[\\"any\\"](V, { context: \\"Failed to set the 'opener' property on 'Window': The provided value\\" }); + + esValue[implSymbol][\\"opener\\"] = V; }, - get protocol() { + get parent() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"protocol\\"]; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parent\\"]); }, - set protocol(V) { + set parent(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'protocol' property on 'Unforgeable': The provided value\\" + Object.defineProperty(esValue, \\"parent\\", { + configurable: true, + enumerable: true, + value: V, + writable: true }); - - esValue[implSymbol][\\"protocol\\"] = V; } }) ); Object.defineProperties(obj, { - assign: { configurable: false, writable: false }, - href: { configurable: false }, - toString: { configurable: false, writable: false }, - origin: { configurable: false }, - protocol: { configurable: false } + window: { configurable: false }, + document: { configurable: false }, + location: { configurable: false }, + top: { configurable: false } }); }; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { @@ -6981,37 +8935,54 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; +const globalNames = [\\"Window\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Unforgeable { + + if (globalObject.EventTarget === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Window before EventTarget\\"); + } + class Window extends globalObject.EventTarget { constructor() { throw new TypeError(\\"Illegal constructor\\"); } } - Object.defineProperties(Unforgeable.prototype, { - [Symbol.toStringTag]: { value: \\"Unforgeable\\", configurable: true } - }); + Object.defineProperties(Window.prototype, { [Symbol.toStringTag]: { value: \\"Window\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Unforgeable; + globalObject[ctorRegistrySymbol][interfaceName] = Window; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Unforgeable + value: Window }); }; -const Impl = require(\\"../implementations/Unforgeable.js\\"); +const Impl = require(\\"../implementations/Window.js\\"); " `; -exports[`with processors UnforgeableMap.webidl 1`] = ` +exports[`with processors ZeroArgConstructor.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -7020,7 +8991,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"UnforgeableMap\\"; +const interfaceName = \\"ZeroArgConstructor\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -7032,7 +9003,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'UnforgeableMap'.\`); + throw new TypeError(\`\${context} is not of type 'ZeroArgConstructor'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -7040,9 +9011,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"UnforgeableMap\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"ZeroArgConstructor\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor UnforgeableMap is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor ZeroArgConstructor is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -7053,24 +9024,7 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) { - Object.defineProperties( - obj, - Object.getOwnPropertyDescriptors({ - get a() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"a\\"]; - } - }) - ); - - Object.defineProperties(obj, { a: { configurable: false } }); -}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -7080,8 +9034,6 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD configurable: true }); - obj = new Proxy(obj, proxyHandler); - obj[implSymbol][utils.wrapperSymbol] = obj; if (Impl.init) { Impl.init(obj[implSymbol], privateData); @@ -7095,206 +9047,83 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class UnforgeableMap { + class ZeroArgConstructor { constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); } } - Object.defineProperties(UnforgeableMap.prototype, { - [Symbol.toStringTag]: { value: \\"UnforgeableMap\\", configurable: true } + Object.defineProperties(ZeroArgConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"ZeroArgConstructor\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = UnforgeableMap; + globalObject[ctorRegistrySymbol][interfaceName] = ZeroArgConstructor; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: UnforgeableMap + value: ZeroArgConstructor }); }; -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); - } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { - let namedValue = V; - - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'UnforgeableMap': 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); - }, +const Impl = require(\\"../implementations/ZeroArgConstructor.js\\"); +" +`; - 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; - } +exports[`without processors AsyncCallbackInterface.webidl 1`] = ` +"\\"use strict\\"; - let namedValue = desc.value; +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'UnforgeableMap': The provided value\\" - }); +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + if (!utils.isObject(value)) { + throw new TypeError(\`\${context} is not an object.\`); + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } + function callTheUserObjectsOperation() { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; - return true; + try { + if (typeof O !== \\"function\\") { + X = O[\\"asyncMethod\\"]; + if (typeof X !== \\"function\\") { + throw new TypeError(\`\${context} does not correctly implement AsyncCallbackInterface.\`); + } + thisArg = O; } - } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + let callResult = Reflect.apply(X, thisArg, []); - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - return false; - } + callResult = Promise.resolve(callResult).then( + value => { + value = conversions[\\"any\\"](value, { context: context + \\" promise value\\" }); - return Reflect.deleteProperty(target, P); - }, + return value; + }, + reason => reason + ); - preventExtensions() { - return false; + return callResult; + } catch (err) { + return Promise.reject(err); + } } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; }; -const Impl = require(\\"../implementations/UnforgeableMap.js\\"); +exports.install = (globalObject, globalNames) => {}; " `; -exports[`with processors Unscopable.webidl 1`] = ` +exports[`without processors BufferSourceTypes.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -7303,7 +9132,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Unscopable\\"; +const interfaceName = \\"BufferSourceTypes\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -7315,7 +9144,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Unscopable'.\`); + throw new TypeError(\`\${context} is not of type 'BufferSourceTypes'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -7323,9 +9152,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Unscopable\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"BufferSourceTypes\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Unscopable is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor BufferSourceTypes is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -7359,95 +9188,203 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Unscopable { + class BufferSourceTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - get unscopableTest() { + bs(source) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"unscopableTest\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'bs' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'bs' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].bs(...args); } - set unscopableTest(V) { + ab(ab) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'unscopableTest' property on 'Unscopable': The provided value\\" - }); - - esValue[implSymbol][\\"unscopableTest\\"] = V; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'ab' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"ArrayBuffer\\"](curArg, { + context: \\"Failed to execute 'ab' on 'BufferSourceTypes': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].ab(...args); } - get unscopableMixin() { + abv(abv) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"unscopableMixin\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'abv' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'abv' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return esValue[implSymbol].abv(...args); } - set unscopableMixin(V) { + u8a(u8) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'u8a' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"Uint8Array\\"](curArg, { + context: \\"Failed to execute 'u8a' on 'BufferSourceTypes': parameter 1\\" + }); + args.push(curArg); + } + return esValue[implSymbol].u8a(...args); + } + abUnion(ab) { + const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"boolean\\"](V, { - context: \\"Failed to set the 'unscopableMixin' property on 'Unscopable': The provided value\\" - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'abUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isArrayBuffer(curArg)) { + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'abUnion' on 'BufferSourceTypes': parameter 1\\" + }); + } + args.push(curArg); + } + return esValue[implSymbol].abUnion(...args); + } - esValue[implSymbol][\\"unscopableMixin\\"] = V; + u8aUnion(ab) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg) && curArg.constructor.name === \\"Uint8Array\\") { + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': parameter 1\\" + }); + } + args.push(curArg); + } + return esValue[implSymbol].u8aUnion(...args); } } - Object.defineProperties(Unscopable.prototype, { - unscopableTest: { enumerable: true }, - unscopableMixin: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Unscopable\\", configurable: true }, - [Symbol.unscopables]: { - value: { unscopableTest: true, unscopableMixin: true, __proto__: null }, - configurable: true - } + Object.defineProperties(BufferSourceTypes.prototype, { + bs: { enumerable: true }, + ab: { enumerable: true }, + abv: { enumerable: true }, + u8a: { enumerable: true }, + abUnion: { enumerable: true }, + u8aUnion: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"BufferSourceTypes\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Unscopable; + globalObject[ctorRegistrySymbol][interfaceName] = BufferSourceTypes; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Unscopable + value: BufferSourceTypes }); }; -const Impl = require(\\"../implementations/Unscopable.js\\"); +const Impl = require(\\"../implementations/BufferSourceTypes.js\\"); " `; -exports[`with processors Variadic.webidl 1`] = ` +exports[`without processors CEReactions.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 = \\"Variadic\\"; +const interfaceName = \\"CEReactions\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -7459,7 +9396,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Variadic'.\`); + throw new TypeError(\`\${context} is not of type 'CEReactions'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -7467,9 +9404,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Variadic\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"CEReactions\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Variadic is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor CEReactions is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -7490,6 +9427,15 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD configurable: true }); + { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + obj = new Proxy(obj, proxyHandler); + } + obj[implSymbol][utils.wrapperSymbol] = obj; if (Impl.init) { Impl.init(obj[implSymbol], privateData); @@ -7500,189 +9446,254 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class Variadic { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - simple1() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - const args = []; - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - return esValue[implSymbol].simple1(...args); + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class CEReactions { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - simple2(first) { + method() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = URL.convert(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); - args.push(curArg); - } - return esValue[implSymbol].simple2(...args); + return esValue[implSymbol].method(); } - overloaded1() { + get attr() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } - } - } - return esValue[implSymbol].overloaded1(...args); + + return esValue[implSymbol][\\"attr\\"]; } - overloaded2(first) { + set attr(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'attr' property on 'CEReactions': The provided value\\" + }); + + esValue[implSymbol][\\"attr\\"] = V; + } + } + Object.defineProperties(CEReactions.prototype, { + method: { enumerable: true }, + attr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"CEReactions\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = CEReactions; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CEReactions + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - } - } - break; - default: { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } + return 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); + } + if (target === receiver) { + const globalObject = this._globalObject; + + if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + let namedValue = V; + + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': 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); } - return esValue[implSymbol].overloaded2(...args); + 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); } - Object.defineProperties(Variadic.prototype, { - simple1: { enumerable: true }, - simple2: { enumerable: true }, - overloaded1: { enumerable: true }, - overloaded2: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"Variadic\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); + + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + 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 'CEReactions': 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); } - globalObject[ctorRegistrySymbol][interfaceName] = Variadic; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: Variadic - }); -}; + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } -const Impl = require(\\"../implementations/Variadic.js\\"); + const globalObject = this._globalObject; + + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { + target[implSymbol][utils.namedDelete](P); + return true; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require(\\"../implementations/CEReactions.js\\"); " `; -exports[`with processors ZeroArgConstructor.webidl 1`] = ` +exports[`without processors DOMImplementation.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -7691,7 +9702,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"ZeroArgConstructor\\"; +const interfaceName = \\"DOMImplementation\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -7703,7 +9714,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'ZeroArgConstructor'.\`); + throw new TypeError(\`\${context} is not of type 'DOMImplementation'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -7711,9 +9722,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"ZeroArgConstructor\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor ZeroArgConstructor is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor DOMImplementation is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -7747,83 +9758,149 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class ZeroArgConstructor { + class DOMImplementation { constructor() { - return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + throw new TypeError(\\"Illegal constructor\\"); } - } - Object.defineProperties(ZeroArgConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"ZeroArgConstructor\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = ZeroArgConstructor; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: ZeroArgConstructor - }); -}; - -const Impl = require(\\"../implementations/ZeroArgConstructor.js\\"); -" -`; - -exports[`without processors AsyncCallbackInterface.webidl 1`] = ` -"\\"use strict\\"; -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + createDocumentType(qualifiedName, publicId, systemId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { - if (!utils.isObject(value)) { - throw new TypeError(\`\${context} is not an object.\`); - } + 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)); + } - function callTheUserObjectsOperation() { - let thisArg = utils.tryWrapperForImpl(this); - let O = value; - let X = O; + createDocument(namespace, qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - try { - if (typeof O !== \\"function\\") { - X = O[\\"asyncMethod\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement AsyncCallbackInterface.\`); + 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\\" + }); } - thisArg = O; + 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)); + } - let callResult = Reflect.apply(X, thisArg, []); - - callResult = Promise.resolve(callResult).then( - value => { - value = conversions[\\"any\\"](value, { context: context + \\" promise value\\" }); + createHTMLDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + 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)); + } - return value; - }, - reason => reason - ); + hasFeature() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return callResult; - } catch (err) { - return Promise.reject(err); + 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 } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = DOMImplementation; - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; - - return callTheUserObjectsOperation; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMImplementation + }); }; -exports.install = (globalObject, globalNames) => {}; +const Impl = require(\\"../implementations/DOMImplementation.js\\"); " `; -exports[`without processors BufferSourceTypes.webidl 1`] = ` +exports[`without processors DOMRect.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -7832,7 +9909,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"BufferSourceTypes\\"; +const interfaceName = \\"DOMRect\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -7844,7 +9921,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'BufferSourceTypes'.\`); + throw new TypeError(\`\${context} is not of type 'DOMRect'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -7852,9 +9929,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"BufferSourceTypes\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"DOMRect\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor BufferSourceTypes is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor DOMRect is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -7882,518 +9959,395 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Window\\", \\"Worker\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class BufferSourceTypes { + class DOMRect { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - bs(source) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'bs' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } const args = []; { let curArg = arguments[0]; - if (utils.isArrayBuffer(curArg)) { - } else if (ArrayBuffer.isView(curArg)) { + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 1\\" + }); } else { - throw new TypeError( - \\"Failed to execute 'bs' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" - ); + curArg = 0; } args.push(curArg); } - return esValue[implSymbol].bs(...args); - } - - ab(ab) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'ab' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; { - let curArg = arguments[0]; - curArg = conversions[\\"ArrayBuffer\\"](curArg, { - context: \\"Failed to execute 'ab' on 'BufferSourceTypes': parameter 1\\" - }); + 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); } - return esValue[implSymbol].ab(...args); - } - - abv(abv) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'abv' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + { + 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); } - const args = []; { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg)) { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"unrestricted double\\"](curArg, { + context: \\"Failed to construct 'DOMRect': parameter 4\\" + }); } else { - throw new TypeError( - \\"Failed to execute 'abv' on 'BufferSourceTypes': parameter 1\\" + \\" is not of any supported type.\\" - ); + curArg = 0; } args.push(curArg); } - return esValue[implSymbol].abv(...args); + return exports.setup(Object.create(new.target.prototype), globalObject, args); } - u8a(u8) { + get x() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'u8a' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"Uint8Array\\"](curArg, { - context: \\"Failed to execute 'u8a' on 'BufferSourceTypes': parameter 1\\" - }); - args.push(curArg); - } - return esValue[implSymbol].u8a(...args); + return esValue[implSymbol][\\"x\\"]; } - abUnion(ab) { + set x(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'abUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (utils.isArrayBuffer(curArg)) { - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'abUnion' on 'BufferSourceTypes': parameter 1\\" - }); - } - args.push(curArg); - } - return esValue[implSymbol].abUnion(...args); + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'x' property on 'DOMRect': The provided value\\" + }); + + esValue[implSymbol][\\"x\\"] = V; } - u8aUnion(ab) { + get y() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg) && curArg.constructor.name === \\"Uint8Array\\") { - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'u8aUnion' on 'BufferSourceTypes': parameter 1\\" - }); - } - args.push(curArg); - } - return esValue[implSymbol].u8aUnion(...args); - } - } - Object.defineProperties(BufferSourceTypes.prototype, { - bs: { enumerable: true }, - ab: { enumerable: true }, - abv: { enumerable: true }, - u8a: { enumerable: true }, - abUnion: { enumerable: true }, - u8aUnion: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"BufferSourceTypes\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = BufferSourceTypes; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: BufferSourceTypes - }); -}; - -const Impl = require(\\"../implementations/BufferSourceTypes.js\\"); -" -`; - -exports[`without processors CEReactions.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"CEReactions\\"; - -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'CEReactions'.\`); -}; - -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } + return esValue[implSymbol][\\"y\\"]; + } - const ctor = globalObject[ctorRegistrySymbol][\\"CEReactions\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor CEReactions is not installed on the passed global object\\"); - } + set y(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); -}; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; -exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { - privateData.wrapper = obj; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - exports._internalSetup(obj, globalObject); - Object.defineProperty(obj, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" + }); - { - let proxyHandler = proxyHandlerCache.get(globalObject); - if (proxyHandler === undefined) { - proxyHandler = new ProxyHandler(globalObject); - proxyHandlerCache.set(globalObject, proxyHandler); + esValue[implSymbol][\\"y\\"] = V; } - obj = new Proxy(obj, proxyHandler); - } - obj[implSymbol][utils.wrapperSymbol] = obj; - if (Impl.init) { - Impl.init(obj[implSymbol], privateData); - } - return obj; -}; + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const exposed = new Set([\\"Window\\"]); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class CEReactions { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + return esValue[implSymbol][\\"width\\"]; } - method() { + set width(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].method(); + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'width' property on 'DOMRect': The provided value\\" + }); + + esValue[implSymbol][\\"width\\"] = V; } - get attr() { + get height() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"attr\\"]; + return esValue[implSymbol][\\"height\\"]; } - set attr(V) { + set height(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'attr' property on 'CEReactions': The provided value\\" + V = conversions[\\"unrestricted double\\"](V, { + context: \\"Failed to set the 'height' property on 'DOMRect': The provided value\\" }); - esValue[implSymbol][\\"attr\\"] = V; + esValue[implSymbol][\\"height\\"] = V; + } + + static fromRect() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = utils.tryImplForWrapper(curArg); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(Impl.implementation.fromRect(...args)); } } - Object.defineProperties(CEReactions.prototype, { - method: { enumerable: true }, - attr: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"CEReactions\\", configurable: true } + 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 } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = CEReactions; + globalObject[ctorRegistrySymbol][interfaceName] = DOMRect; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: CEReactions + value: DOMRect }); -}; - -const proxyHandlerCache = new WeakMap(); -class ProxyHandler { - constructor(globalObject) { - this._globalObject = globalObject; - } - - get(target, P, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.get(target, P, receiver); - } - const desc = this.getOwnPropertyDescriptor(target, P); - if (desc === undefined) { - const parent = Object.getPrototypeOf(target); - if (parent === null) { - return undefined; - } - 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; + if (globalNames.includes(\\"Window\\")) { + Object.defineProperty(globalObject, \\"SVGRect\\", { + configurable: true, + writable: true, + value: DOMRect + }); } +}; - ownKeys(target) { - const keys = new Set(); +const Impl = require(\\"../implementations/DOMRect.js\\"); +" +`; - for (const key of target[implSymbol][utils.supportedPropertyNames]) { - if (!(key in target)) { - keys.add(\`\${key}\`); - } - } +exports[`without processors Dictionary.webidl 1`] = ` +"\\"use strict\\"; - for (const key of Reflect.ownKeys(target)) { - keys.add(key); - } - return [...keys]; - } +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - let ignoreNamedProps = false; +const URL = require(\\"./URL.js\\"); +const URLSearchParams = require(\\"./URLSearchParams.js\\"); - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target) && !ignoreNamedProps) { - const namedValue = target[implSymbol][utils.namedGet](P); +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\\" }); - return { - writable: true, - enumerable: true, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; + ret[key] = value; + } else { + ret[key] = false; } - - return Reflect.getOwnPropertyDescriptor(target, P); } - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); - } - if (target === receiver) { - const globalObject = this._globalObject; - - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { - let namedValue = V; - - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': 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; + { + const key = \\"requiredInterface\\"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = URL.convert(value, { context: context + \\" has member requiredInterface that\\" }); - if (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 }; + ret[key] = value; } else { - valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); } - return Reflect.defineProperty(receiver, P, valueDesc); } - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); - } + { + 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\\" }); - const globalObject = this._globalObject; - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; + V.push(nextItem); + } + value = V; } - let namedValue = desc.value; - - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'CEReactions': The provided value\\" - }); + ret[key] = value; + } + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } + { + 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 true; + ret[key] = value; } - return Reflect.defineProperty(target, P, desc); } +}; - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } +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 globalObject = this._globalObject; + const ret = Object.create(null); + exports._convertInherit(obj, ret, { context }); + return ret; +}; +" +`; - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - target[implSymbol][utils.namedDelete](P); - return true; - } +exports[`without processors DictionaryConvert.webidl 1`] = ` +"\\"use strict\\"; - return Reflect.deleteProperty(target, P); +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\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); } + throw new TypeError(\`\${context} is not of type 'DictionaryConvert'.\`); +}; - preventExtensions() { - return false; +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); } -} -const Impl = require(\\"../implementations/CEReactions.js\\"); + const ctor = globalObject[ctorRegistrySymbol][\\"DictionaryConvert\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor DictionaryConvert is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class DictionaryConvert { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + op() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + 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); + } + } + Object.defineProperties(DictionaryConvert.prototype, { + op: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = DictionaryConvert; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DictionaryConvert + }); +}; + +const Impl = require(\\"../implementations/DictionaryConvert.js\\"); " `; -exports[`without processors DOMImplementation.webidl 1`] = ` +exports[`without processors Element.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -8401,8 +10355,9 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Node = require(\\"./Node.js\\"); -const interfaceName = \\"DOMImplementation\\"; +const interfaceName = \\"Element\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -8414,7 +10369,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'DOMImplementation'.\`); + throw new TypeError(\`\${context} is not of type 'Element'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -8422,9 +10377,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"DOMImplementation\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Element\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor DOMImplementation is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Element is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -8435,7 +10390,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Node._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -8458,158 +10415,186 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class DOMImplementation { + + if (globalObject.Node === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Element before Node\\"); + } + class Element extends globalObject.Node { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - createDocumentType(qualifiedName, publicId, systemId) { + get namespaceURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"namespaceURI\\"]; + } + + get prefix() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"prefix\\"]; + } + + get localName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"localName\\"]; + } + + get tagName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"tagName\\"]; + } + + get id() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"id\\"]; + } + + set id(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'id' property on 'Element': The provided value\\" }); + + esValue[implSymbol][\\"id\\"] = V; + } + + get className() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"className\\"]; + } + + set className(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'className' property on 'Element': The provided value\\" + }); + + esValue[implSymbol][\\"className\\"] = V; + } + + get classList() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - 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 utils.getSameObject(this, \\"classList\\", () => { + return utils.tryWrapperForImpl(esValue[implSymbol][\\"classList\\"]); + }); } - createDocument(namespace, qualifiedName) { + set classList(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - 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)); + this.classList.value = V; } - createHTMLDocument() { + get slot() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - 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)); + + return esValue[implSymbol][\\"slot\\"]; } - hasFeature() { + set slot(V) { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].hasFeature(); + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'slot' property on 'Element': The provided value\\" + }); + + esValue[implSymbol][\\"slot\\"] = V; } } - Object.defineProperties(DOMImplementation.prototype, { - createDocumentType: { enumerable: true }, - createDocument: { enumerable: true }, - createHTMLDocument: { enumerable: true }, - hasFeature: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DOMImplementation\\", configurable: true } + Object.defineProperties(Element.prototype, { + namespaceURI: { enumerable: true }, + prefix: { enumerable: true }, + localName: { enumerable: true }, + tagName: { enumerable: true }, + id: { enumerable: true }, + className: { enumerable: true }, + classList: { enumerable: true }, + slot: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Element\\", configurable: true }, + [Symbol.unscopables]: { value: { slot: true, __proto__: null }, configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = DOMImplementation; + globalObject[ctorRegistrySymbol][interfaceName] = Element; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: DOMImplementation + value: Element }); }; -const Impl = require(\\"../implementations/DOMImplementation.js\\"); +const Impl = require(\\"../implementations/Element.js\\"); " `; -exports[`without processors DOMRect.webidl 1`] = ` +exports[`without processors Enum.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 = \\"DOMRect\\"; +const interfaceName = \\"Enum\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -8621,7 +10606,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'DOMRect'.\`); + throw new TypeError(\`\${context} is not of type 'Enum'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -8629,9 +10614,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"DOMRect\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Enum\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor DOMRect is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Enum is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -8659,324 +10644,391 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\", \\"Worker\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class DOMRect { + class Enum { constructor() { - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 1\\" - }); - } else { - curArg = 0; - } - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 2\\" - }); - } else { - curArg = 0; - } - args.push(curArg); + throw new TypeError(\\"Illegal constructor\\"); + } + + op(destination) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - { - 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); + + 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[3]; - if (curArg !== undefined) { - curArg = conversions[\\"unrestricted double\\"](curArg, { - context: \\"Failed to construct 'DOMRect': parameter 4\\" - }); - } else { - curArg = 0; - } + let curArg = arguments[0]; + curArg = RequestDestination.convert(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); args.push(curArg); } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + return esValue[implSymbol].op(...args); } - get x() { + get attr() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"x\\"]; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"attr\\"]); } - set x(V) { + set attr(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'x' property on 'DOMRect': The provided value\\" - }); + V = \`\${V}\`; + if (!RequestDestination.enumerationValues.has(V)) { + return; + } - esValue[implSymbol][\\"x\\"] = V; + esValue[implSymbol][\\"attr\\"] = V; } + } + Object.defineProperties(Enum.prototype, { + op: { enumerable: true }, + attr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Enum\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Enum; - get y() { - const esValue = this !== null && this !== undefined ? this : globalObject; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Enum + }); +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const Impl = require(\\"../implementations/Enum.js\\"); +" +`; - return esValue[implSymbol][\\"y\\"]; - } +exports[`without processors EventListener.webidl 1`] = ` +"\\"use strict\\"; - set y(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(\\"Illegal invocation\\"); +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; +}; + +exports.install = (globalObject, globalNames) => {}; +" +`; - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'y' property on 'DOMRect': The provided value\\" - }); +exports[`without processors EventTarget.webidl 1`] = ` +"\\"use strict\\"; - esValue[implSymbol][\\"y\\"] = V; - } +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); - get width() { - const esValue = this !== null && this !== undefined ? this : globalObject; +const EventListener = require(\\"./EventListener.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const interfaceName = \\"EventTarget\\"; - return esValue[implSymbol][\\"width\\"]; - } +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'EventTarget'.\`); +}; - set width(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } + const ctor = globalObject[ctorRegistrySymbol][\\"EventTarget\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor EventTarget is not installed on the passed global object\\"); + } - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'width' property on 'DOMRect': The provided value\\" - }); + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; - esValue[implSymbol][\\"width\\"] = V; - } + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); - get height() { - const esValue = this !== null && this !== undefined ? this : globalObject; + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); - return esValue[implSymbol][\\"height\\"]; +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class EventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); } - set height(V) { + addEventListener(type, callback) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"unrestricted double\\"](V, { - context: \\"Failed to set the 'height' property on 'DOMRect': The provided value\\" - }); - - esValue[implSymbol][\\"height\\"] = V; - } - - static fromRect() { + 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]; - if (curArg !== undefined) { - curArg = utils.tryImplForWrapper(curArg); + 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 utils.tryWrapperForImpl(Impl.implementation.fromRect(...args)); + return esValue[implSymbol].addEventListener(...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(EventTarget.prototype, { + addEventListener: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"EventTarget\\", configurable: true } }); - Object.defineProperties(DOMRect, { fromRect: { enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = DOMRect; + globalObject[ctorRegistrySymbol][interfaceName] = EventTarget; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: DOMRect + value: EventTarget }); - - if (globalNames.includes(\\"Window\\")) { - Object.defineProperty(globalObject, \\"SVGRect\\", { - configurable: true, - writable: true, - value: DOMRect - }); - } }; -const Impl = require(\\"../implementations/DOMRect.js\\"); +const Impl = require(\\"../implementations/EventTarget.js\\"); " `; -exports[`without processors Dictionary.webidl 1`] = ` +exports[`without processors Global.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 webidl2js_globals = require(\\"./webidl2js-globals.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 = \\"Global\\"; - ret[key] = value; - } else { - ret[key] = false; - } +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); } + throw new TypeError(\`\${context} is not of type 'Global'.\`); +}; - { - 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\\" }); +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } - ret[key] = value; - } else { - throw new TypeError(\\"requiredInterface is required in 'Dictionary'\\"); - } + const ctor = globalObject[ctorRegistrySymbol][\\"Global\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Global is not installed on the passed global object\\"); } - { - 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\\" }); + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + op() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - V.push(nextItem); + return esValue[implSymbol].op(); + }, + unforgeableOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - value = V; - } - ret[key] = value; - } - } + return esValue[implSymbol].unforgeableOp(); + }, + get attr() { + const esValue = this !== null && this !== undefined ? this : globalObject; - { - 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\\" }); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"attr\\"]; + }, + set attr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'attr' property on 'Global': The provided value\\" + }); - ret[key] = value; - } - } -}; + esValue[implSymbol][\\"attr\\"] = V; + }, + get unforgeableAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; -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.\`); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - const ret = Object.create(null); - exports._convertInherit(obj, ret, { context }); - return ret; -}; -" -`; + return esValue[implSymbol][\\"unforgeableAttr\\"]; + }, + set unforgeableAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -exports[`without processors DictionaryConvert.webidl 1`] = ` -"\\"use strict\\"; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'unforgeableAttr' property on 'Global': The provided value\\" + }); -const Dictionary = require(\\"./Dictionary.js\\"); -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; + esValue[implSymbol][\\"unforgeableAttr\\"] = V; + }, + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; -const interfaceName = \\"DictionaryConvert\\"; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } -exports.is = function is(obj) { - return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = function isImpl(obj) { - return utils.isObject(obj) && obj instanceof Impl.implementation; -}; -exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { - if (exports.is(obj)) { - return utils.implForWrapper(obj); - } - throw new TypeError(\`\${context} is not of type 'DictionaryConvert'.\`); -}; + return esValue[implSymbol][\\"length\\"]; + }, + set length(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; -exports.create = function create(globalObject, constructorArgs, privateData) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - const ctor = globalObject[ctorRegistrySymbol][\\"DictionaryConvert\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor DictionaryConvert is not installed on the passed global object\\"); - } + V = conversions[\\"unsigned long\\"](V, { + context: \\"Failed to set the 'length' property on 'Global': The provided value\\" + }); - let obj = Object.create(ctor.prototype); - obj = exports.setup(obj, globalObject, constructorArgs, privateData); - return obj; -}; -exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { - const obj = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(obj); + esValue[implSymbol][\\"length\\"] = V; + }, + [Symbol.iterator]: Array.prototype[Symbol.iterator], + keys: Array.prototype.keys, + values: Array.prototype[Symbol.iterator], + entries: Array.prototype.entries, + forEach: Array.prototype.forEach + }) + ); + + Object.defineProperties(obj, { + unforgeableOp: { configurable: false, writable: false }, + unforgeableAttr: { configurable: false }, + [Symbol.iterator]: { enumerable: false } + }); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -8993,71 +11045,76 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\"]); +const globalNames = [\\"Global\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + +const exposed = new Set([\\"Global\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - 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(\\"Illegal invocation\\"); - } - 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; + + return Impl.implementation[\\"staticAttr\\"]; } } - Object.defineProperties(DictionaryConvert.prototype, { - op: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } - }); + Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); + Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = DictionaryConvert; + globalObject[ctorRegistrySymbol][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[`without processors Enum.webidl 1`] = ` +exports[`without processors HTMLConstructor.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 = \\"HTMLConstructor\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9069,7 +11126,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Enum'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLConstructor'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9077,9 +11134,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Enum\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Enum is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor HTMLConstructor is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9113,127 +11170,41 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Enum { + class HTMLConstructor { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - op(destination) { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - 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(\\"Illegal invocation\\"); - } - - return utils.tryWrapperForImpl(esValue[implSymbol][\\"attr\\"]); - } - - set attr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - 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 } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = Enum; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: Enum - }); -}; - -const Impl = require(\\"../implementations/Enum.js\\"); -" -`; - -exports[`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; + throw new TypeError(\\"Illegal constructor\\"); } - - event = utils.tryWrapperForImpl(event); - - let callResult = Reflect.apply(X, thisArg, [event]); } + Object.defineProperties(HTMLConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = HTMLConstructor; - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; - - return callTheUserObjectsOperation; + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLConstructor + }); }; -exports.install = (globalObject, globalNames) => {}; +const Impl = require(\\"../implementations/HTMLConstructor.js\\"); " `; -exports[`without processors EventTarget.webidl 1`] = ` +exports[`without processors HTMLElement.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 Element = require(\\"./Element.js\\"); -const interfaceName = \\"EventTarget\\"; +const interfaceName = \\"HTMLElement\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9245,7 +11216,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'EventTarget'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLElement'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9253,9 +11224,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"EventTarget\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"HTMLElement\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor EventTarget is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor HTMLElement is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9266,7 +11237,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Element._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -9283,73 +11256,141 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class EventTarget { + + if (globalObject.Element === undefined) { + throw new Error(\\"Internal error: attempting to evaluate HTMLElement before Element\\"); + } + class HTMLElement extends globalObject.Element { constructor() { - return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + throw new TypeError(\\"Illegal constructor\\"); } - addEventListener(type, callback) { + get title() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"title\\"]; + } + + set title(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'addEventListener' on 'EventTarget': parameter 1\\" - }); - args.push(curArg); + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'title' property on 'HTMLElement': The provided value\\" + }); + + esValue[implSymbol][\\"title\\"] = V; + } + + get lang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - { - 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][\\"lang\\"]; + } + + set lang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].addEventListener(...args); + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'lang' property on 'HTMLElement': The provided value\\" + }); + + esValue[implSymbol][\\"lang\\"] = V; + } + + get translate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"translate\\"]; + } + + set translate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"boolean\\"](V, { + context: \\"Failed to set the 'translate' property on 'HTMLElement': The provided value\\" + }); + + esValue[implSymbol][\\"translate\\"] = V; + } + + get dir() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"dir\\"]; + } + + set dir(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'dir' property on 'HTMLElement': The provided value\\" + }); + + esValue[implSymbol][\\"dir\\"] = V; } } - Object.defineProperties(EventTarget.prototype, { - addEventListener: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"EventTarget\\", configurable: true } + Object.defineProperties(HTMLElement.prototype, { + title: { enumerable: true }, + lang: { enumerable: true }, + translate: { enumerable: true }, + dir: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"HTMLElement\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = EventTarget; + globalObject[ctorRegistrySymbol][interfaceName] = HTMLElement; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: EventTarget + value: HTMLElement }); }; -const Impl = require(\\"../implementations/EventTarget.js\\"); +const Impl = require(\\"../implementations/HTMLElement.js\\"); " `; -exports[`without processors Global.webidl 1`] = ` +exports[`without processors LegacyArrayClass.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -9358,7 +11399,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Global\\"; +const interfaceName = \\"LegacyArrayClass\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9370,7 +11411,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'Global'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyArrayClass'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9378,9 +11419,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Global\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyArrayClass\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Global is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor LegacyArrayClass is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9391,106 +11432,7 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) { - Object.defineProperties( - obj, - Object.getOwnPropertyDescriptors({ - op() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol].op(); - }, - unforgeableOp() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol].unforgeableOp(); - }, - get attr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"attr\\"]; - }, - set attr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - 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(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"unforgeableAttr\\"]; - }, - set unforgeableAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - 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(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"length\\"]; - }, - set length(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - V = conversions[\\"unsigned long\\"](V, { - context: \\"Failed to set the 'length' property on 'Global': The provided value\\" - }); - - esValue[implSymbol][\\"length\\"] = V; - }, - [Symbol.iterator]: Array.prototype[Symbol.iterator], - keys: Array.prototype.keys, - values: Array.prototype[Symbol.iterator], - entries: Array.prototype.entries, - forEach: Array.prototype.forEach - }) - ); - - Object.defineProperties(obj, { - unforgeableOp: { configurable: false, writable: false }, - unforgeableAttr: { configurable: false }, - [Symbol.iterator]: { enumerable: false } - }); -}; +exports._internalSetup = function _internalSetup(obj, globalObject) {}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -9507,52 +11449,49 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Global\\"]); +const exposed = new Set([\\"Window\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Global { + class LegacyArrayClass { constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - static staticOp() { - return Impl.implementation.staticOp(); + throw new TypeError(\\"Illegal constructor\\"); } - static get staticAttr() { + get length() { const esValue = this !== null && this !== undefined ? this : globalObject; - return Impl.implementation[\\"staticAttr\\"]; - } - - static set staticAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return Impl.implementation[\\"staticAttr\\"]; + return esValue[implSymbol][\\"length\\"]; } } - Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); - Object.defineProperties(Global, { staticOp: { enumerable: true }, staticAttr: { enumerable: true } }); + Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); + Object.defineProperties(LegacyArrayClass.prototype, { + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyArrayClass\\", configurable: true } + }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = Global; + globalObject[ctorRegistrySymbol][interfaceName] = LegacyArrayClass; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: Global + value: LegacyArrayClass }); }; -const Impl = require(\\"../implementations/Global.js\\"); +const Impl = require(\\"../implementations/LegacyArrayClass.js\\"); " `; -exports[`without processors HTMLConstructor.webidl 1`] = ` +exports[`without processors MixedIn.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -9561,7 +11500,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"HTMLConstructor\\"; +const interfaceName = \\"MixedIn\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9573,7 +11512,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'HTMLConstructor'.\`); + throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9581,9 +11520,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"HTMLConstructor\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor HTMLConstructor is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9617,40 +11556,117 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class HTMLConstructor { + class MixedIn { constructor() { throw new TypeError(\\"Illegal constructor\\"); } + + mixedInOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].mixedInOp(); + } + + ifaceMixinOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].ifaceMixinOp(); + } + + get mixedInAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"mixedInAttr\\"]; + } + + set mixedInAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + 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(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + } + + set ifaceMixinAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" + }); + + esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + } } - Object.defineProperties(HTMLConstructor.prototype, { - [Symbol.toStringTag]: { value: \\"HTMLConstructor\\", configurable: true } + Object.defineProperties(MixedIn.prototype, { + mixedInOp: { enumerable: true }, + ifaceMixinOp: { enumerable: true }, + mixedInAttr: { enumerable: true }, + ifaceMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } + }); + Object.defineProperties(MixedIn, { + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = HTMLConstructor; + globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: HTMLConstructor + value: MixedIn }); }; -const Impl = require(\\"../implementations/HTMLConstructor.js\\"); +const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`without processors LegacyArrayClass.webidl 1`] = ` +exports[`without processors MultiGlobal.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); +const webidl2js_globals = require(\\"./webidl2js-globals.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyArrayClass\\"; +const interfaceName = \\"MultiGlobal\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9662,7 +11678,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'LegacyArrayClass'.\`); + throw new TypeError(\`\${context} is not of type 'MultiGlobal'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9670,9 +11686,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyArrayClass\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"MultiGlobal\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyArrayClass is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor MultiGlobal is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9683,7 +11699,24 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + get self() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"self\\"]); + } + }) + ); + + Object.defineProperties(obj, { self: { configurable: false } }); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -9700,49 +11733,52 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -const exposed = new Set([\\"Window\\"]); +const globalNames = [\\"Global1\\", \\"Global2\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + +const exposed = new Set([\\"Global1\\", \\"Global2\\"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyArrayClass { + class MultiGlobal { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - - get length() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"length\\"]; - } } - Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); - Object.defineProperties(LegacyArrayClass.prototype, { - length: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"LegacyArrayClass\\", configurable: true } + Object.defineProperties(MultiGlobal.prototype, { + [Symbol.toStringTag]: { value: \\"MultiGlobal\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyArrayClass; + globalObject[ctorRegistrySymbol][interfaceName] = MultiGlobal; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: LegacyArrayClass + value: MultiGlobal }); }; -const Impl = require(\\"../implementations/LegacyArrayClass.js\\"); +const Impl = require(\\"../implementations/MultiGlobal.js\\"); " `; -exports[`without processors MixedIn.webidl 1`] = ` +exports[`without processors Node.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -9750,8 +11786,9 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require(\\"./EventTarget.js\\"); -const interfaceName = \\"MixedIn\\"; +const interfaceName = \\"Node\\"; exports.is = function is(obj) { return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; @@ -9763,7 +11800,7 @@ exports.convert = function convert(obj, { context = \\"The provided value\\" } = if (exports.is(obj)) { return utils.implForWrapper(obj); } - throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); + throw new TypeError(\`\${context} is not of type 'Node'.\`); }; exports.create = function create(globalObject, constructorArgs, privateData) { @@ -9771,9 +11808,9 @@ exports.create = function create(globalObject, constructorArgs, privateData) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"Node\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor Node is not installed on the passed global object\\"); } let obj = Object.create(ctor.prototype); @@ -9784,7 +11821,9 @@ exports.createImpl = function createImpl(globalObject, constructorArgs, privateD const obj = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(obj); }; -exports._internalSetup = function _internalSetup(obj, globalObject) {}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + EventTarget._internalSetup(obj, globalObject); +}; exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { privateData.wrapper = obj; @@ -9807,103 +11846,218 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class MixedIn { + + if (globalObject.EventTarget === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Node before EventTarget\\"); + } + class Node extends globalObject.EventTarget { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - mixedInOp() { + getRootNode() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = utils.tryImplForWrapper(curArg); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getRootNode(...args)); + } - return esValue[implSymbol].mixedInOp(); + hasChildNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].hasChildNodes(); } - ifaceMixinOp() { + get nodeType() { const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol].ifaceMixinOp(); + return esValue[implSymbol][\\"nodeType\\"]; } - get mixedInAttr() { + get nodeName() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"mixedInAttr\\"]; + return esValue[implSymbol][\\"nodeName\\"]; } - set mixedInAttr(V) { + get baseURI() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" + return esValue[implSymbol][\\"baseURI\\"]; + } + + get isConnected() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"isConnected\\"]; + } + + get ownerDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"ownerDocument\\"]); + } + + get parentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parentNode\\"]); + } + + get parentElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parentElement\\"]); + } + + get childNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.getSameObject(this, \\"childNodes\\", () => { + return utils.tryWrapperForImpl(esValue[implSymbol][\\"childNodes\\"]); }); + } + + get firstChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"firstChild\\"]); + } + + get lastChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } - esValue[implSymbol][\\"mixedInAttr\\"] = V; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"lastChild\\"]); } - get ifaceMixinAttr() { + get previousSibling() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"previousSibling\\"]); } - set ifaceMixinAttr(V) { + get nextSibling() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new TypeError(\\"Illegal invocation\\"); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + return utils.tryWrapperForImpl(esValue[implSymbol][\\"nextSibling\\"]); } } - 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(Node.prototype, { + getRootNode: { enumerable: true }, + hasChildNodes: { enumerable: true }, + nodeType: { enumerable: true }, + nodeName: { enumerable: true }, + baseURI: { enumerable: true }, + isConnected: { enumerable: true }, + ownerDocument: { enumerable: true }, + parentNode: { enumerable: true }, + parentElement: { enumerable: true }, + childNodes: { enumerable: true }, + firstChild: { enumerable: true }, + lastChild: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Node\\", configurable: true }, + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true } }); - Object.defineProperties(MixedIn, { - mixedInConst: { value: 43, enumerable: true }, - ifaceMixinConst: { value: 42, enumerable: true } + Object.defineProperties(Node, { + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; + globalObject[ctorRegistrySymbol][interfaceName] = Node; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: MixedIn + value: Node }); }; -const Impl = require(\\"../implementations/MixedIn.js\\"); +const Impl = require(\\"../implementations/Node.js\\"); " `; @@ -15406,6 +17560,308 @@ const Impl = require(\\"../implementations/Variadic.js\\"); " `; +exports[`without processors Window.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const webidl2js_globals = require(\\"./webidl2js-globals.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require(\\"./EventTarget.js\\"); + +const interfaceName = \\"Window\\"; + +exports.is = function is(obj) { + return utils.isObject(obj) && utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = function isImpl(obj) { + return utils.isObject(obj) && obj instanceof Impl.implementation; +}; +exports.convert = function convert(obj, { context = \\"The provided value\\" } = {}) { + if (exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Window'.\`); +}; + +exports.create = function create(globalObject, constructorArgs, privateData) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Window\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Window is not installed on the passed global object\\"); + } + + let obj = Object.create(ctor.prototype); + obj = exports.setup(obj, globalObject, constructorArgs, privateData); + return obj; +}; +exports.createImpl = function createImpl(globalObject, constructorArgs, privateData) { + const obj = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(obj); +}; +exports._internalSetup = function _internalSetup(obj, globalObject) { + EventTarget._internalSetup(obj, globalObject); + + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + get window() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"window\\"]); + }, + get self() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"self\\"]); + }, + set self(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(esValue, \\"self\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + }, + get document() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"document\\"]); + }, + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"name\\"]; + }, + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'name' property on 'Window': The provided value\\" + }); + + esValue[implSymbol][\\"name\\"] = V; + }, + get location() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"location\\"]); + }, + set location(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + this.location.href = V; + }, + get frames() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"frames\\"]); + }, + set frames(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(esValue, \\"frames\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + }, + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"length\\"]; + }, + set length(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(esValue, \\"length\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + }, + get top() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"top\\"]); + }, + get opener() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"opener\\"]; + }, + set opener(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"any\\"](V, { context: \\"Failed to set the 'opener' property on 'Window': The provided value\\" }); + + esValue[implSymbol][\\"opener\\"] = V; + }, + get parent() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(esValue[implSymbol][\\"parent\\"]); + }, + set parent(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(esValue, \\"parent\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + } + }) + ); + + Object.defineProperties(obj, { + window: { configurable: false }, + document: { configurable: false }, + location: { configurable: false }, + top: { configurable: false } + }); +}; +exports.setup = function setup(obj, globalObject, constructorArgs = [], privateData = {}) { + privateData.wrapper = obj; + + exports._internalSetup(obj, globalObject); + Object.defineProperty(obj, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + obj[implSymbol][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[implSymbol], privateData); + } + return obj; +}; + +const globalNames = [\\"Window\\"]; + +/** + * Initialises the passed obj as a new global. + * + * The obj is expected to contain all the global object properties + * as specified in the ECMAScript specification. + */ +exports.setupGlobal = (obj, constructorArgs = [], privateData = {}) => { + webidl2js_globals.installInterfaces(obj, globalNames); + + Object.setPrototypeOf(obj, obj[interfaceName].prototype); + obj = exports.setup(obj, obj, constructorArgs, privateData); +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + if (globalObject.EventTarget === undefined) { + throw new Error(\\"Internal error: attempting to evaluate Window before EventTarget\\"); + } + class Window extends globalObject.EventTarget { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(Window.prototype, { [Symbol.toStringTag]: { value: \\"Window\\", configurable: true } }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = Window; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Window + }); +}; + +const Impl = require(\\"../implementations/Window.js\\"); +" +`; + exports[`without processors ZeroArgConstructor.webidl 1`] = ` "\\"use strict\\"; diff --git a/test/cases/Element.webidl b/test/cases/Element.webidl new file mode 100644 index 00000000..47812c8e --- /dev/null +++ b/test/cases/Element.webidl @@ -0,0 +1,14 @@ +// Simplified from https://dom.spec.whatwg.org/#element + +[Exposed=Window] +interface Element : Node { + readonly attribute DOMString? namespaceURI; + readonly attribute DOMString? prefix; + readonly attribute DOMString localName; + readonly attribute DOMString tagName; + + [CEReactions] attribute DOMString id; + [CEReactions] attribute DOMString className; + [SameObject, PutForwards=value] readonly attribute DOMTokenList classList; + [CEReactions, Unscopable] attribute DOMString slot; +}; diff --git a/test/cases/HTMLElement.webidl b/test/cases/HTMLElement.webidl new file mode 100644 index 00000000..527bafcf --- /dev/null +++ b/test/cases/HTMLElement.webidl @@ -0,0 +1,11 @@ +// Simplified from https://html.spec.whatwg.org/multipage/dom.html#htmlelement + +[Exposed=Window, + HTMLConstructor] +interface HTMLElement : Element { + // metadata attributes + [CEReactions] attribute DOMString title; + [CEReactions] attribute DOMString lang; + [CEReactions] attribute boolean translate; + [CEReactions] attribute DOMString dir; +}; diff --git a/test/cases/MultiGlobal.webidl b/test/cases/MultiGlobal.webidl new file mode 100644 index 00000000..02f03e87 --- /dev/null +++ b/test/cases/MultiGlobal.webidl @@ -0,0 +1,5 @@ +[Global=(Global1,Global2), + Exposed=(Global1,Global2)] +interface MultiGlobal { + [Unforgeable] readonly attribute MultiGlobal self; +}; diff --git a/test/cases/Node.webidl b/test/cases/Node.webidl new file mode 100644 index 00000000..89862673 --- /dev/null +++ b/test/cases/Node.webidl @@ -0,0 +1,33 @@ +// Simplified from https://dom.spec.whatwg.org/#node + +[Exposed=Window] +interface Node : EventTarget { + const unsigned short ELEMENT_NODE = 1; + const unsigned short ATTRIBUTE_NODE = 2; + const unsigned short TEXT_NODE = 3; + const unsigned short CDATA_SECTION_NODE = 4; + const unsigned short ENTITY_REFERENCE_NODE = 5; // historical + const unsigned short ENTITY_NODE = 6; // historical + const unsigned short PROCESSING_INSTRUCTION_NODE = 7; + const unsigned short COMMENT_NODE = 8; + const unsigned short DOCUMENT_NODE = 9; + const unsigned short DOCUMENT_TYPE_NODE = 10; + const unsigned short DOCUMENT_FRAGMENT_NODE = 11; + const unsigned short NOTATION_NODE = 12; // historical + readonly attribute unsigned short nodeType; + readonly attribute DOMString nodeName; + + readonly attribute USVString baseURI; + + readonly attribute boolean isConnected; + readonly attribute Document? ownerDocument; + Node getRootNode(optional GetRootNodeOptions options); + readonly attribute Node? parentNode; + readonly attribute Element? parentElement; + boolean hasChildNodes(); + [SameObject] readonly attribute NodeList childNodes; + readonly attribute Node? firstChild; + readonly attribute Node? lastChild; + readonly attribute Node? previousSibling; + readonly attribute Node? nextSibling; +}; diff --git a/test/cases/Window.webidl b/test/cases/Window.webidl new file mode 100644 index 00000000..6367df4e --- /dev/null +++ b/test/cases/Window.webidl @@ -0,0 +1,19 @@ +// Simplified from https://html.spec.whatwg.org/multipage/window-object.html#window +[Global=Window, + Exposed=Window, + LegacyUnenumerableNamedProperties] +interface Window : EventTarget { + // the current browsing context + [Unforgeable] readonly attribute WindowProxy window; + [Replaceable] readonly attribute WindowProxy self; + [Unforgeable] readonly attribute Document document; + attribute DOMString name; + [PutForwards=href, Unforgeable] readonly attribute Location location; + + // other browsing contexts + [Replaceable] readonly attribute WindowProxy frames; + [Replaceable] readonly attribute unsigned long length; + [Unforgeable] readonly attribute WindowProxy? top; + attribute any opener; + [Replaceable] readonly attribute WindowProxy? parent; +}; diff --git a/test/test.js b/test/test.js index 092338d0..63f9c068 100644 --- a/test/test.js +++ b/test/test.js @@ -97,6 +97,13 @@ describe("with processors", () => { } }); +test("webidl2js-globals.js", () => { + const outputFile = path.resolve(outputDir, "webidl2js-globals.js"); + const output = fs.readFileSync(outputFile, { encoding: "utf-8" }); + + expect(output).toMatchSnapshot(); +}); + test("utils.js", () => { const input = fs.readFileSync(path.resolve(rootDir, "lib/output/utils.js"), { encoding: "utf-8" }); const output = fs.readFileSync(path.resolve(outputDir, "utils.js"), { encoding: "utf-8" });