From fd2c9a09325cabc7b36b4e847307390f41f1c733 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sun, 3 Dec 2017 21:38:36 -0800 Subject: [PATCH 1/3] Split out some bits in Interface to the prototype --- lib/constructs/interface.js | 110 ++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 0665c6c7..8ef83a1c 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -502,54 +502,54 @@ class Interface { } } + _supportsPropertyIndex(O, index, indexedValue) { + let unsupportedValue = utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported"); + if (unsupportedValue) { + unsupportedValue = unsupportedValue.rhs.value; + } + if (unsupportedValue) { + const func = this.indexedGetter.name !== null ? `.${this.indexedGetter.name}` : "[utils.indexedGet]"; + const value = indexedValue || `${O}[impl]${func}(${index})`; + return `${value} !== ${unsupportedValue}`; + } + return `${O}[impl][utils.supportsPropertyIndex](${index})`; + } + + _supportsPropertyName(O, P, namedValue) { + let unsupportedValue = utils.getExtAttr(this.namedGetter.extAttrs, "WebIDL2JSValueAsUnsupported"); + if (unsupportedValue) { + unsupportedValue = unsupportedValue.rhs.value; + } + if (unsupportedValue) { + const func = this.namedGetter.name !== null ? `.${this.namedGetter.name}` : "[utils.namedGet]"; + const value = namedValue || `${O}[impl]${func}(${P})`; + return `${value} !== ${unsupportedValue}`; + } + return `${O}[impl][utils.supportsPropertyName](${P})`; + } + + // "named property visibility algorithm" + // If `supports` is true then skip the supportsPropertyName check. + _namedPropertyVisible(P, O, supports = false) { + const conditions = []; + if (!supports) { + conditions.push(this._supportsPropertyName(O, P)); + } + if (utils.getExtAttr(this.idl.extAttrs, "OverrideBuiltins")) { + conditions.push(`!utils.hasOwn(${O}, ${P})`); + } else { + // TODO: create a named properties object. + conditions.push(`!(${P} in ${O})`); + } + return conditions.join(" && "); + } + generateLegacyProxy() { const hasIndexedSetter = this.indexedSetter !== null; const hasNamedSetter = this.namedSetter !== null; const hasNamedDeleter = this.namedDeleter !== null; const overrideBuiltins = Boolean(utils.getExtAttr(this.idl.extAttrs, "OverrideBuiltins")); - const supportsPropertyIndex = (O, index, indexedValue) => { - let unsupportedValue = utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported"); - if (unsupportedValue) { - unsupportedValue = unsupportedValue.rhs.value; - } - if (unsupportedValue) { - const func = this.indexedGetter.name !== null ? `.${this.indexedGetter.name}` : "[utils.indexedGet]"; - const value = indexedValue || `${O}[impl]${func}(${index})`; - return `${value} !== ${unsupportedValue}`; - } - return `${O}[impl][utils.supportsPropertyIndex](${index})`; - }; - - const supportsPropertyName = (O, P, namedValue) => { - let unsupportedValue = utils.getExtAttr(this.namedGetter.extAttrs, "WebIDL2JSValueAsUnsupported"); - if (unsupportedValue) { - unsupportedValue = unsupportedValue.rhs.value; - } - if (unsupportedValue) { - const func = this.namedGetter.name !== null ? `.${this.namedGetter.name}` : "[utils.namedGet]"; - const value = namedValue || `${O}[impl]${func}(${P})`; - return `${value} !== ${unsupportedValue}`; - } - return `${O}[impl][utils.supportsPropertyName](${P})`; - }; - - // "named property visibility algorithm" - // If `supports` is true then skip the supportsPropertyName check. - function namedPropertyVisible(P, O, supports = false) { - const conditions = []; - if (!supports) { - conditions.push(supportsPropertyName(O, P)); - } - if (overrideBuiltins) { - conditions.push(`!utils.hasOwn(${O}, ${P})`); - } else { - // TODO: create a named properties object. - conditions.push(`!(${P} in ${O})`); - } - return conditions.join(" && "); - } - // "invoke an indexed property setter" const invokeIndexedSetter = (O, P, V) => { const arg = this.indexedSetter.arguments[1]; @@ -566,7 +566,7 @@ class Interface { if (this.indexedSetter.name === null) { str += ` - const creating = !(${supportsPropertyIndex(O, "index")}); + const creating = !(${this._supportsPropertyIndex(O, "index")}); if (creating) { ${O}[impl][utils.indexedSetNew](index, indexedValue); } else { @@ -597,7 +597,7 @@ class Interface { if (this.namedSetter.name === null) { str += ` - const creating = !(${supportsPropertyName(O, P)}); + const creating = !(${this._supportsPropertyName(O, P)}); if (creating) { ${O}[impl][utils.namedSetNew](${P}, namedValue); } else { @@ -677,7 +677,7 @@ class Interface { if (this.supportsNamedProperties) { this.str += ` for (const key of target[impl][utils.supportedPropertyNames]) { - if (${namedPropertyVisible("key", "target", true)}) { + if (${this._namedPropertyVisible("key", "target", true)}) { keys.add(\`\${key}\`); } } @@ -710,10 +710,10 @@ class Interface { let condition; if (utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) { this.str += `const indexedValue = target[impl]${func}(index);`; - condition = supportsPropertyIndex("target", "index", "indexedValue"); + condition = this._supportsPropertyIndex("target", "index", "indexedValue"); } else { preamble = `const indexedValue = target[impl]${func}(index);`; - condition = supportsPropertyIndex("target", "index"); + condition = this._supportsPropertyIndex("target", "index"); } this.str += ` @@ -739,13 +739,13 @@ class Interface { this.str += ` const namedValue = target[impl]${func}(P); `; - conditions.push(supportsPropertyName("target", "index", "namedValue")); - conditions.push(namedPropertyVisible("P", "target", true)); + conditions.push(this._supportsPropertyName("target", "index", "namedValue")); + conditions.push(this._namedPropertyVisible("P", "target", true)); } else { preamble = ` const namedValue = target[impl]${func}(P); `; - conditions.push(namedPropertyVisible("P", "target", false)); + conditions.push(this._namedPropertyVisible("P", "target", false)); } conditions.push("!ignoreNamedProps"); this.str += ` @@ -820,10 +820,10 @@ class Interface { let condition; if (utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) { this.str += `const indexedValue = target[impl]${func}(index);`; - condition = supportsPropertyIndex("target", "index", "indexedValue"); + condition = this._supportsPropertyIndex("target", "index", "indexedValue"); } else { preamble = `const indexedValue = target[impl]${func}(index);`; - condition = supportsPropertyIndex("target", "index"); + condition = this._supportsPropertyIndex("target", "index"); } this.str += ` @@ -922,7 +922,7 @@ class Interface { if (!hasNamedSetter) { needFallback = true; this.str += ` - const creating = !(${supportsPropertyName("target", "P")}); + const creating = !(${this._supportsPropertyName("target", "P")}); if (!creating) { return false; } @@ -972,13 +972,13 @@ class Interface { this.str += ` if (utils.isArrayIndexPropName(P)) { const index = P >>> 0; - return !(${supportsPropertyIndex("target", "index")}); + return !(${this._supportsPropertyIndex("target", "index")}); } `; } if (this.supportsNamedProperties && !utils.isGlobal(this.idl)) { this.str += ` - if (${namedPropertyVisible("P", "target")}) { + if (${this._namedPropertyVisible("P", "target")}) { `; if (!hasNamedDeleter) { this.str += ` From a37d959cf4e1fa5c15c816b4ac8f8374bb3ce40b Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 4 Dec 2017 11:35:38 -0800 Subject: [PATCH 2/3] Implement the named properties object --- lib/constructs/interface.js | 192 ++++++++++++++++++- test/__snapshots__/test.js.snap | 329 +++++++++++++++++++++++++++++++- 2 files changed, 512 insertions(+), 9 deletions(-) diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 8ef83a1c..a7b7975f 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -236,6 +236,10 @@ class Interface { throw new Error(msg); } } + + if (utils.isGlobal(this.idl) && this.namedGetter) { + this.factory = true; + } } get supportsIndexedProperties() { @@ -347,15 +351,19 @@ class Interface { `; } + if (utils.isGlobal(this.idl) && this.supportsNamedProperties) { + this.generateNamedPropertiesObject(); + this.str += `Object.setPrototypeOf(${this.name}.prototype, namedPropertiesObject);`; + } else if (this.idl.inheritance) { + this.str += `Object.setPrototypeOf(${this.name}.prototype, ${this.idl.inheritance}.interface.prototype);`; + } else if (utils.getExtAttr(this.idl.extAttrs, "LegacyArrayClass")) { + this.str += `Object.setPrototypeOf(${this.name}.prototype, Array.prototype);`; + } + if (this.idl.inheritance) { this.str += ` - Object.setPrototypeOf(${this.name}.prototype, ${this.idl.inheritance}.interface.prototype); Object.setPrototypeOf(${this.name}, ${this.idl.inheritance}.interface); `; - } else if (utils.getExtAttr(this.idl.extAttrs, "LegacyArrayClass")) { - this.str += ` - Object.setPrototypeOf(${this.name}.prototype, Array.prototype); - `; } this.str += ` @@ -544,6 +552,180 @@ class Interface { return conditions.join(" && "); } + generateNamedPropertiesObject() { + const proto = (() => { + if (this.idl.inheritance) { + return `${this.idl.inheritance}.interface.prototype`; + } else if (utils.getExtAttr(this.idl.extAttrs, "LegacyArrayClass")) { + return "Array.prototype"; + } + return "Object.prototype"; + })(); + + this.str += ` + const namedPropertiesObject = new Proxy(Object.create(${proto}, { + [Symbol.toStringTag]: { + value: "${this.name}Properties", + writable: false, + enumerable: false, + configurable: true + } + }), { + `; + + // [[SetPrototypeOf]] + this.str += ` + setPrototypeOf() { + throw new TypeError("Immutable prototype object '#<${this.name}Properties>' cannot have their prototype set"); + }, + `; + + // [[PreventExtensions]] + this.str += ` + preventExtensions() { + return false; + }, + `; + + // [[GetOwnProperty]] + this.str += ` + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + const object = defaultPrivateData.globalObject; + `; + + const func = this.namedGetter.name !== null ? `.${this.namedGetter.name}` : "[utils.namedGet]"; + const enumerable = !utils.getExtAttr(this.idl.extAttrs, "LegacyUnenumerableNamedProperties"); + let preamble = ""; + const conditions = []; + if (utils.getExtAttr(this.namedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) { + this.str += ` + const namedValue = object[impl]${func}(P); + `; + conditions.push(this._supportsPropertyName("object", "index", "namedValue")); + conditions.push(this._namedPropertyVisible("P", "object", true)); + } else { + preamble = ` + const namedValue = object[impl]${func}(P); + `; + conditions.push(this._namedPropertyVisible("P", "object", false)); + } + + this.str += ` + if (${conditions.join(" && ")}) { + ${preamble} + return { + writable: true, + enumerable: ${enumerable}, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + return Reflect.getOwnPropertyDescriptor(target, P); + }, + `; + + // [[DefineOwnProperty]] + this.str += ` + defineProperty() { + return false; + }, + `; + + // [[HasProperty]] + this.str += ` + 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]] + this.str += ` + 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, []); + }, + `; + + // [[Set]] + this.str += ` + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + const ownDesc = this.getOwnPropertyDescriptor(P); + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + // parent is never null. + return Reflect.set(parent, P, V, receiver); + } + // ownDesc.writable is always true. + if (!utils.isObject(receiver)) { + return false; + } + // If receiver is this Proxy object, the following will always return false. Problem is, receiver may not be + // this Proxy object. + 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); + }, + `; + + // [[Delete]] + this.str += ` + deleteProperty() { + return false; + }, + `; + + // [[OwnPropertyKeys]] not overriden + + this.str += ` + }); + `; + } + generateLegacyProxy() { const hasIndexedSetter = this.indexedSetter !== null; const hasNamedSetter = this.namedSetter !== null; diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 6eb64dc4..0928540c 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -534,9 +534,7 @@ const impl = utils.implSymbol; function LegacyArrayClass() { throw new TypeError(\\"Illegal constructor\\"); } - Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); - Object.defineProperty(LegacyArrayClass, \\"prototype\\", { value: LegacyArrayClass.prototype, writable: false, @@ -950,7 +948,6 @@ const MixinMixin = require(\\"./MixinMixin.js\\"); function Mixin() { throw new TypeError(\\"Illegal constructor\\"); } - Object.setPrototypeOf(Mixin.prototype, MixinInherited.interface.prototype); Object.setPrototypeOf(Mixin, MixinInherited.interface); @@ -1852,6 +1849,331 @@ const Impl = require(\\"../implementations/Overloads.js\\"); " `; +exports[`PrimaryGlobal.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const impl = utils.implSymbol; +const URL = require(\\"./URL.js\\"); + +module.exports = { + createInterface: function(defaultPrivateData = {}) { + function PrimaryGlobal() { + throw new TypeError(\\"Illegal constructor\\"); + } + + const namedPropertiesObject = new Proxy( + Object.create(URL.interface.prototype, { + [Symbol.toStringTag]: { + value: \\"PrimaryGlobalProperties\\", + writable: false, + enumerable: false, + configurable: true + } + }), + { + setPrototypeOf() { + throw new TypeError( + \\"Immutable prototype object '#' cannot have their prototype set\\" + ); + }, + + preventExtensions() { + return false; + }, + + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + const object = defaultPrivateData.globalObject; + + if (object[impl][utils.supportsPropertyName](P) && !(P in object)) { + const namedValue = object[impl][utils.namedGet](P); + + return { + writable: true, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + return Reflect.getOwnPropertyDescriptor(target, P); + }, + + defineProperty() { + return false; + }, + + 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(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, []); + }, + + set(target, P, V, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.set(target, P, V, receiver); + } + const ownDesc = this.getOwnPropertyDescriptor(P); + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + // parent is never null. + return Reflect.set(parent, P, V, receiver); + } + // ownDesc.writable is always true. + if (!utils.isObject(receiver)) { + return false; + } + // If receiver is this Proxy object, the following will always return false. Problem is, receiver may not be + // this Proxy object. + 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); + }, + + deleteProperty() { + return false; + } + } + ); + Object.setPrototypeOf(PrimaryGlobal.prototype, namedPropertiesObject); + Object.setPrototypeOf(PrimaryGlobal, URL.interface); + + Object.defineProperty(PrimaryGlobal, \\"prototype\\", { + value: PrimaryGlobal.prototype, + writable: false, + enumerable: false, + configurable: false + }); + + Object.defineProperty(PrimaryGlobal.prototype, Symbol.toStringTag, { + value: \\"PrimaryGlobal\\", + writable: false, + enumerable: false, + configurable: true + }); + + const iface = { + create(constructorArgs, privateData) { + let obj = Object.create(PrimaryGlobal.prototype); + obj = this.setup(obj, constructorArgs, privateData); + return obj; + }, + createImpl(constructorArgs, privateData) { + let obj = Object.create(PrimaryGlobal.prototype); + obj = this.setup(obj, constructorArgs, privateData); + return utils.implForWrapper(obj); + }, + _internalSetup(obj) { + URL._internalSetup(obj); + + obj.close = function close() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return this[impl].close(); + }; + + Object.defineProperty(obj, \\"name\\", { + get() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return obj[impl][\\"name\\"]; + }, + + set(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'name' property on 'PrimaryGlobal': The provided value\\" + }); + + obj[impl][\\"name\\"] = V; + }, + + enumerable: true, + configurable: true + }); + + Object.defineProperty(obj, \\"url\\", { + get() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(obj[impl][\\"url\\"]); + }, + + enumerable: true, + configurable: true + }); + + Object.defineProperty(obj, \\"unforgeableURL\\", { + get() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(obj[impl][\\"unforgeableURL\\"]); + }, + + enumerable: true, + configurable: false + }); + + Object.defineProperty(obj, \\"replaceableURLList\\", { + get() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return utils.tryWrapperForImpl(obj[impl][\\"replaceableURLList\\"]); + }, + + set(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + Object.defineProperty(this, \\"replaceableURLList\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + }, + + enumerable: true, + configurable: true + }); + }, + setup(obj, constructorArgs, privateData) { + if (!privateData) privateData = {}; + + for (var prop in defaultPrivateData) { + if (!(prop in privateData)) { + privateData[prop] = defaultPrivateData[prop]; + } + } + + privateData.wrapper = obj; + + this._internalSetup(obj); + Object.defineProperty(obj, impl, { + value: new Impl.implementation(constructorArgs, privateData), + writable: false, + enumerable: false, + configurable: true + }); + + obj[impl][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[impl], privateData); + } + return obj; + }, + interface: PrimaryGlobal, + expose: { + Window: { PrimaryGlobal } + } + }; // iface + return iface; + }, // createInterface + + // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` + // method into this array. It allows objects that directly implements *those* interfaces to be recognized as + // implementing this mixin interface. + _mixedIntoPredicates: [], + is(obj) { + if (obj) { + if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) { + return true; + } + for (const isMixedInto of module.exports._mixedIntoPredicates) { + if (isMixedInto(obj)) { + return true; + } + } + } + return false; + }, + isImpl(obj) { + if (obj) { + if (obj instanceof Impl.implementation) { + return true; + } + + const wrapper = utils.wrapperForImpl(obj); + for (const isMixedInto of module.exports._mixedIntoPredicates) { + if (isMixedInto(wrapper)) { + return true; + } + } + } + return false; + }, + convert(obj, { context = \\"The provided value\\" } = {}) { + if (module.exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'PrimaryGlobal'.\`); + } +}; // module.exports + +const Impl = require(\\"../implementations/PrimaryGlobal.js\\"); +" +`; + exports[`PromiseTypes.webidl 1`] = ` "\\"use strict\\"; @@ -5669,7 +5991,6 @@ const URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); function URLSearchParamsCollection2() { throw new TypeError(\\"Illegal constructor\\"); } - Object.setPrototypeOf(URLSearchParamsCollection2.prototype, URLSearchParamsCollection.interface.prototype); Object.setPrototypeOf(URLSearchParamsCollection2, URLSearchParamsCollection.interface); From 6ddc0f385b323c27b0aee421db73ddb118c8e103 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 4 Dec 2017 23:38:09 -0800 Subject: [PATCH 3/3] fixes --- lib/constructs/interface.js | 58 +- lib/constructs/operation.js | 17 +- test/__snapshots__/test.js.snap | 3206 +++++++++++++++++-------------- test/cases/PrimaryGlobal.webidl | 11 + 4 files changed, 1795 insertions(+), 1497 deletions(-) create mode 100644 test/cases/PrimaryGlobal.webidl diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index a7b7975f..91092b88 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -237,7 +237,7 @@ class Interface { } } - if (utils.isGlobal(this.idl) && this.namedGetter) { + if (this.hasNamedPropertiesObject) { this.factory = true; } } @@ -250,6 +250,10 @@ class Interface { return this.namedGetter !== null; } + get hasNamedPropertiesObject() { + return utils.isGlobal(this.idl) && this.supportsNamedProperties; + } + get isLegacyPlatformObj() { return !utils.isGlobal(this.idl) && (this.supportsIndexedProperties || this.supportsNamedProperties); } @@ -351,7 +355,7 @@ class Interface { `; } - if (utils.isGlobal(this.idl) && this.supportsNamedProperties) { + if (this.hasNamedPropertiesObject) { this.generateNamedPropertiesObject(); this.str += `Object.setPrototypeOf(${this.name}.prototype, namedPropertiesObject);`; } else if (this.idl.inheritance) { @@ -545,8 +549,21 @@ class Interface { } if (utils.getExtAttr(this.idl.extAttrs, "OverrideBuiltins")) { conditions.push(`!utils.hasOwn(${O}, ${P})`); + } else if (this.hasNamedPropertiesObject) { + conditions.push(`!utils.hasOwn(${O}, ${P})`); + conditions.push(` + (() => { + let prototype = Object.getPrototypeOf(${O}); + while (prototype !== null) { + if (prototype !== namedPropertiesObject && utils.hasOwn(${O}, ${P})) { + return false; + } + prototype = Object.getPrototypeOf(prototype); + } + return true; + })() + `); } else { - // TODO: create a named properties object. conditions.push(`!(${P} in ${O})`); } return conditions.join(" && "); @@ -563,6 +580,7 @@ class Interface { })(); this.str += ` + const namedPropertiesObjectHandlersPlaceholder = {}; const namedPropertiesObject = new Proxy(Object.create(${proto}, { [Symbol.toStringTag]: { value: "${this.name}Properties", @@ -570,7 +588,8 @@ class Interface { enumerable: false, configurable: true } - }), { + }), namedPropertiesObjectHandlersPlaceholder); + const namedPropertiesObjectHandlers = { `; // [[SetPrototypeOf]] @@ -661,19 +680,11 @@ class Interface { 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; + // parent is never null. + return Reflect.get(parent, P, receiver); } - return Reflect.apply(getter, receiver, []); + // Named properties object only has data properties. + return desc.value; }, `; @@ -683,7 +694,7 @@ class Interface { if (typeof P === "symbol") { return Reflect.set(target, P, V, receiver); } - const ownDesc = this.getOwnPropertyDescriptor(P); + const ownDesc = this.getOwnPropertyDescriptor(target, P); if (ownDesc === undefined) { const parent = Reflect.getPrototypeOf(target); // parent is never null. @@ -722,7 +733,7 @@ class Interface { // [[OwnPropertyKeys]] not overriden this.str += ` - }); + }; `; } @@ -811,7 +822,7 @@ class Interface { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -1229,6 +1240,15 @@ class Interface { exposers.push(keys[i] + ": { " + exposedMap[keys[i]].join(", ") + " }"); } + if (this.hasNamedPropertiesObject) { + this.str += ` + enableNamedPropertiesObject(globalObject) { + defaultPrivateData.globalObject = globalObject; + Object.assign(namedPropertiesObjectHandlers, namedPropertiesObjectHandlersPlaceholder); + }, + `; + } + this.str += ` create(constructorArgs, privateData) { let obj = Object.create(${this.name}.prototype); diff --git a/lib/constructs/operation.js b/lib/constructs/operation.js index 2d0794e5..f1dbd6ea 100644 --- a/lib/constructs/operation.js +++ b/lib/constructs/operation.js @@ -66,7 +66,11 @@ class Operation { const argNames = minOp.nameList.map(name => (keywords.has(name) ? "_" : "") + name); str += ` - ${targetObj}.${this.name} = function ${fnName}(${argNames.join(", ")}) { + Object.defineProperty(${targetObj}, ${JSON.stringify(this.name)}, { + writable: true, + enumerable: true, + configurable: true, + value: function ${fnName}(${argNames.join(", ")}) { `; if (!this.static) { str += ` @@ -88,16 +92,11 @@ class Operation { str += parameterConversions.body; if (overloads.every(overload => conversions[overload.operation.idlType.idlType])) { - str += ` - return ${callOn}.${implFunc}(${argsSpread}); - }; - `; + str += `return ${callOn}.${implFunc}(${argsSpread});`; } else { - str += ` - return utils.tryWrapperForImpl(${callOn}.${implFunc}(${argsSpread})); - }; - `; + str += `return utils.tryWrapperForImpl(${callOn}.${implFunc}(${argsSpread}));`; } + str += "}});"; return { requires, diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 0928540c..18a1f5ab 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -100,28 +100,32 @@ Object.defineProperty(DictionaryConvert, \\"prototype\\", { configurable: false }); -DictionaryConvert.prototype.op = function op() { - if (!this || !module.exports.is(this)) { - 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\\" - }); +Object.defineProperty(DictionaryConvert.prototype, \\"op\\", { + writable: true, + enumerable: true, + configurable: true, + value: function op() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); } - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = convertDictionary(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); - args.push(curArg); + 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 = convertDictionary(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); + args.push(curArg); + } + return this[impl].op(...args); } - return this[impl].op(...args); -}; - +}); Object.defineProperty(DictionaryConvert.prototype, Symbol.toStringTag, { value: \\"DictionaryConvert\\", writable: false, @@ -231,25 +235,29 @@ Object.defineProperty(Enum, \\"prototype\\", { configurable: false }); -Enum.prototype.op = function op(destination) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(Enum.prototype, \\"op\\", { + writable: true, + enumerable: true, + configurable: true, + value: function op(destination) { + if (!this || !module.exports.is(this)) { + 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 = convertRequestDestination(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); - 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[0]; + curArg = convertRequestDestination(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); + args.push(curArg); + } + return this[impl].op(...args); } - return this[impl].op(...args); -}; - +}); Object.defineProperty(Enum.prototype, \\"attr\\", { get() { if (!this || !module.exports.is(this)) { @@ -385,14 +393,17 @@ module.exports = { configurable: false }); - Factory.prototype.method = function method() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + Object.defineProperty(Factory.prototype, \\"method\\", { + writable: true, + enumerable: true, + configurable: true, + value: function method() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].method(); } - - return this[impl].method(); - }; - + }); Object.defineProperty(Factory.prototype, \\"attribute\\", { get() { if (!this || !module.exports.is(this)) { @@ -665,46 +676,61 @@ Object.defineProperty(MixedIn, \\"prototype\\", { configurable: false }); -MixedIn.prototype.mixedInOp = function mixedInOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(MixedIn.prototype, \\"mixedInOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixedInOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixedInOp(); } - - return this[impl].mixedInOp(); -}; - -MixedIn.prototype.mixinOp = function mixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(MixedIn.prototype, \\"mixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinOp(); } - - return this[impl].mixinOp(); -}; - -MixedIn.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(MixedIn.prototype, \\"mixinMixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinMixinOp(); } - - return this[impl].mixinMixinOp(); -}; - -MixedIn.prototype.mixinInheritedOp = function mixinInheritedOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(MixedIn.prototype, \\"mixinInheritedOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinInheritedOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinInheritedOp(); } - - return this[impl].mixinInheritedOp(); -}; - -MixedIn.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(MixedIn.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinInheritedOp(); } - - return this[impl].mixinInheritedOp(); -}; - +}); Object.defineProperty(MixedIn.prototype, \\"mixedInAttr\\", { get() { if (!this || !module.exports.is(this)) { @@ -958,22 +984,28 @@ Object.defineProperty(Mixin, \\"prototype\\", { configurable: false }); -Mixin.prototype.mixinOp = function mixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(Mixin.prototype, \\"mixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinOp(); } - - return this[impl].mixinOp(); -}; - -Mixin.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(Mixin.prototype, \\"mixinMixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinMixinOp(); } - - return this[impl].mixinMixinOp(); -}; - +}); Object.defineProperty(Mixin.prototype, \\"mixinAttr\\", { get() { if (!this || !module.exports.is(this)) { @@ -1151,22 +1183,28 @@ Object.defineProperty(MixinInherited, \\"prototype\\", { configurable: false }); -MixinInherited.prototype.mixinInheritedOp = function mixinInheritedOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(MixinInherited.prototype, \\"mixinInheritedOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinInheritedOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinInheritedOp(); } - - return this[impl].mixinInheritedOp(); -}; - -MixinInherited.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(MixinInherited.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinInheritedOp(); } - - return this[impl].mixinInheritedOp(); -}; - +}); Object.defineProperty(MixinInherited.prototype, \\"mixinInheritedAttr\\", { get() { if (!this || !module.exports.is(this)) { @@ -1306,14 +1344,17 @@ Object.defineProperty(MixinMixin, \\"prototype\\", { configurable: false }); -MixinMixin.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(MixinMixin.prototype, \\"mixinMixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinMixinOp(); } - - return this[impl].mixinMixinOp(); -}; - +}); Object.defineProperty(MixinMixin.prototype, \\"mixinMixinAttr\\", { get() { if (!this || !module.exports.is(this)) { @@ -1483,284 +1524,304 @@ Object.defineProperty(Overloads, \\"prototype\\", { configurable: false }); -Overloads.prototype.compatible = function compatible(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(Overloads.prototype, \\"compatible\\", { + writable: true, + enumerable: true, + configurable: true, + value: function compatible(arg1) { + if (!this || !module.exports.is(this)) { + 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\\" + 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\\" }); - } else { - curArg = 0; + args.push(curArg); } - args.push(curArg); - } - } - return utils.tryWrapperForImpl(this[impl].compatible(...args)); -}; - -Overloads.prototype.incompatible1 = function incompatible1(arg1) { - if (!this || !module.exports.is(this)) { - 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 this[impl].incompatible1(...args); -}; - -Overloads.prototype.incompatible2 = function incompatible2(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + 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(this[impl].compatible(...args)); } +}); +Object.defineProperty(Overloads.prototype, \\"incompatible1\\", { + writable: true, + enumerable: true, + configurable: true, + value: function incompatible1(arg1) { + if (!this || !module.exports.is(this)) { + 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); + 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 this[impl].incompatible1(...args); } - return this[impl].incompatible2(...args); -}; +}); +Object.defineProperty(Overloads.prototype, \\"incompatible2\\", { + writable: true, + enumerable: true, + configurable: true, + value: function incompatible2(arg1) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Overloads.prototype.incompatible3 = function incompatible3(arg1) { - if (!this || !module.exports.is(this)) { - 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 this[impl].incompatible2(...args); } +}); +Object.defineProperty(Overloads.prototype, \\"incompatible3\\", { + writable: true, + enumerable: true, + configurable: true, + value: function incompatible3(arg1) { + if (!this || !module.exports.is(this)) { + 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 = convertURL(curArg, { context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" }); + 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 = convertURL(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); } - args.push(curArg); - } - } else if (isURL(curArg)) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = convertURL(curArg, { context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" }); + } else if (isURL(curArg)) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = convertURL(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); } - args.push(curArg); - } - } else if ( - curArg instanceof ArrayBuffer || - (typeof SharedArrayBuffer !== \\"undefined\\" && curArg instanceof SharedArrayBuffer) - ) { - { - let curArg = arguments[1]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); + } else if ( + curArg instanceof ArrayBuffer || + (typeof SharedArrayBuffer !== \\"undefined\\" && curArg instanceof SharedArrayBuffer) + ) { + { + let curArg = arguments[1]; + if (curArg instanceof ArrayBuffer) { + } 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); } - args.push(curArg); - } - } else if (ArrayBuffer.isView(curArg)) { - { - let curArg = arguments[1]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[1]; + if (curArg instanceof ArrayBuffer) { + } 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); } - 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 (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" - ); + 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); } - args.push(curArg); - } - { - let curArg = arguments[3]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" - ); + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); } - args.push(curArg); - } + { + let curArg = arguments[2]; + if (curArg instanceof ArrayBuffer) { + } 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 (curArg instanceof ArrayBuffer) { + } 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 this[impl].incompatible3(...args); } - return this[impl].incompatible3(...args); -}; - +}); Object.defineProperty(Overloads.prototype, Symbol.toStringTag, { value: \\"Overloads\\", writable: false, @@ -1864,6 +1925,7 @@ module.exports = { throw new TypeError(\\"Illegal constructor\\"); } + const namedPropertiesObjectHandlersPlaceholder = {}; const namedPropertiesObject = new Proxy( Object.create(URL.interface.prototype, { [Symbol.toStringTag]: { @@ -1873,114 +1935,118 @@ module.exports = { configurable: true } }), - { - setPrototypeOf() { - throw new TypeError( - \\"Immutable prototype object '#' cannot have their prototype set\\" - ); - }, + namedPropertiesObjectHandlersPlaceholder + ); + const namedPropertiesObjectHandlers = { + setPrototypeOf() { + throw new TypeError(\\"Immutable prototype object '#' cannot have their prototype set\\"); + }, - preventExtensions() { - return false; - }, + preventExtensions() { + return false; + }, - getOwnPropertyDescriptor(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.getOwnPropertyDescriptor(target, P); - } - const object = defaultPrivateData.globalObject; + getOwnPropertyDescriptor(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + const object = defaultPrivateData.globalObject; - if (object[impl][utils.supportsPropertyName](P) && !(P in object)) { - const namedValue = object[impl][utils.namedGet](P); + if ( + object[impl][utils.supportsPropertyName](P) && + !utils.hasOwn(object, P) && + (() => { + let prototype = Object.getPrototypeOf(object); + while (prototype !== null) { + if (prototype !== namedPropertiesObject && utils.hasOwn(object, P)) { + return false; + } + prototype = Object.getPrototypeOf(prototype); + } + return true; + })() + ) { + const namedValue = object[impl][utils.namedGet](P); - return { - writable: true, - enumerable: false, - configurable: true, - value: utils.tryWrapperForImpl(namedValue) - }; - } - return Reflect.getOwnPropertyDescriptor(target, P); - }, + return { + writable: true, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + return Reflect.getOwnPropertyDescriptor(target, P); + }, - defineProperty() { - return false; - }, + defineProperty() { + return false; + }, - 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; - }, + 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(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, []); - }, + 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); + // parent is never null. + return Reflect.get(parent, P, receiver); + } + // Named properties object only has data properties. + return desc.value; + }, - set(target, P, V, receiver) { - if (typeof P === \\"symbol\\") { - return Reflect.set(target, P, V, receiver); - } - const ownDesc = this.getOwnPropertyDescriptor(P); - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - // parent is never null. - return Reflect.set(parent, P, V, receiver); - } - // ownDesc.writable is always true. - if (!utils.isObject(receiver)) { + set(target, P, V, receiver) { + if (typeof P === \\"symbol\\") { + return Reflect.set(target, P, V, receiver); + } + const ownDesc = this.getOwnPropertyDescriptor(target, P); + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + // parent is never null. + return Reflect.set(parent, P, V, receiver); + } + // ownDesc.writable is always true. + if (!utils.isObject(receiver)) { + return false; + } + // If receiver is this Proxy object, the following will always return false. Problem is, receiver may not be + // this Proxy object. + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { return false; } - // If receiver is this Proxy object, the following will always return false. Problem is, receiver may not be - // this Proxy object. - 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 }; + if (!existingDesc.writable) { + return false; } - return Reflect.defineProperty(receiver, P, valueDesc); - }, - - deleteProperty() { - return false; + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; } + return Reflect.defineProperty(receiver, P, valueDesc); + }, + + deleteProperty() { + return false; } - ); + }; Object.setPrototypeOf(PrimaryGlobal.prototype, namedPropertiesObject); Object.setPrototypeOf(PrimaryGlobal, URL.interface); @@ -1999,6 +2065,11 @@ module.exports = { }); const iface = { + enableNamedPropertiesObject(globalObject) { + defaultPrivateData.globalObject = globalObject; + Object.assign(namedPropertiesObjectHandlers, namedPropertiesObjectHandlersPlaceholder); + }, + create(constructorArgs, privateData) { let obj = Object.create(PrimaryGlobal.prototype); obj = this.setup(obj, constructorArgs, privateData); @@ -2012,14 +2083,17 @@ module.exports = { _internalSetup(obj) { URL._internalSetup(obj); - obj.close = function close() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + Object.defineProperty(obj, \\"close\\", { + writable: true, + enumerable: true, + configurable: true, + value: function close() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].close(); } - - return this[impl].close(); - }; - + }); Object.defineProperty(obj, \\"name\\", { get() { if (!this || !module.exports.is(this)) { @@ -2193,54 +2267,62 @@ Object.defineProperty(PromiseTypes, \\"prototype\\", { configurable: false }); -PromiseTypes.prototype.voidPromiseConsumer = function voidPromiseConsumer(p) { - if (!this || !module.exports.is(this)) { - 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 this[impl].voidPromiseConsumer(...args); -}; +Object.defineProperty(PromiseTypes.prototype, \\"voidPromiseConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function voidPromiseConsumer(p) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -PromiseTypes.prototype.promiseConsumer = function promiseConsumer(p) { - if (!this || !module.exports.is(this)) { - 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 this[impl].voidPromiseConsumer(...args); } +}); +Object.defineProperty(PromiseTypes.prototype, \\"promiseConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function promiseConsumer(p) { + if (!this || !module.exports.is(this)) { + 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\\" - }); + 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 value; + }, reason => reason); + args.push(curArg); + } + return this[impl].promiseConsumer(...args); } - return this[impl].promiseConsumer(...args); -}; - +}); Object.defineProperty(PromiseTypes.prototype, Symbol.toStringTag, { value: \\"PromiseTypes\\", writable: false, @@ -2656,199 +2738,219 @@ Object.defineProperty(SeqAndRec, \\"prototype\\", { configurable: false }); -SeqAndRec.prototype.recordConsumer = function recordConsumer(rec) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(SeqAndRec.prototype, \\"recordConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function recordConsumer(rec) { + if (!this || !module.exports.is(this)) { + 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; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); + 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; + let typedValue = curArg[key]; - typedValue = conversions[\\"double\\"](typedValue, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); + + typedValue = conversions[\\"double\\"](typedValue, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); - result[typedKey] = typedValue; + result[typedKey] = typedValue; + } } + curArg = result; } - curArg = result; + args.push(curArg); } - args.push(curArg); + return this[impl].recordConsumer(...args); } - return this[impl].recordConsumer(...args); -}; +}); +Object.defineProperty(SeqAndRec.prototype, \\"recordConsumer2\\", { + writable: true, + enumerable: true, + configurable: true, + value: function recordConsumer2(rec) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -SeqAndRec.prototype.recordConsumer2 = function recordConsumer2(rec) { - if (!this || !module.exports.is(this)) { - 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; + let typedValue = curArg[key]; - 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; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); - typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); + typedValue = convertURL(typedValue, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); - result[typedKey] = typedValue; + result[typedKey] = typedValue; + } } + curArg = result; } - curArg = result; + args.push(curArg); } - args.push(curArg); - } - return this[impl].recordConsumer2(...args); -}; - -SeqAndRec.prototype.sequenceConsumer = function sequenceConsumer(seq) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].recordConsumer2(...args); } +}); +Object.defineProperty(SeqAndRec.prototype, \\"sequenceConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function sequenceConsumer(seq) { + if (!this || !module.exports.is(this)) { + 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)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } 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 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); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); - } - return this[impl].sequenceConsumer(...args); -}; - -SeqAndRec.prototype.sequenceConsumer2 = function sequenceConsumer2(seq) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].sequenceConsumer(...args); } +}); +Object.defineProperty(SeqAndRec.prototype, \\"sequenceConsumer2\\", { + writable: true, + enumerable: true, + configurable: true, + value: function sequenceConsumer2(seq) { + if (!this || !module.exports.is(this)) { + 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)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = utils.tryImplForWrapper(nextItem); + } + 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); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); - } - return this[impl].sequenceConsumer2(...args); -}; - -SeqAndRec.prototype.frozenArrayConsumer = function frozenArrayConsumer(arr) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].sequenceConsumer2(...args); } +}); +Object.defineProperty(SeqAndRec.prototype, \\"frozenArrayConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function frozenArrayConsumer(arr) { + if (!this || !module.exports.is(this)) { + 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)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } 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\\" - }); + } + 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); + V.push(nextItem); + } + curArg = V; } - curArg = V; + curArg = Object.freeze(curArg); + args.push(curArg); } - curArg = Object.freeze(curArg); - args.push(curArg); + return this[impl].frozenArrayConsumer(...args); } - return this[impl].frozenArrayConsumer(...args); -}; - +}); Object.defineProperty(SeqAndRec.prototype, Symbol.toStringTag, { value: \\"SeqAndRec\\", writable: false, @@ -2956,18 +3058,25 @@ Object.defineProperty(Static, \\"prototype\\", { configurable: false }); -Static.prototype.def = function def() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(Static.prototype, \\"def\\", { + writable: true, + enumerable: true, + configurable: true, + value: function def() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].def(); } - - return this[impl].def(); -}; - -Static.def = function def() { - return Impl.implementation.def(); -}; - +}); +Object.defineProperty(Static, \\"def\\", { + writable: true, + enumerable: true, + configurable: true, + value: function def() { + return Impl.implementation.def(); + } +}); Object.defineProperty(Static.prototype, \\"abc\\", { get() { if (!this || !module.exports.is(this)) { @@ -3097,111 +3206,132 @@ const Impl = require(\\"../implementations/Static.js\\"); exports[`Storage.webidl 1`] = ` "\\"use strict\\"; -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const impl = utils.implSymbol; - -function Storage() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Storage, \\"prototype\\", { - value: Storage.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Storage.prototype.key = function key(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'key' on 'Storage': 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\\" }); - args.push(curArg); - } - return this[impl].key(...args); -}; +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); -Storage.prototype.getItem = function getItem(key) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +const impl = utils.implSymbol; - 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 this[impl].getItem(...args); -}; +function Storage() { + throw new TypeError(\\"Illegal constructor\\"); +} -Storage.prototype.setItem = function setItem(key, value) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(Storage, \\"prototype\\", { + value: Storage.prototype, + writable: false, + enumerable: false, + configurable: false +}); - 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 this[impl].setItem(...args); -}; +Object.defineProperty(Storage.prototype, \\"key\\", { + writable: true, + enumerable: true, + configurable: true, + value: function key(index) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.removeItem = function removeItem(key) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'key' on 'Storage': 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\\" }); + args.push(curArg); + } + return this[impl].key(...args); } +}); +Object.defineProperty(Storage.prototype, \\"getItem\\", { + writable: true, + enumerable: true, + configurable: true, + value: function getItem(key) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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); + 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 this[impl].getItem(...args); } - return this[impl].removeItem(...args); -}; +}); +Object.defineProperty(Storage.prototype, \\"setItem\\", { + writable: true, + enumerable: true, + configurable: true, + value: function setItem(key, value) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.clear = function clear() { - if (!this || !module.exports.is(this)) { - 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.\\" + ); + } + 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 this[impl].setItem(...args); } +}); +Object.defineProperty(Storage.prototype, \\"removeItem\\", { + writable: true, + enumerable: true, + configurable: true, + value: function removeItem(key) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return this[impl].clear(); -}; - + 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 this[impl].removeItem(...args); + } +}); +Object.defineProperty(Storage.prototype, \\"clear\\", { + writable: true, + enumerable: true, + configurable: true, + value: function clear() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].clear(); + } +}); Object.defineProperty(Storage.prototype, \\"length\\", { get() { if (!this || !module.exports.is(this)) { @@ -3297,7 +3427,7 @@ const iface = { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -3613,14 +3743,17 @@ Object.defineProperty(StringifierDefaultOperation, \\"prototype\\", { configurable: false }); -StringifierDefaultOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(StringifierDefaultOperation.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].toString(); } - - return this[impl].toString(); -}; - +}); Object.defineProperty(StringifierDefaultOperation.prototype, Symbol.toStringTag, { value: \\"StringifierDefaultOperation\\", writable: false, @@ -3728,22 +3861,28 @@ Object.defineProperty(StringifierNamedOperation, \\"prototype\\", { configurable: false }); -StringifierNamedOperation.prototype.operation = function operation() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(StringifierNamedOperation.prototype, \\"operation\\", { + writable: true, + enumerable: true, + configurable: true, + value: function operation() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].operation(); } - - return this[impl].operation(); -}; - -StringifierNamedOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(StringifierNamedOperation.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].operation(); } - - return this[impl].operation(); -}; - +}); Object.defineProperty(StringifierNamedOperation.prototype, Symbol.toStringTag, { value: \\"StringifierNamedOperation\\", writable: false, @@ -3851,14 +3990,17 @@ Object.defineProperty(StringifierOperation, \\"prototype\\", { configurable: false }); -StringifierOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(StringifierOperation.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].toString(); } - - return this[impl].toString(); -}; - +}); Object.defineProperty(StringifierOperation.prototype, Symbol.toStringTag, { value: \\"StringifierOperation\\", writable: false, @@ -3969,209 +4111,181 @@ Object.defineProperty(TypedefsAndUnions, \\"prototype\\", { configurable: false }); -TypedefsAndUnions.prototype.numOrStrConsumer = function numOrStrConsumer(a) { - if (!this || !module.exports.is(this)) { - 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 this[impl].numOrStrConsumer(...args); -}; - -TypedefsAndUnions.prototype.numOrEnumConsumer = function numOrEnumConsumer(a) { - if (!this || !module.exports.is(this)) { - 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 = convertRequestDestination(curArg, { - context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" - }); - } - } - args.push(curArg); - } - return this[impl].numOrEnumConsumer(...args); -}; - -TypedefsAndUnions.prototype.numOrStrOrNullConsumer = function numOrStrOrNullConsumer(a) { - if (!this || !module.exports.is(this)) { - 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.\\" - ); - } - 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 - }); - } +Object.defineProperty(TypedefsAndUnions.prototype, \\"numOrStrConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function numOrStrConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); } - args.push(curArg); - } - return this[impl].numOrStrOrNullConsumer(...args); -}; -TypedefsAndUnions.prototype.numOrStrOrURLOrNullConsumer = function numOrStrOrURLOrNullConsumer(a) { - if (!this || !module.exports.is(this)) { - 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 (isURL(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (typeof curArg === \\"number\\") { + 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 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true, - enforceRange: true + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true }); } else { curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - enforceRange: true + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\" }); } + args.push(curArg); } - args.push(curArg); + return this[impl].numOrStrConsumer(...args); } - return this[impl].numOrStrOrURLOrNullConsumer(...args); -}; +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"numOrEnumConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function numOrEnumConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -TypedefsAndUnions.prototype.urlMapInnerConsumer = function urlMapInnerConsumer(a) { - if (!this || !module.exports.is(this)) { - 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 = convertRequestDestination(curArg, { + context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } + } + args.push(curArg); + } + return this[impl].numOrEnumConsumer(...args); } +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"numOrStrOrNullConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function numOrStrOrNullConsumer(a) { + if (!this || !module.exports.is(this)) { + 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } 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 typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + } + 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 }); - - typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + enforceRange: true }); - - result[typedKey] = typedValue; } } - curArg = result; + args.push(curArg); } - args.push(curArg); + return this[impl].numOrStrOrNullConsumer(...args); } - return this[impl].urlMapInnerConsumer(...args); -}; +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"numOrStrOrURLOrNullConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function numOrStrOrURLOrNullConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { - if (!this || !module.exports.is(this)) { - 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 (isURL(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 this[impl].numOrStrOrURLOrNullConsumer(...args); } +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"urlMapInnerConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function urlMapInnerConsumer(a) { + if (!this || !module.exports.is(this)) { + 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; if (!utils.isObject(curArg)) { throw new TypeError( - \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" ); } else { const result = Object.create(null); @@ -4182,11 +4296,11 @@ TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { let typedValue = curArg[key]; typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" }); typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" }); result[typedKey] = typedValue; @@ -4194,67 +4308,36 @@ TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { } curArg = result; } + args.push(curArg); } - args.push(curArg); - } - return this[impl].urlMapConsumer(...args); -}; - -TypedefsAndUnions.prototype.bufferSourceOrURLConsumer = function bufferSourceOrURLConsumer(b) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].urlMapInnerConsumer(...args); } +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"urlMapConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function urlMapConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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 (isURL(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } - args.push(curArg); - } - return this[impl].bufferSourceOrURLConsumer(...args); -}; - -TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBufferViewOrURLMapConsumer(b) { - if (!this || !module.exports.is(this)) { - 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)) { + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { if (!utils.isObject(curArg)) { throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\" is not an object.\\" + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" ); } else { const result = Object.create(null); @@ -4265,17 +4348,11 @@ TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBuff let typedValue = curArg[key]; typedKey = conversions[\\"USVString\\"](typedKey, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s key\\" + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" }); typedValue = convertURL(typedValue, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s value\\" + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" }); result[typedKey] = typedValue; @@ -4283,45 +4360,146 @@ TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBuff } curArg = result; } + } + args.push(curArg); + } + return this[impl].urlMapConsumer(...args); + } +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"bufferSourceOrURLConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function bufferSourceOrURLConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + 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 (isURL(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { } else { throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not of any supported type.\\" ); } + args.push(curArg); } - args.push(curArg); + return this[impl].bufferSourceOrURLConsumer(...args); } - return this[impl].arrayBufferViewOrURLMapConsumer(...args); -}; +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"arrayBufferViewOrURLMapConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function arrayBufferViewOrURLMapConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -TypedefsAndUnions.prototype.arrayBufferViewDupConsumer = function arrayBufferViewDupConsumer(b) { - if (!this || !module.exports.is(this)) { - 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; + let typedValue = curArg[key]; - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + typedKey = conversions[\\"USVString\\"](typedKey, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s key\\" + }); + + typedValue = convertURL(typedValue, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s value\\" + }); + + 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 this[impl].arrayBufferViewOrURLMapConsumer(...args); } - const args = []; - { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg)) { - } else { +}); +Object.defineProperty(TypedefsAndUnions.prototype, \\"arrayBufferViewDupConsumer\\", { + writable: true, + enumerable: true, + configurable: true, + value: function arrayBufferViewDupConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" + \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } - args.push(curArg); + 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 this[impl].arrayBufferViewDupConsumer(...args); } - return this[impl].arrayBufferViewDupConsumer(...args); -}; - +}); Object.defineProperty(TypedefsAndUnions.prototype, \\"buf\\", { get() { if (!this || !module.exports.is(this)) { @@ -4505,14 +4683,17 @@ Object.defineProperty(URL, \\"prototype\\", { configurable: false }); -URL.prototype.toJSON = function toJSON() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +Object.defineProperty(URL.prototype, \\"toJSON\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].toJSON(); } - - return this[impl].toJSON(); -}; - +}); Object.defineProperty(URL.prototype, \\"href\\", { get() { if (!this || !module.exports.is(this)) { @@ -4893,25 +5074,29 @@ Object.defineProperty(URLList.prototype, Symbol.iterator, { value: Array.prototype[Symbol.iterator] }); URLList.prototype.forEach = Array.prototype.forEach; -URLList.prototype.item = function item(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" }); - args.push(curArg); - } - return utils.tryWrapperForImpl(this[impl].item(...args)); -}; +Object.defineProperty(URLList.prototype, \\"item\\", { + writable: true, + enumerable: true, + configurable: true, + value: function item(index) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].item(...args)); + } +}); URLList.prototype.entries = Array.prototype.entries; URLList.prototype.keys = Array.prototype.keys; URLList.prototype.values = Array.prototype[Symbol.iterator]; @@ -5011,7 +5196,7 @@ const iface = { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -5353,156 +5538,198 @@ URLSearchParams.prototype.forEach = function forEach(callback) { i++; } }; -URLSearchParams.prototype.append = function append(name, value) { - if (!this || !module.exports.is(this)) { - 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.\\" - ); - } - 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 this[impl].append(...args); -}; - -URLSearchParams.prototype.delete = function _delete(name) { - if (!this || !module.exports.is(this)) { - 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - return this[impl].delete(...args); -}; - -URLSearchParams.prototype.get = function get(name) { - if (!this || !module.exports.is(this)) { - 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" }); - args.push(curArg); - } - return this[impl].get(...args); -}; +Object.defineProperty(URLSearchParams.prototype, \\"append\\", { + writable: true, + enumerable: true, + configurable: true, + value: function append(name, value) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLSearchParams.prototype.getAll = function getAll(name) { - if (!this || !module.exports.is(this)) { - 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.\\" + ); + } + 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 this[impl].append(...args); } +}); +Object.defineProperty(URLSearchParams.prototype, \\"delete\\", { + writable: true, + enumerable: true, + configurable: true, + value: function _delete(name) { + if (!this || !module.exports.is(this)) { + 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + 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 this[impl].delete(...args); } - return utils.tryWrapperForImpl(this[impl].getAll(...args)); -}; +}); +Object.defineProperty(URLSearchParams.prototype, \\"get\\", { + writable: true, + enumerable: true, + configurable: true, + value: function get(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLSearchParams.prototype.has = function has(name) { - if (!this || !module.exports.is(this)) { - 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.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].get(...args); } +}); +Object.defineProperty(URLSearchParams.prototype, \\"getAll\\", { + writable: true, + enumerable: true, + configurable: true, + value: function getAll(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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 (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(this[impl].getAll(...args)); } - return this[impl].has(...args); -}; +}); +Object.defineProperty(URLSearchParams.prototype, \\"has\\", { + writable: true, + enumerable: true, + configurable: true, + value: function has(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLSearchParams.prototype.set = function set(name, value) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + 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 this[impl].has(...args); } +}); +Object.defineProperty(URLSearchParams.prototype, \\"set\\", { + writable: true, + enumerable: true, + configurable: true, + value: function set(name, value) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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); + 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 this[impl].set(...args); } - return this[impl].set(...args); -}; - -URLSearchParams.prototype.sort = function sort() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(URLSearchParams.prototype, \\"sort\\", { + writable: true, + enumerable: true, + configurable: true, + value: function sort() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].sort(); } - - return this[impl].sort(); -}; - -URLSearchParams.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +}); +Object.defineProperty(URLSearchParams.prototype, \\"toString\\", { + writable: true, + enumerable: true, + configurable: true, + value: function toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].toString(); } - - return this[impl].toString(); -}; - +}); URLSearchParams.prototype.entries = URLSearchParams.prototype[Symbol.iterator]; URLSearchParams.prototype.keys = function keys() { @@ -5645,52 +5872,60 @@ Object.defineProperty(URLSearchParamsCollection.prototype, Symbol.iterator, { value: Array.prototype[Symbol.iterator] }); -URLSearchParamsCollection.prototype.item = function item(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(this[impl].item(...args)); -}; - -URLSearchParamsCollection.prototype.namedItem = function namedItem(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(URLSearchParamsCollection.prototype, \\"item\\", { + writable: true, + enumerable: true, + configurable: true, + value: function item(index) { + if (!this || !module.exports.is(this)) { + 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); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].item(...args)); } - return utils.tryWrapperForImpl(this[impl].namedItem(...args)); -}; +}); +Object.defineProperty(URLSearchParamsCollection.prototype, \\"namedItem\\", { + writable: true, + enumerable: true, + configurable: true, + value: function namedItem(name) { + if (!this || !module.exports.is(this)) { + 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(this[impl].namedItem(...args)); + } +}); Object.defineProperty(URLSearchParamsCollection.prototype, \\"length\\", { get() { if (!this || !module.exports.is(this)) { @@ -5786,7 +6021,7 @@ const iface = { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -6092,7 +6327,7 @@ const iface = { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -6333,69 +6568,80 @@ Object.defineProperty(UnderscoredProperties, \\"prototype\\", { configurable: false }); -UnderscoredProperties.prototype.operation = function operation(sequence) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +Object.defineProperty(UnderscoredProperties.prototype, \\"operation\\", { + writable: true, + enumerable: true, + configurable: true, + value: function operation(sequence) { + if (!this || !module.exports.is(this)) { + 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.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } 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\\" - }); + } + 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\\" + }); - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); - } - return this[impl].operation(...args); -}; - -UnderscoredProperties.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].operation(...args); } - - return this[impl].mixinMixinOp(); -}; - -UnderscoredProperties.static = function _static(_void) { - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); +}); +Object.defineProperty(UnderscoredProperties.prototype, \\"mixinMixinOp\\", { + writable: true, + enumerable: true, + configurable: true, + value: function mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl].mixinMixinOp(); } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" - }); - args.push(curArg); +}); +Object.defineProperty(UnderscoredProperties, \\"static\\", { + writable: true, + enumerable: true, + configurable: true, + value: function _static(_void) { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'static' on 'UnderscoredProperties': 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); + } + return Impl.implementation.static(...args); } - return Impl.implementation.static(...args); -}; - +}); Object.defineProperty(UnderscoredProperties.prototype, \\"attribute\\", { get() { if (!this || !module.exports.is(this)) { @@ -6631,27 +6877,33 @@ const iface = { return utils.implForWrapper(obj); }, _internalSetup(obj) { - obj.assign = function assign(url) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + Object.defineProperty(obj, \\"assign\\", { + writable: true, + enumerable: true, + configurable: true, + value: function assign(url) { + if (!this || !module.exports.is(this)) { + 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); + 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 this[impl].assign(...args); } - return this[impl].assign(...args); - }; - + }); Object.defineProperty(obj, \\"href\\", { get() { if (!this || !module.exports.is(this)) { @@ -6871,7 +7123,7 @@ const iface = { if (parent === null) { return undefined; } - return Reflect.get(target, P, receiver); + return Reflect.get(parent, P, receiver); } if (!desc.get && !desc.set) { return desc.value; @@ -7213,91 +7465,128 @@ Object.defineProperty(Variadic, \\"prototype\\", { configurable: false }); -Variadic.prototype.simple1 = function simple1() { - if (!this || !module.exports.is(this)) { - 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 this[impl].simple1(...args); -}; - -Variadic.prototype.simple2 = function simple2(first) { - if (!this || !module.exports.is(this)) { - 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 = convertURL(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); - args.push(curArg); +Object.defineProperty(Variadic.prototype, \\"simple1\\", { + writable: true, + enumerable: true, + configurable: true, + value: function simple1() { + if (!this || !module.exports.is(this)) { + 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 this[impl].simple1(...args); } - return this[impl].simple2(...args); -}; +}); +Object.defineProperty(Variadic.prototype, \\"simple2\\", { + writable: true, + enumerable: true, + configurable: true, + value: function simple2(first) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Variadic.prototype.overloaded1 = function overloaded1() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - const args = []; - switch (arguments.length) { - case 0: - break; - default: { + 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]; - if (typeof curArg === \\"number\\") { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); + curArg = 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 = convertURL(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); + args.push(curArg); + } + return this[impl].simple2(...args); + } +}); +Object.defineProperty(Variadic.prototype, \\"overloaded1\\", { + writable: true, + enumerable: true, + configurable: true, + value: function overloaded1() { + if (!this || !module.exports.is(this)) { + 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 this[impl].overloaded1(...args); } - return this[impl].overloaded1(...args); -}; - -Variadic.prototype.overloaded2 = function overloaded2(first) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } +}); +Object.defineProperty(Variadic.prototype, \\"overloaded2\\", { + writable: true, + enumerable: true, + configurable: true, + value: function overloaded2(first) { + if (!this || !module.exports.is(this)) { + 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.\\" - ); - } - const args = []; - switch (arguments.length) { - case 1: - { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + 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\\") { { @@ -7307,6 +7596,13 @@ Variadic.prototype.overloaded2 = function overloaded2(first) { }); 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]; @@ -7315,47 +7611,19 @@ Variadic.prototype.overloaded2 = function overloaded2(first) { }); 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); + 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 this[impl].overloaded2(...args); } - return this[impl].overloaded2(...args); -}; - +}); Object.defineProperty(Variadic.prototype, Symbol.toStringTag, { value: \\"Variadic\\", writable: false, diff --git a/test/cases/PrimaryGlobal.webidl b/test/cases/PrimaryGlobal.webidl new file mode 100644 index 00000000..ba302664 --- /dev/null +++ b/test/cases/PrimaryGlobal.webidl @@ -0,0 +1,11 @@ +// imitates the Window interface +[PrimaryGlobal, LegacyUnenumerableNamedProperties] +interface PrimaryGlobal : URL { + attribute DOMString name; + readonly attribute URL url; + [Unforgeable] readonly attribute URL unforgeableURL; + [Replaceable] readonly attribute URLList replaceableURLList; + + void close(); + getter object (DOMString name); +};