diff --git a/README.md b/README.md index 18c43e98..6a35796c 100644 --- a/README.md +++ b/README.md @@ -264,10 +264,12 @@ Performs the Web IDL conversion algorithm for this interface, converting _value_ In practice, this means doing a type-check equivalent to `is(value)`, and if it passes, returns the corresponding impl. If the type-check fails, it throws an informative exception. _context_ can be used to describe the provided value in any resulting error message. -#### `install(globalObject)` +#### `install(globalObject, globalNames)` This method creates a brand new wrapper constructor and prototype and attach it to the passed `globalObject`. It also registers the created constructor with the `globalObject`'s global constructor registry, which makes `create()`, `createImpl()`, and `setup()` work. (Thus, it is important to invoke `install()` before invoking those methods, as otherwise they will throw.) +The second argument `globalNames` is an array containing the [global names](https://heycam.github.io/webidl/#dfn-global-name) of the interface that `globalObject` implements. This is used for the purposes of deciding which interfaces are [exposed](https://heycam.github.io/webidl/#dfn-exposed). For example, this array should be `["Window"]` for a [`Window`](https://html.spec.whatwg.org/multipage/window-object.html#window) global object. But for a [`DedicatedWorkerGlobalScope`](https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope) global object, this array should be `["Worker", "DedicatedWorker"]`. Note that we do not yet implement [`[SecureContext]`](https://heycam.github.io/webidl/#SecureContext), so the "exposed" check is not fully implemented. + #### `create(globalObject, constructorArgs, privateData)` Creates a new instance of the wrapper class and corresponding implementation class, passing in the `globalObject`, the `constructorArgs` array and `privateData` object to the implementation class constructor. Then returns the wrapper class. @@ -454,6 +456,7 @@ webidl2js is implementing an ever-growing subset of the Web IDL specification. S - Variadic arguments - `[Clamp]` - `[EnforceRange]` +- `[Exposed]` - `[LegacyArrayClass]` - `[LegacyUnenumerableNamedProperties]` - `[LegacyWindowAlias]` @@ -478,7 +481,6 @@ Notable missing features include: - `[AllowShared]` - `[Default]` (for `toJSON()` operations) - `[Global]`'s various consequences, including the named properties object and `[[SetPrototypeOf]]` -- `[Exposed]` - `[LenientSetter]` - `[LenientThis]` - `[NamedConstructor]` diff --git a/lib/constructs/callback-interface.js b/lib/constructs/callback-interface.js index 6c20c5b6..0c5e6cd5 100644 --- a/lib/constructs/callback-interface.js +++ b/lib/constructs/callback-interface.js @@ -20,6 +20,25 @@ class CallbackInterface { this._analyzed = false; this._outputStaticProperties = new Map(); + + const exposed = utils.getExtAttr(this.idl.extAttrs, "Exposed"); + if (this.idl.members.some(member => member.type === "const") && !exposed) { + throw new Error(`Callback interface ${this.name} with defined constants lacks the [Exposed] extended attribute`); + } + + if (exposed) { + if (!exposed.rhs || (exposed.rhs.type !== "identifier" && exposed.rhs.type !== "identifier-list")) { + throw new Error(`[Exposed] must take an identifier or an identifier list in callback interface ${this.name}`); + } + + if (exposed.rhs.type === "identifier") { + this.exposed = new Set([exposed.rhs.value]); + } else { + this.exposed = new Set(exposed.rhs.value.map(token => token.value)); + } + } else { + this.exposed = new Set(); + } } _analyzeMembers() { @@ -178,14 +197,24 @@ class CallbackInterface { } generateInstall() { + if (this.constants.size > 0) { + this.str += ` + const exposed = new Set(${JSON.stringify([...this.exposed])}); + `; + } + this.str += ` - exports.install = function install(globalObject) { + exports.install = (globalObject, globalNames) => { `; if (this.constants.size > 0) { const { name } = this; this.str += ` + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + const ${name} = () => { throw new TypeError("Illegal invocation"); }; @@ -234,4 +263,6 @@ class CallbackInterface { } } +CallbackInterface.prototype.type = "callback interface"; + module.exports = CallbackInterface; diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 34c073c0..e28aa171 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -1463,7 +1463,12 @@ class Interface { const { idl, name } = this; this.str += ` - exports.install = (globalObject, globalName) => { + const exposed = new Set(${JSON.stringify([...this.exposed])}); + + exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } `; if (idl.inheritance) { @@ -1500,7 +1505,7 @@ class Interface { if (this.legacyWindowAliases) { this.str += ` - if (globalName === "Window") { + if (globalNames.includes("Window")) { `; for (const legacyWindowAlias of this.legacyWindowAliases) { diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 2d915d7d..87638119 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -48,7 +48,7 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) {}; +exports.install = (globalObject, globalNames) => {}; " `; @@ -111,7 +111,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class BufferSourceTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -368,7 +373,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class CEReactions { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -702,7 +712,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DOMImplementation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -904,7 +919,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DOMRect { constructor() { const args = []; @@ -1082,7 +1102,7 @@ exports.install = (globalObject, globalName) => { value: DOMRect }); - if (globalName === \\"Window\\") { + if (globalNames.includes(\\"Window\\")) { Object.defineProperty(globalObject, \\"SVGRect\\", { configurable: true, writable: true, @@ -1233,7 +1253,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DictionaryConvert { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -1342,7 +1367,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Enum { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -1449,7 +1479,7 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) {}; +exports.install = (globalObject, globalNames) => {}; " `; @@ -1513,7 +1543,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class EventTarget { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); @@ -1732,7 +1767,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Global\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Global { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -1832,7 +1872,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class HTMLConstructor { constructor() { return HTMLConstructor_HTMLConstructor(globalObject, interfaceName); @@ -1916,7 +1961,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class LegacyArrayClass { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -2012,7 +2062,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class MixedIn { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -2152,7 +2207,13 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + const NodeFilter = () => { throw new TypeError(\\"Illegal invocation\\"); }; @@ -2245,7 +2306,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Overloads { constructor() { const args = []; @@ -2639,7 +2705,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class PromiseTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -2782,7 +2853,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Reflect { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -3089,7 +3165,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class SeqAndRec { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); @@ -3378,7 +3459,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Static { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -3514,7 +3600,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Storage { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -3874,7 +3965,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierAttribute { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -3981,7 +4077,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierDefaultOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -4077,7 +4178,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierNamedOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -4181,7 +4287,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -4277,7 +4388,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class TypedefsAndUnions { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -4792,7 +4908,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URL { constructor(url) { if (arguments.length < 1) { @@ -5114,7 +5235,7 @@ exports.install = (globalObject, globalName) => { value: URL }); - if (globalName === \\"Window\\") { + if (globalNames.includes(\\"Window\\")) { Object.defineProperty(globalObject, \\"webkitURL\\", { configurable: true, writable: true, @@ -5188,7 +5309,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLList { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -5519,7 +5645,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLSearchParams { constructor() { const args = []; @@ -5920,7 +6051,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLSearchParamsCollection { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -6260,7 +6396,13 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + if (globalObject.URLSearchParamsCollection === undefined) { throw new Error( \\"Internal error: attempting to evaluate URLSearchParamsCollection2 before URLSearchParamsCollection\\" @@ -6565,7 +6707,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class UnderscoredProperties { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -6834,7 +6981,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Unforgeable { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -6937,7 +7089,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class UnforgeableMap { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -7196,7 +7353,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Unscopable { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -7335,7 +7497,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Variadic { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -7574,7 +7741,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class ZeroArgConstructor { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); @@ -7647,7 +7819,7 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) {}; +exports.install = (globalObject, globalNames) => {}; " `; @@ -7710,7 +7882,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class BufferSourceTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -7966,7 +8143,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class CEReactions { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -8270,7 +8452,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DOMImplementation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -8472,7 +8659,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DOMRect { constructor() { const args = []; @@ -8650,7 +8842,7 @@ exports.install = (globalObject, globalName) => { value: DOMRect }); - if (globalName === \\"Window\\") { + if (globalNames.includes(\\"Window\\")) { Object.defineProperty(globalObject, \\"SVGRect\\", { configurable: true, writable: true, @@ -8801,7 +8993,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class DictionaryConvert { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -8910,7 +9107,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Enum { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -9017,7 +9219,7 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) {}; +exports.install = (globalObject, globalNames) => {}; " `; @@ -9081,7 +9283,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\", \\"AudioWorklet\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class EventTarget { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); @@ -9300,7 +9507,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Global\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Global { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -9399,7 +9611,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class HTMLConstructor { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -9483,7 +9700,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class LegacyArrayClass { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -9579,7 +9801,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class MixedIn { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -9719,7 +9946,13 @@ exports.convert = function convert(value, { context = \\"The provided value\\" } return callTheUserObjectsOperation; }; -exports.install = function install(globalObject) { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + const NodeFilter = () => { throw new TypeError(\\"Illegal invocation\\"); }; @@ -9812,7 +10045,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Overloads { constructor() { const args = []; @@ -10206,7 +10444,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class PromiseTypes { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -10348,7 +10591,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Reflect { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -10641,7 +10889,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class SeqAndRec { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); @@ -10930,7 +11183,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Static { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11066,7 +11324,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Storage { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11426,7 +11689,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierAttribute { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11533,7 +11801,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierDefaultOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11629,7 +11902,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierNamedOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11733,7 +12011,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class StringifierOperation { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -11829,7 +12112,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class TypedefsAndUnions { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -12344,7 +12632,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URL { constructor(url) { if (arguments.length < 1) { @@ -12666,7 +12959,7 @@ exports.install = (globalObject, globalName) => { value: URL }); - if (globalName === \\"Window\\") { + if (globalNames.includes(\\"Window\\")) { Object.defineProperty(globalObject, \\"webkitURL\\", { configurable: true, writable: true, @@ -12740,7 +13033,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLList { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -13071,7 +13369,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\", \\"Worker\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLSearchParams { constructor() { const args = []; @@ -13472,7 +13775,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class URLSearchParamsCollection { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -13812,7 +14120,13 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + if (globalObject.URLSearchParamsCollection === undefined) { throw new Error( \\"Internal error: attempting to evaluate URLSearchParamsCollection2 before URLSearchParamsCollection\\" @@ -14117,7 +14431,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class UnderscoredProperties { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -14386,7 +14705,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Unforgeable { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -14489,7 +14813,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class UnforgeableMap { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -14748,7 +15077,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Unscopable { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -14887,7 +15221,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class Variadic { constructor() { throw new TypeError(\\"Illegal constructor\\"); @@ -15126,7 +15465,12 @@ exports.setup = function setup(obj, globalObject, constructorArgs = [], privateD return obj; }; -exports.install = (globalObject, globalName) => { +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } class ZeroArgConstructor { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined);