1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10:04 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

View File

@@ -9,9 +9,10 @@ const { define, mixin } = require("../utils");
const Element = require("../living/generated/Element");
const EventTarget = require("../living/generated/EventTarget");
const EventHandlerNonNull = require("../living/generated/EventHandlerNonNull");
const IDLFunction = require("../living/generated/Function");
const OnBeforeUnloadEventHandlerNonNull = require("../living/generated/OnBeforeUnloadEventHandlerNonNull");
const OnErrorEventHandlerNonNull = require("../living/generated/OnErrorEventHandlerNonNull");
const PageTransitionEvent = require("../living/generated/PageTransitionEvent");
const { fireAPageTransitionEvent } = require("../living/helpers/page-transition-event");
const namedPropertiesWindow = require("../living/named-properties-window");
const postMessage = require("../living/post-message");
const DOMException = require("domexception/webidl2js-wrapper");
@@ -24,6 +25,7 @@ const External = require("../living/generated/External");
const Navigator = require("../living/generated/Navigator");
const Performance = require("../living/generated/Performance");
const Screen = require("../living/generated/Screen");
const Crypto = require("../living/generated/Crypto");
const Storage = require("../living/generated/Storage");
const Selection = require("../living/generated/Selection");
const reportException = require("../living/helpers/runtime-script-errors");
@@ -97,9 +99,6 @@ exports.createWindow = function (options) {
const jsGlobalEntriesToInstall = Object.entries(jsGlobals).filter(([name]) => name in global);
// TODO remove when we drop Node v10 support.
const anyNodeVersionQueueMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : process.nextTick;
// https://html.spec.whatwg.org/#the-window-object
function setupWindow(windowInstance, { runScripts }) {
if (runScripts === "outside-only" || runScripts === "dangerously") {
@@ -167,7 +166,7 @@ function setupWindow(windowInstance, { runScripts }) {
if (!idlUtils.isObject(V)) {
V = null;
} else {
V = OnBeforeUnloadEventHandlerNonNull.convert(V, {
V = OnBeforeUnloadEventHandlerNonNull.convert(windowInstance, V, {
context: "Failed to set the 'onbeforeunload' property on 'Window': The provided value"
});
}
@@ -185,7 +184,7 @@ function setupWindow(windowInstance, { runScripts }) {
if (!idlUtils.isObject(V)) {
V = null;
} else {
V = OnErrorEventHandlerNonNull.convert(V, {
V = OnErrorEventHandlerNonNull.convert(windowInstance, V, {
context: "Failed to set the 'onerror' property on 'Window': The provided value"
});
}
@@ -204,7 +203,7 @@ function setupWindow(windowInstance, { runScripts }) {
if (!idlUtils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(windowInstance, V, {
context: `Failed to set the 'on${event}' property on 'Window': The provided value`
});
}
@@ -341,6 +340,7 @@ function Window(options) {
const navigator = Navigator.create(window, [], { userAgent: this._resourceLoader._userAgent });
const performance = Performance.create(window, [], { rawPerformance });
const screen = Screen.create(window);
const crypto = Crypto.create(window);
const customElementRegistry = CustomElementRegistry.create(window);
define(this, {
@@ -404,6 +404,9 @@ function Window(options) {
get screen() {
return screen;
},
get crypto() {
return crypto;
},
get origin() {
return window._origin;
},
@@ -543,9 +546,9 @@ function Window(options) {
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing
this.queueMicrotask = function (callback) {
callback = webIDLConversions.Function(callback);
callback = IDLFunction.convert(this, callback);
anyNodeVersionQueueMicrotask(() => {
queueMicrotask(() => {
try {
callback();
} catch (e) {
@@ -566,7 +569,7 @@ function Window(options) {
if (this._pretendToBeVisual) {
this.requestAnimationFrame = function (callback) {
callback = webIDLConversions.Function(callback);
callback = IDLFunction.convert(this, callback);
const handle = ++animationFrameCallbackId;
mapOfAnimationFrameCallbacks.set(handle, callback);
@@ -780,7 +783,7 @@ function Window(options) {
};
this.getComputedStyle = function (elt, pseudoElt = undefined) {
elt = Element.convert(elt);
elt = Element.convert(this, elt);
if (pseudoElt !== undefined && pseudoElt !== null) {
pseudoElt = webIDLConversions.DOMString(pseudoElt);
}
@@ -907,17 +910,19 @@ function Window(options) {
return; // window might've been closed already
}
const documentImpl = idlUtils.implForWrapper(window._document);
if (window.document.readyState === "complete") {
fireAnEvent("load", window, undefined, {}, documentImpl);
fireAnEvent("load", window, undefined, {}, true);
} else {
window.document.addEventListener("load", () => {
fireAnEvent("load", window, undefined, {}, documentImpl);
fireAnEvent("load", window, undefined, {}, true);
if (!window._document) {
return; // window might've been closed already
}
const documentImpl = idlUtils.implForWrapper(window._document);
if (!documentImpl._pageShowingFlag) {
documentImpl._pageShowingFlag = true;
fireAnEvent("pageshow", window, PageTransitionEvent, { persisted: false }, documentImpl);
fireAPageTransitionEvent("pageshow", window, false);
}
});
}

View File

@@ -79,6 +79,11 @@
"enumerable": false,
"configurable": true
},
"AggregateError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"EvalError": {
"writable": true,
"enumerable": false,
@@ -229,6 +234,16 @@
"enumerable": false,
"configurable": true
},
"FinalizationRegistry": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WeakRef": {
"writable": true,
"enumerable": false,
"configurable": true
},
"decodeURI": {
"writable": true,
"enumerable": false,
@@ -284,21 +299,6 @@
"enumerable": false,
"configurable": true
},
"AggregateError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"FinalizationRegistry": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WeakRef": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WebAssembly": {
"writable": true,
"enumerable": false,

View File

@@ -18,32 +18,6 @@ const {
customElementReactionsStack, invokeCEReactions, lookupCEDefinition
} = require("../../living/helpers/custom-elements");
// Horrible monkey-patch to implement https://github.com/inikulin/parse5/issues/237 and
// https://github.com/inikulin/parse5/issues/285.
const OpenElementStack = require("parse5/lib/parser/open-element-stack");
const openElementStackOriginalPush = OpenElementStack.prototype.push;
OpenElementStack.prototype.push = function (...args) {
openElementStackOriginalPush.apply(this, args);
this.treeAdapter._currentElement = this.current;
const after = this.items[this.stackTop];
if (after._pushedOnStackOfOpenElements) {
after._pushedOnStackOfOpenElements();
}
};
const openElementStackOriginalPop = OpenElementStack.prototype.pop;
OpenElementStack.prototype.pop = function (...args) {
const before = this.items[this.stackTop];
openElementStackOriginalPop.apply(this, args);
this.treeAdapter._currentElement = this.current;
if (before._poppedOffStackOfOpenElements) {
before._poppedOffStackOfOpenElements();
}
};
class JSDOMParse5Adapter {
constructor(documentImpl, options = {}) {
@@ -52,7 +26,7 @@ class JSDOMParse5Adapter {
this._fragment = options.fragment || false;
// Since the createElement hook doesn't provide the parent element, we keep track of this using _currentElement:
// https://github.com/inikulin/parse5/issues/285. See above horrible monkey-patch for how this is maintained.
// https://github.com/inikulin/parse5/issues/285.
this._currentElement = undefined;
}
@@ -190,6 +164,16 @@ class JSDOMParse5Adapter {
attributes.setAttributeValue(element, attr.name, attr.value, prefix, attr.namespace);
}
}
onItemPush(after) {
this._currentElement = after;
after._pushedOnStackOfOpenElements?.();
}
onItemPop(before, newTop) {
this._currentElement = newTop;
before._poppedOffStackOfOpenElements?.();
}
}
// Assign shared adapters with serializer.
@@ -202,6 +186,7 @@ function parseFragment(markup, contextElement) {
const config = {
...ownerDocument._parseOptions,
sourceCodeLocationInfo: false,
treeAdapter: new JSDOMParse5Adapter(ownerDocument, { fragment: true })
};

View File

@@ -25,7 +25,7 @@ module.exports = class ResourceLoader {
const dataURL = dataURLFromRecord(urlRecord);
let timeoutId;
const promise = new Promise(resolve => {
timeoutId = setTimeout(resolve, 0, dataURL.body);
timeoutId = setTimeout(resolve, 0, Buffer.from(dataURL.body));
});
promise.abort = () => {
if (timeoutId !== undefined) {

View File

@@ -29,7 +29,7 @@ exports.addToCore = core => {
core.CSSImportRule = cssom.CSSImportRule;
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
// Relavant specs
// Relevant specs
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
// http://www.w3.org/TR/cssom-view/ (2008)
// http://dev.w3.org/csswg/cssom/ (2010) Meant to replace DOM Level 2 Style

View File

@@ -7,8 +7,8 @@ class AbortControllerImpl {
this.signal = AbortSignal.createImpl(globalObject, []);
}
abort() {
this.signal._signalAbort();
abort(reason) {
this.signal._signalAbort(reason);
}
}

View File

@@ -3,6 +3,8 @@
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
const { fireAnEvent } = require("../helpers/events");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const AbortSignal = require("../generated/AbortSignal");
const DOMException = require("domexception/webidl2js-wrapper");
class AbortSignalImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
@@ -11,15 +13,34 @@ class AbortSignalImpl extends EventTargetImpl {
// make event firing possible
this._ownerDocument = globalObject.document;
this.aborted = false;
this.reason = undefined;
this.abortAlgorithms = new Set();
}
_signalAbort() {
get aborted() {
return this.reason !== undefined;
}
static abort(globalObject, reason) {
const abortSignal = AbortSignal.createImpl(globalObject, []);
if (reason !== undefined) {
abortSignal.reason = reason;
} else {
abortSignal.reason = DOMException.create(globalObject, ["The operation was aborted.", "AbortError"]);
}
return abortSignal;
}
_signalAbort(reason) {
if (this.aborted) {
return;
}
this.aborted = true;
if (reason !== undefined) {
this.reason = reason;
} else {
this.reason = DOMException.create(this._globalObject, ["The operation was aborted.", "AbortError"]);
}
for (const algorithm of this.abortAlgorithms) {
algorithm();

View File

@@ -0,0 +1,47 @@
"use strict";
const nodeCrypto = require("crypto");
const DOMException = require("domexception/webidl2js-wrapper");
// https://w3c.github.io/webcrypto/#crypto-interface
class CryptoImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
// https://w3c.github.io/webcrypto/#Crypto-method-getRandomValues
getRandomValues(array) {
// Note: this rejects Float32Array, Float64Array and DataView.
//
// We perform "instance tests" by comparing `array.constructor.name` so
// that the tests will be successful across realms.
const typeName = array.constructor.name;
if (!(typeName === "Int8Array" ||
typeName === "Uint8Array" ||
typeName === "Uint8ClampedArray" ||
typeName === "Int16Array" ||
typeName === "Uint16Array" ||
typeName === "Int32Array" ||
typeName === "Uint32Array" ||
typeName === "BigInt64Array" ||
typeName === "BigUint64Array")) {
throw DOMException.create(this._globalObject, [
`getRandomValues() only accepts integer typed arrays`,
"TypeMismatchError"
]);
}
if (array.byteLength > 65536) {
throw DOMException.create(this._globalObject, [
`getRandomValues() cannot generate more than 65536 bytes of random values; ` +
`${array.byteLength} bytes were requested`,
"QuotaExceededError"
]);
}
nodeCrypto.randomFillSync(array);
return array;
}
}
exports.implementation = CryptoImpl;

View File

@@ -147,7 +147,7 @@ class CustomElementRegistryImpl {
const callbackValue = prototype[callbackName];
if (callbackValue !== undefined) {
lifecycleCallbacks[callbackName] = IDLFunction.convert(callbackValue, {
lifecycleCallbacks[callbackName] = IDLFunction.convert(_globalObject, callbackValue, {
context: `The lifecycle callback "${callbackName}"`
});
}

View File

@@ -11,6 +11,7 @@ exports.implementation = class InnerHTMLImpl {
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
get innerHTML() {
return fragmentSerialization(this, {
outer: false,
requireWellFormed: true,
globalObject: this._globalObject
});

View File

@@ -6,7 +6,7 @@ const { domSymbolTree } = require("../helpers/internal-constants");
// Tree traversing
exports.getFirstChild = node => node.firstChild;
exports.getChildNodes = node => node.childNodesForSerializing || domSymbolTree.childrenToArray(node);
exports.getChildNodes = node => domSymbolTree.childrenToArray(node);
exports.getParentNode = node => node.parentNode;

View File

@@ -7,28 +7,19 @@ const DOMException = require("domexception/webidl2js-wrapper");
const utils = require("../generated/utils");
const treeAdapter = require("./parse5-adapter-serialization");
const NODE_TYPE = require("../node-type");
const NAMESPACES = require("../helpers/namespaces");
function htmlSerialization(node) {
if (
node.nodeType === NODE_TYPE.ELEMENT_NODE &&
node.namespaceURI === NAMESPACES.HTML_NS &&
node.tagName === "TEMPLATE"
) {
node = node.content;
}
return parse5.serialize(node, { treeAdapter });
}
module.exports.fragmentSerialization = (node, { requireWellFormed, globalObject }) => {
module.exports.fragmentSerialization = (node, { outer, requireWellFormed, globalObject }) => {
const contextDocument =
node.nodeType === NODE_TYPE.DOCUMENT_NODE ? node : node._ownerDocument;
if (contextDocument._parsingMode === "html") {
return htmlSerialization(node);
const config = {
...contextDocument._parseOptions,
treeAdapter
};
return outer ? parse5.serializeOuter(node, config) : parse5.serialize(node, config);
}
const childNodes = node.childNodesForSerializing || node.childNodes;
const childNodes = outer ? [node] : node.childNodes;
try {
let serialized = "";

View File

@@ -5,6 +5,6 @@ const EventImpl = require("./Event-impl").implementation;
const CloseEventInit = require("../generated/CloseEventInit");
class CloseEventImpl extends EventImpl {}
CloseEventImpl.defaultInit = CloseEventInit.convert(undefined);
CloseEventImpl.defaultInit = CloseEventInit.convert(undefined, undefined);
exports.implementation = CloseEventImpl;

View File

@@ -13,7 +13,7 @@ class CompositionEventImpl extends UIEventImpl {
this.data = data;
}
}
CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined);
CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined, undefined);
module.exports = {
implementation: CompositionEventImpl

View File

@@ -14,7 +14,7 @@ class CustomEventImpl extends EventImpl {
this.detail = detail;
}
}
CustomEventImpl.defaultInit = CustomEventInit.convert(undefined);
CustomEventImpl.defaultInit = CustomEventInit.convert(undefined, undefined);
module.exports = {
implementation: CustomEventImpl

View File

@@ -7,7 +7,7 @@ const ErrorEventInit = require("../generated/ErrorEventInit");
class ErrorEventImpl extends EventImpl {
}
ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined);
ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined, undefined);
module.exports = {
implementation: ErrorEventImpl

View File

@@ -190,7 +190,7 @@ class EventImpl {
this._initialize(type, bubbles, cancelable);
}
}
EventImpl.defaultInit = EventInit.convert(undefined);
EventImpl.defaultInit = EventInit.convert(undefined, undefined);
module.exports = {
implementation: EventImpl

View File

@@ -27,6 +27,10 @@ class EventTargetImpl {
addEventListener(type, callback, options) {
options = normalizeEventHandlerOptions(options, ["capture", "once", "passive"]);
if (options.signal !== null && options.signal.aborted) {
return;
}
if (callback === null) {
return;
}
@@ -49,6 +53,12 @@ class EventTargetImpl {
callback,
options
});
if (options.signal !== null) {
options.signal._addAlgorithm(() => {
this.removeEventListener(type, callback, options);
});
}
}
removeEventListener(type, callback, options) {
@@ -101,14 +111,16 @@ class EventTargetImpl {
// https://dom.spec.whatwg.org/#concept-event-dispatch
// legacyOutputDidListenersThrowFlag optional parameter is not necessary here since it is only used by indexDB.
_dispatch(eventImpl, targetOverride /* , legacyOutputDidListenersThrowFlag */) {
_dispatch(eventImpl, legacyTargetOverrideFlag /* , legacyOutputDidListenersThrowFlag */) {
let targetImpl = this;
let clearTargets = false;
let activationTarget = null;
eventImpl._dispatchFlag = true;
targetOverride = targetOverride || targetImpl;
const targetOverride = legacyTargetOverrideFlag ?
idlUtils.implForWrapper(targetImpl._globalObject._document) :
targetImpl;
let relatedTarget = retarget(eventImpl.relatedTarget, targetImpl);
if (targetImpl !== relatedTarget || targetImpl === eventImpl.relatedTarget) {
@@ -364,7 +376,7 @@ function innerInvokeEventListeners(eventImpl, listeners, phase, itemInShadowTree
* @returns {Object} object containing at least the "defaultBoolKeys"
*/
function normalizeEventHandlerOptions(options, defaultBoolKeys) {
const returnValue = {};
const returnValue = { signal: null };
// no need to go further here
if (typeof options === "boolean" || options === null || typeof options === "undefined") {
@@ -383,6 +395,10 @@ function normalizeEventHandlerOptions(options, defaultBoolKeys) {
returnValue[key] = Boolean(options[key]);
}
if (options.signal !== undefined) {
returnValue.signal = options.signal;
}
return returnValue;
}

View File

@@ -4,6 +4,6 @@ const UIEventImpl = require("./UIEvent-impl").implementation;
const FocusEventInit = require("../generated/FocusEventInit");
class FocusEventImpl extends UIEventImpl {}
FocusEventImpl.defaultInit = FocusEventInit.convert(undefined);
FocusEventImpl.defaultInit = FocusEventInit.convert(undefined, undefined);
exports.implementation = FocusEventImpl;

View File

@@ -7,7 +7,7 @@ const HashChangeEventInit = require("../generated/HashChangeEventInit");
class HashChangeEventImpl extends EventImpl {
}
HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined);
HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined, undefined);
module.exports = {
implementation: HashChangeEventImpl

View File

@@ -4,7 +4,7 @@ const InputEventInit = require("../generated/InputEventInit");
// https://w3c.github.io/uievents/#interface-inputevent
class InputEventImpl extends UIEventImpl { }
InputEventImpl.defaultInit = InputEventInit.convert(undefined);
InputEventImpl.defaultInit = InputEventInit.convert(undefined, undefined);
module.exports = {
implementation: InputEventImpl

View File

@@ -22,7 +22,7 @@ class KeyboardEventImpl extends UIEventImpl {
}
}
mixin(KeyboardEventImpl.prototype, EventModifierMixinImpl.prototype);
KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined);
KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined, undefined);
module.exports = {
implementation: KeyboardEventImpl

View File

@@ -18,7 +18,7 @@ class MessageEventImpl extends EventImpl {
this.ports = ports;
}
}
MessageEventImpl.defaultInit = MessageEventInit.convert(undefined);
MessageEventImpl.defaultInit = MessageEventInit.convert(undefined, undefined);
module.exports = {
implementation: MessageEventImpl

View File

@@ -42,7 +42,7 @@ class MouseEventImpl extends UIEventImpl {
}
}
mixin(MouseEventImpl.prototype, EventModifierMixinImpl.prototype);
MouseEventImpl.defaultInit = MouseEventInit.convert(undefined);
MouseEventImpl.defaultInit = MouseEventInit.convert(undefined, undefined);
module.exports = {
implementation: MouseEventImpl

View File

@@ -15,6 +15,6 @@ class PageTransitionEventImpl extends EventImpl {
this.persisted = persisted;
}
}
PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined);
PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined, undefined);
exports.implementation = PageTransitionEventImpl;

View File

@@ -4,6 +4,6 @@ const EventImpl = require("./Event-impl.js").implementation;
const PopStateEventInit = require("../generated/PopStateEventInit");
class PopStateEventImpl extends EventImpl {}
PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined);
PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined, undefined);
exports.implementation = PopStateEventImpl;

View File

@@ -7,7 +7,7 @@ const ProgressEventInit = require("../generated/ProgressEventInit");
class ProgressEventImpl extends EventImpl {
}
ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined);
ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined, undefined);
module.exports = {
implementation: ProgressEventImpl

View File

@@ -19,7 +19,7 @@ class StorageEventImpl extends EventImpl {
this.storageArea = storageArea;
}
}
StorageEventImpl.defaultInit = StorageEventInit.convert(undefined);
StorageEventImpl.defaultInit = StorageEventInit.convert(undefined, undefined);
module.exports = {
implementation: StorageEventImpl

View File

@@ -7,7 +7,7 @@ const TouchEventInit = require("../generated/TouchEventInit");
class TouchEventImpl extends UIEventImpl {
}
TouchEventImpl.defaultInit = TouchEventInit.convert(undefined);
TouchEventImpl.defaultInit = TouchEventInit.convert(undefined, undefined);
module.exports = {
implementation: TouchEventImpl

View File

@@ -52,7 +52,7 @@ class UIEventImpl extends EventImpl {
this.detail = detail;
}
}
UIEventImpl.defaultInit = UIEventInit.convert(undefined);
UIEventImpl.defaultInit = UIEventInit.convert(undefined, undefined);
module.exports = {
implementation: UIEventImpl

View File

@@ -5,7 +5,7 @@ const MouseEventImpl = require("./MouseEvent-impl").implementation;
const WheelEventInit = require("../generated/WheelEventInit");
class WheelEventImpl extends MouseEventImpl {}
WheelEventImpl.defaultInit = WheelEventInit.convert(undefined);
WheelEventImpl.defaultInit = WheelEventInit.convert(undefined, undefined);
module.exports = {
implementation: WheelEventImpl

View File

@@ -21,6 +21,11 @@ function assertValue(value) {
}
}
// https://fetch.spec.whatwg.org/#concept-header-value-normalize
function normalizeValue(potentialValue) {
return potentialValue.replace(/^[\n\r\t ]+|[\n\r\t ]+$/g, "");
}
class HeadersImpl {
constructor(globalObject, args) {
this.guard = "none";
@@ -61,7 +66,7 @@ class HeadersImpl {
}
append(name, value) {
value = value.trim();
value = normalizeValue(value);
assertName(name);
assertValue(value);
@@ -97,7 +102,7 @@ class HeadersImpl {
}
set(name, value) {
value = value.trim();
value = normalizeValue(value);
assertName(name);
assertValue(value);

View File

@@ -14,24 +14,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbortController'.`);
throw new globalObject.TypeError(`${context} is not of type 'AbortController'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["AbortController"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbortController is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbortController"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -62,8 +62,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -84,6 +84,8 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class AbortController {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
@@ -92,17 +94,31 @@ exports.install = (globalObject, globalNames) => {
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'abort' called on an object that is not a valid instance of AbortController.");
throw new globalObject.TypeError(
"'abort' called on an object that is not a valid instance of AbortController."
);
}
return esValue[implSymbol].abort();
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'abort' on 'AbortController': parameter 1",
globals: globalObject
});
}
args.push(curArg);
}
return esValue[implSymbol].abort(...args);
}
get signal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get signal' called on an object that is not a valid instance of AbortController.");
throw new globalObject.TypeError(
"'get signal' called on an object that is not a valid instance of AbortController."
);
}
return utils.getSameObject(this, "signal", () => {
@@ -115,10 +131,7 @@ exports.install = (globalObject, globalNames) => {
signal: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortController", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbortController;
ctorRegistry[interfaceName] = AbortController;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbortSignal'.`);
throw new globalObject.TypeError(`${context} is not of type 'AbortSignal'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["AbortSignal"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbortSignal is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbortSignal"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,29 +89,43 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.EventTarget === undefined) {
throw new Error("Internal error: attempting to evaluate AbortSignal before EventTarget");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class AbortSignal extends globalObject.EventTarget {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
get aborted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get aborted' called on an object that is not a valid instance of AbortSignal.");
throw new globalObject.TypeError(
"'get aborted' called on an object that is not a valid instance of AbortSignal."
);
}
return esValue[implSymbol]["aborted"];
}
get reason() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get reason' called on an object that is not a valid instance of AbortSignal."
);
}
return esValue[implSymbol]["reason"];
}
get onabort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onabort' called on an object that is not a valid instance of AbortSignal.");
throw new globalObject.TypeError(
"'get onabort' called on an object that is not a valid instance of AbortSignal."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
@@ -121,28 +135,44 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onabort' called on an object that is not a valid instance of AbortSignal.");
throw new globalObject.TypeError(
"'set onabort' called on an object that is not a valid instance of AbortSignal."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onabort' property on 'AbortSignal': The provided value"
});
}
esValue[implSymbol]["onabort"] = V;
}
static abort() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'abort' on 'AbortSignal': parameter 1",
globals: globalObject
});
}
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.abort(globalObject, ...args));
}
}
Object.defineProperties(AbortSignal.prototype, {
aborted: { enumerable: true },
reason: { enumerable: true },
onabort: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortSignal", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbortSignal;
Object.defineProperties(AbortSignal, { abort: { enumerable: true } });
ctorRegistry[interfaceName] = AbortSignal;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -14,24 +14,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbstractRange'.`);
throw new globalObject.TypeError(`${context} is not of type 'AbstractRange'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["AbstractRange"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbstractRange is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbstractRange"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -62,8 +62,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -84,16 +84,20 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class AbstractRange {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
get startContainer() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get startContainer' called on an object that is not a valid instance of AbstractRange.");
throw new globalObject.TypeError(
"'get startContainer' called on an object that is not a valid instance of AbstractRange."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["startContainer"]);
@@ -103,7 +107,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get startOffset' called on an object that is not a valid instance of AbstractRange.");
throw new globalObject.TypeError(
"'get startOffset' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["startOffset"];
@@ -113,7 +119,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get endContainer' called on an object that is not a valid instance of AbstractRange.");
throw new globalObject.TypeError(
"'get endContainer' called on an object that is not a valid instance of AbstractRange."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["endContainer"]);
@@ -123,7 +131,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get endOffset' called on an object that is not a valid instance of AbstractRange.");
throw new globalObject.TypeError(
"'get endOffset' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["endOffset"];
@@ -133,7 +143,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get collapsed' called on an object that is not a valid instance of AbstractRange.");
throw new globalObject.TypeError(
"'get collapsed' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["collapsed"];
@@ -147,10 +159,7 @@ exports.install = (globalObject, globalNames) => {
collapsed: { enumerable: true },
[Symbol.toStringTag]: { value: "AbstractRange", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbstractRange;
ctorRegistry[interfaceName] = AbstractRange;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,16 +3,17 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const AbortSignal = require("./AbortSignal.js");
const EventListenerOptions = require("./EventListenerOptions.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventListenerOptions._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventListenerOptions._convertInherit(globalObject, obj, ret, { context });
{
const key = "once";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'once' that" });
value = conversions["boolean"](value, { context: context + " has member 'once' that", globals: globalObject });
ret[key] = value;
} else {
@@ -24,21 +25,31 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "passive";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'passive' that" });
value = conversions["boolean"](value, { context: context + " has member 'passive' that", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "signal";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = AbortSignal.convert(globalObject, value, { context: context + " has member 'signal' that" });
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -3,12 +3,12 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "flatten";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'flatten' that" });
value = conversions["boolean"](value, { context: context + " has member 'flatten' that", globals: globalObject });
ret[key] = value;
} else {
@@ -17,12 +17,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -17,24 +17,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Attr'.`);
throw new globalObject.TypeError(`${context} is not of type 'Attr'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["Attr"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Attr is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Attr"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -90,19 +90,19 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate Attr before Node");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Attr extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
get namespaceURI() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get namespaceURI' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError(
"'get namespaceURI' called on an object that is not a valid instance of Attr."
);
}
return esValue[implSymbol]["namespaceURI"];
@@ -112,7 +112,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get prefix' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'get prefix' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["prefix"];
@@ -122,7 +122,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get localName' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'get localName' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["localName"];
@@ -132,7 +132,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["name"];
@@ -142,7 +142,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'get value' called on an object that is not a valid instance of Attr.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -157,10 +157,13 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'set value' called on an object that is not a valid instance of Attr.");
}
V = conversions["DOMString"](V, { context: "Failed to set the 'value' property on 'Attr': The provided value" });
V = conversions["DOMString"](V, {
context: "Failed to set the 'value' property on 'Attr': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
@@ -174,7 +177,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get ownerElement' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError(
"'get ownerElement' called on an object that is not a valid instance of Attr."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ownerElement"]);
@@ -184,7 +189,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get specified' called on an object that is not a valid instance of Attr.");
throw new globalObject.TypeError("'get specified' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["specified"];
@@ -200,10 +205,7 @@ exports.install = (globalObject, globalNames) => {
specified: { enumerable: true },
[Symbol.toStringTag]: { value: "Attr", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Attr;
ctorRegistry[interfaceName] = Attr;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -14,24 +14,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'BarProp'.`);
throw new globalObject.TypeError(`${context} is not of type 'BarProp'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["BarProp"];
if (ctor === undefined) {
throw new Error("Internal error: constructor BarProp is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["BarProp"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -62,8 +62,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -84,16 +84,18 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class BarProp {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
get visible() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get visible' called on an object that is not a valid instance of BarProp.");
throw new globalObject.TypeError("'get visible' called on an object that is not a valid instance of BarProp.");
}
return esValue[implSymbol]["visible"];
@@ -103,10 +105,7 @@ exports.install = (globalObject, globalNames) => {
visible: { enumerable: true },
[Symbol.toStringTag]: { value: "BarProp", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = BarProp;
ctorRegistry[interfaceName] = BarProp;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,10 +3,10 @@
const enumerationValues = new Set(["blob", "arraybuffer"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`);
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`);
}
return string;
};

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Blob'.`);
throw new globalObject.TypeError(`${context} is not of type 'Blob'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["Blob"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Blob is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Blob"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -63,8 +63,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -85,6 +85,8 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Blob {
constructor() {
const args = [];
@@ -92,7 +94,7 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[0];
if (curArg !== undefined) {
if (!utils.isObject(curArg)) {
throw new TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
throw new globalObject.TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
@@ -103,7 +105,8 @@ exports.install = (globalObject, globalNames) => {
} else if (ArrayBuffer.isView(nextItem)) {
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'Blob': parameter 1" + "'s element"
context: "Failed to construct 'Blob': parameter 1" + "'s element",
globals: globalObject
});
}
V.push(nextItem);
@@ -115,7 +118,7 @@ exports.install = (globalObject, globalNames) => {
}
{
let curArg = arguments[1];
curArg = BlobPropertyBag.convert(curArg, { context: "Failed to construct 'Blob': parameter 2" });
curArg = BlobPropertyBag.convert(globalObject, curArg, { context: "Failed to construct 'Blob': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -124,7 +127,7 @@ exports.install = (globalObject, globalNames) => {
slice() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'slice' called on an object that is not a valid instance of Blob.");
throw new globalObject.TypeError("'slice' called on an object that is not a valid instance of Blob.");
}
const args = [];
{
@@ -132,6 +135,7 @@ exports.install = (globalObject, globalNames) => {
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 1",
globals: globalObject,
clamp: true
});
}
@@ -142,6 +146,7 @@ exports.install = (globalObject, globalNames) => {
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 2",
globals: globalObject,
clamp: true
});
}
@@ -150,7 +155,10 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'slice' on 'Blob': parameter 3" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 3",
globals: globalObject
});
}
args.push(curArg);
}
@@ -161,7 +169,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get size' called on an object that is not a valid instance of Blob.");
throw new globalObject.TypeError("'get size' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["size"];
@@ -171,7 +179,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of Blob.");
throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["type"];
@@ -183,10 +191,7 @@ exports.install = (globalObject, globalNames) => {
type: { enumerable: true },
[Symbol.toStringTag]: { value: "Blob", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Blob;
ctorRegistry[interfaceName] = Blob;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,16 +3,12 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(blob) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;

View File

@@ -5,12 +5,12 @@ const utils = require("./utils.js");
const EndingType = require("./EndingType.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "endings";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = EndingType.convert(value, { context: context + " has member 'endings' that" });
value = EndingType.convert(globalObject, value, { context: context + " has member 'endings' that" });
ret[key] = value;
} else {
@@ -22,7 +22,7 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "type";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'type' that" });
value = conversions["DOMString"](value, { context: context + " has member 'type' that", globals: globalObject });
ret[key] = value;
} else {
@@ -31,12 +31,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CDATASection'.`);
throw new globalObject.TypeError(`${context} is not of type 'CDATASection'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CDATASection"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CDATASection is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CDATASection"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -65,8 +65,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -88,21 +88,16 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Text === undefined) {
throw new Error("Internal error: attempting to evaluate CDATASection before Text");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CDATASection extends globalObject.Text {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(CDATASection.prototype, {
[Symbol.toStringTag]: { value: "CDATASection", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CDATASection;
ctorRegistry[interfaceName] = CDATASection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,10 +3,10 @@
const enumerationValues = new Set(["", "maybe", "probably"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`);
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`);
}
return string;
};

View File

@@ -17,24 +17,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CharacterData'.`);
throw new globalObject.TypeError(`${context} is not of type 'CharacterData'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CharacterData"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CharacterData is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CharacterData"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -90,39 +90,39 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate CharacterData before Node");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CharacterData extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
substringData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'substringData' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'substringData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'substringData' on 'CharacterData': parameter 1"
context: "Failed to execute 'substringData' on 'CharacterData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2"
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -132,21 +132,22 @@ exports.install = (globalObject, globalNames) => {
appendData(data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'appendData' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'appendData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'appendData' on 'CharacterData': parameter 1"
context: "Failed to execute 'appendData' on 'CharacterData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -156,28 +157,30 @@ exports.install = (globalObject, globalNames) => {
insertData(offset, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'insertData' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'insertData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'insertData' on 'CharacterData': parameter 1"
context: "Failed to execute 'insertData' on 'CharacterData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2"
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -187,28 +190,30 @@ exports.install = (globalObject, globalNames) => {
deleteData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'deleteData' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'deleteData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1"
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2"
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -218,35 +223,38 @@ exports.install = (globalObject, globalNames) => {
replaceData(offset, count, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceData' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'replaceData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 3) {
throw new TypeError(
"Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1"
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2"
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3"
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3",
globals: globalObject
});
args.push(curArg);
}
@@ -256,7 +264,7 @@ exports.install = (globalObject, globalNames) => {
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'before' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError("'before' called on an object that is not a valid instance of CharacterData.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -265,7 +273,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1)
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -281,7 +290,7 @@ exports.install = (globalObject, globalNames) => {
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'after' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError("'after' called on an object that is not a valid instance of CharacterData.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -290,7 +299,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1)
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -306,7 +316,9 @@ exports.install = (globalObject, globalNames) => {
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceWith' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'replaceWith' called on an object that is not a valid instance of CharacterData."
);
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -315,7 +327,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1)
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -331,7 +344,7 @@ exports.install = (globalObject, globalNames) => {
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of CharacterData.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -346,7 +359,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get data' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'get data' called on an object that is not a valid instance of CharacterData."
);
}
return esValue[implSymbol]["data"];
@@ -356,11 +371,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set data' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'set data' called on an object that is not a valid instance of CharacterData."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'data' property on 'CharacterData': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -371,7 +389,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of CharacterData.");
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of CharacterData."
);
}
return esValue[implSymbol]["length"];
@@ -381,7 +401,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get previousElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
@@ -393,7 +413,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get nextElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
@@ -421,10 +441,7 @@ exports.install = (globalObject, globalNames) => {
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CharacterData;
ctorRegistry[interfaceName] = CharacterData;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CloseEvent'.`);
throw new globalObject.TypeError(`${context} is not of type 'CloseEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CloseEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CloseEvent is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CloseEvent"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,25 +89,28 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate CloseEvent before Event");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CloseEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CloseEvent': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'CloseEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CloseEvent': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'CloseEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CloseEventInit.convert(curArg, { context: "Failed to construct 'CloseEvent': parameter 2" });
curArg = CloseEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'CloseEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -117,7 +120,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get wasClean' called on an object that is not a valid instance of CloseEvent.");
throw new globalObject.TypeError(
"'get wasClean' called on an object that is not a valid instance of CloseEvent."
);
}
return esValue[implSymbol]["wasClean"];
@@ -127,7 +132,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get code' called on an object that is not a valid instance of CloseEvent.");
throw new globalObject.TypeError("'get code' called on an object that is not a valid instance of CloseEvent.");
}
return esValue[implSymbol]["code"];
@@ -137,7 +142,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get reason' called on an object that is not a valid instance of CloseEvent.");
throw new globalObject.TypeError(
"'get reason' called on an object that is not a valid instance of CloseEvent."
);
}
return esValue[implSymbol]["reason"];
@@ -149,10 +156,7 @@ exports.install = (globalObject, globalNames) => {
reason: { enumerable: true },
[Symbol.toStringTag]: { value: "CloseEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CloseEvent;
ctorRegistry[interfaceName] = CloseEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -5,14 +5,17 @@ const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "code";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned short"](value, { context: context + " has member 'code' that" });
value = conversions["unsigned short"](value, {
context: context + " has member 'code' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -24,7 +27,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "reason";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["USVString"](value, { context: context + " has member 'reason' that" });
value = conversions["USVString"](value, {
context: context + " has member 'reason' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -36,7 +42,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "wasClean";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'wasClean' that" });
value = conversions["boolean"](value, {
context: context + " has member 'wasClean' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -45,12 +54,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Comment'.`);
throw new globalObject.TypeError(`${context} is not of type 'Comment'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["Comment"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Comment is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Comment"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -65,8 +65,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -88,16 +88,17 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.CharacterData === undefined) {
throw new Error("Internal error: attempting to evaluate Comment before CharacterData");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Comment extends globalObject.CharacterData {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Comment': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'Comment': parameter 1",
globals: globalObject
});
} else {
curArg = "";
}
@@ -107,10 +108,7 @@ exports.install = (globalObject, globalNames) => {
}
}
Object.defineProperties(Comment.prototype, { [Symbol.toStringTag]: { value: "Comment", configurable: true } });
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Comment;
ctorRegistry[interfaceName] = Comment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CompositionEvent'.`);
throw new globalObject.TypeError(`${context} is not of type 'CompositionEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CompositionEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CompositionEvent is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CompositionEvent"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,25 +89,26 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.UIEvent === undefined) {
throw new Error("Internal error: attempting to evaluate CompositionEvent before UIEvent");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CompositionEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CompositionEvent': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'CompositionEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CompositionEvent': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'CompositionEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CompositionEventInit.convert(curArg, {
curArg = CompositionEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'CompositionEvent': parameter 2"
});
args.push(curArg);
@@ -118,23 +119,22 @@ exports.install = (globalObject, globalNames) => {
initCompositionEvent(typeArg) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'initCompositionEvent' called on an object that is not a valid instance of CompositionEvent."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1"
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -142,7 +142,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2"
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2",
globals: globalObject
});
} else {
curArg = false;
@@ -153,7 +154,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3"
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3",
globals: globalObject
});
} else {
curArg = false;
@@ -177,7 +179,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[4];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5"
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5",
globals: globalObject
});
} else {
curArg = "";
@@ -191,7 +194,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get data' called on an object that is not a valid instance of CompositionEvent.");
throw new globalObject.TypeError(
"'get data' called on an object that is not a valid instance of CompositionEvent."
);
}
return esValue[implSymbol]["data"];
@@ -202,10 +207,7 @@ exports.install = (globalObject, globalNames) => {
data: { enumerable: true },
[Symbol.toStringTag]: { value: "CompositionEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CompositionEvent;
ctorRegistry[interfaceName] = CompositionEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -5,14 +5,14 @@ const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "data";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'data' that" });
value = conversions["DOMString"](value, { context: context + " has member 'data' that", globals: globalObject });
ret[key] = value;
} else {
@@ -21,12 +21,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

134
node_modules/jsdom/lib/jsdom/living/generated/Crypto.js generated vendored Normal file
View File

@@ -0,0 +1,134 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Crypto";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'Crypto'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Crypto"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Crypto {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
getRandomValues(array) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getRandomValues' called on an object that is not a valid instance of Crypto."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'getRandomValues' on 'Crypto': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
if (ArrayBuffer.isView(curArg)) {
} else {
throw new globalObject.TypeError(
"Failed to execute 'getRandomValues' on 'Crypto': parameter 1" + " is not of any supported type."
);
}
args.push(curArg);
}
return esValue[implSymbol].getRandomValues(...args);
}
}
Object.defineProperties(Crypto.prototype, {
getRandomValues: { enumerable: true },
[Symbol.toStringTag]: { value: "Crypto", configurable: true }
});
ctorRegistry[interfaceName] = Crypto;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Crypto
});
};
const Impl = require("../crypto/Crypto-impl.js");

View File

@@ -3,22 +3,18 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction() {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
callResult = Reflect.apply(value, thisArg, []);
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
@@ -26,7 +22,7 @@ exports.convert = (value, { context = "The provided value" } = {}) => {
invokeTheCallbackFunction.construct = () => {
let callResult = Reflect.construct(value, []);
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};

View File

@@ -19,24 +19,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CustomElementRegistry'.`);
throw new globalObject.TypeError(`${context} is not of type 'CustomElementRegistry'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CustomElementRegistry"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CustomElementRegistry is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CustomElementRegistry"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,42 +89,45 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CustomElementRegistry {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
define(name, constructor) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'define' called on an object that is not a valid instance of CustomElementRegistry.");
throw new globalObject.TypeError(
"'define' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'define' on 'CustomElementRegistry': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'define' on 'CustomElementRegistry': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 1"
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CustomElementConstructor.convert(curArg, {
curArg = CustomElementConstructor.convert(globalObject, curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = ElementDefinitionOptions.convert(curArg, {
curArg = ElementDefinitionOptions.convert(globalObject, curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 3"
});
args.push(curArg);
@@ -140,21 +143,22 @@ exports.install = (globalObject, globalNames) => {
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get' called on an object that is not a valid instance of CustomElementRegistry.");
throw new globalObject.TypeError(
"'get' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'get' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'get' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'get' on 'CustomElementRegistry': parameter 1"
context: "Failed to execute 'get' on 'CustomElementRegistry': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -165,49 +169,48 @@ exports.install = (globalObject, globalNames) => {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'whenDefined' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'whenDefined' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'whenDefined' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'whenDefined' on 'CustomElementRegistry': parameter 1"
context: "Failed to execute 'whenDefined' on 'CustomElementRegistry': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].whenDefined(...args));
} catch (e) {
return Promise.reject(e);
return globalObject.Promise.reject(e);
}
}
upgrade(root) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'upgrade' called on an object that is not a valid instance of CustomElementRegistry.");
throw new globalObject.TypeError(
"'upgrade' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'upgrade' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'upgrade' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Node.convert(curArg, {
curArg = Node.convert(globalObject, curArg, {
context: "Failed to execute 'upgrade' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
@@ -227,10 +230,7 @@ exports.install = (globalObject, globalNames) => {
upgrade: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomElementRegistry", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CustomElementRegistry;
ctorRegistry[interfaceName] = CustomElementRegistry;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CustomEvent'.`);
throw new globalObject.TypeError(`${context} is not of type 'CustomEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["CustomEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CustomEvent is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CustomEvent"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,25 +89,28 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate CustomEvent before Event");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CustomEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'CustomEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CustomEvent': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'CustomEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CustomEventInit.convert(curArg, { context: "Failed to construct 'CustomEvent': parameter 2" });
curArg = CustomEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'CustomEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -116,21 +119,22 @@ exports.install = (globalObject, globalNames) => {
initCustomEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'initCustomEvent' called on an object that is not a valid instance of CustomEvent.");
throw new globalObject.TypeError(
"'initCustomEvent' called on an object that is not a valid instance of CustomEvent."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1"
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -138,7 +142,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2"
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2",
globals: globalObject
});
} else {
curArg = false;
@@ -149,7 +154,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3"
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3",
globals: globalObject
});
} else {
curArg = false;
@@ -160,7 +166,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[3];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4"
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4",
globals: globalObject
});
} else {
curArg = null;
@@ -174,7 +181,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get detail' called on an object that is not a valid instance of CustomEvent.");
throw new globalObject.TypeError(
"'get detail' called on an object that is not a valid instance of CustomEvent."
);
}
return esValue[implSymbol]["detail"];
@@ -185,10 +194,7 @@ exports.install = (globalObject, globalNames) => {
detail: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CustomEvent;
ctorRegistry[interfaceName] = CustomEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -5,14 +5,14 @@ const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "detail";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["any"](value, { context: context + " has member 'detail' that" });
value = conversions["any"](value, { context: context + " has member 'detail' that", globals: globalObject });
ret[key] = value;
} else {
@@ -21,12 +21,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMImplementation'.`);
throw new globalObject.TypeError(`${context} is not of type 'DOMImplementation'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DOMImplementation"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMImplementation is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMImplementation"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -63,8 +63,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -85,45 +85,48 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMImplementation {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
createDocumentType(qualifiedName, publicId, systemId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'createDocumentType' called on an object that is not a valid instance of DOMImplementation."
);
}
if (arguments.length < 3) {
throw new TypeError(
"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1"
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2"
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3"
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3",
globals: globalObject
});
args.push(curArg);
}
@@ -133,14 +136,14 @@ exports.install = (globalObject, globalNames) => {
createDocument(namespace, qualifiedName) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'createDocument' called on an object that is not a valid instance of DOMImplementation.");
throw new globalObject.TypeError(
"'createDocument' called on an object that is not a valid instance of DOMImplementation."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
@@ -150,7 +153,8 @@ exports.install = (globalObject, globalNames) => {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1"
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1",
globals: globalObject
});
}
args.push(curArg);
@@ -159,6 +163,7 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2",
globals: globalObject,
treatNullAsEmptyString: true
});
args.push(curArg);
@@ -169,7 +174,7 @@ exports.install = (globalObject, globalNames) => {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = DocumentType.convert(curArg, {
curArg = DocumentType.convert(globalObject, curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3"
});
}
@@ -184,7 +189,7 @@ exports.install = (globalObject, globalNames) => {
createHTMLDocument() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation."
);
}
@@ -193,7 +198,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1"
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1",
globals: globalObject
});
}
args.push(curArg);
@@ -204,7 +210,9 @@ exports.install = (globalObject, globalNames) => {
hasFeature() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'hasFeature' called on an object that is not a valid instance of DOMImplementation.");
throw new globalObject.TypeError(
"'hasFeature' called on an object that is not a valid instance of DOMImplementation."
);
}
return esValue[implSymbol].hasFeature();
@@ -217,10 +225,7 @@ exports.install = (globalObject, globalNames) => {
hasFeature: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMImplementation", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMImplementation;
ctorRegistry[interfaceName] = DOMImplementation;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMParser'.`);
throw new globalObject.TypeError(`${context} is not of type 'DOMParser'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DOMParser"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMParser is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMParser"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -63,8 +63,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -85,6 +85,8 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMParser {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
@@ -93,27 +95,28 @@ exports.install = (globalObject, globalNames) => {
parseFromString(str, type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'parseFromString' called on an object that is not a valid instance of DOMParser.");
throw new globalObject.TypeError(
"'parseFromString' called on an object that is not a valid instance of DOMParser."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1"
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = SupportedType.convert(curArg, {
curArg = SupportedType.convert(globalObject, curArg, {
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2"
});
args.push(curArg);
@@ -125,10 +128,7 @@ exports.install = (globalObject, globalNames) => {
parseFromString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMParser", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMParser;
ctorRegistry[interfaceName] = DOMParser;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMStringMap'.`);
throw new globalObject.TypeError(`${context} is not of type 'DOMStringMap'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DOMStringMap"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMStringMap is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMStringMap"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
function makeProxy(wrapper, globalObject) {
@@ -75,8 +75,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -99,18 +99,17 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMStringMap {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(DOMStringMap.prototype, {
[Symbol.toStringTag]: { value: "DOMStringMap", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMStringMap;
ctorRegistry[interfaceName] = DOMStringMap;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
@@ -210,7 +209,8 @@ class ProxyHandler {
let namedValue = V;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -276,7 +276,8 @@ class ProxyHandler {
let namedValue = desc.value;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);

View File

@@ -16,24 +16,33 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMTokenList'.`);
throw new globalObject.TypeError(`${context} is not of type 'DOMTokenList'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DOMTokenList"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMTokenList is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMTokenList"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
function makeProxy(wrapper, globalObject) {
let proxyHandler = proxyHandlerCache.get(globalObject);
if (proxyHandler === undefined) {
proxyHandler = new ProxyHandler(globalObject);
proxyHandlerCache.set(globalObject, proxyHandler);
}
return new Proxy(wrapper, proxyHandler);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -57,7 +66,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -66,8 +75,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -75,7 +84,7 @@ exports.new = globalObject => {
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -90,27 +99,30 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMTokenList {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'item' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'item' on 'DOMTokenList': 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 'DOMTokenList': parameter 1"
context: "Failed to execute 'item' on 'DOMTokenList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -120,21 +132,22 @@ exports.install = (globalObject, globalNames) => {
contains(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'contains' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'contains' called on an object that is not a valid instance of DOMTokenList."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1"
context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -144,13 +157,14 @@ exports.install = (globalObject, globalNames) => {
add() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'add' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError("'add' called on an object that is not a valid instance of DOMTokenList.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1)
context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1),
globals: globalObject
});
args.push(curArg);
}
@@ -165,13 +179,14 @@ exports.install = (globalObject, globalNames) => {
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of DOMTokenList.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1)
context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1),
globals: globalObject
});
args.push(curArg);
}
@@ -186,21 +201,20 @@ exports.install = (globalObject, globalNames) => {
toggle(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'toggle' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError("'toggle' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1"
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -208,7 +222,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2"
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2",
globals: globalObject
});
}
args.push(curArg);
@@ -224,28 +239,28 @@ exports.install = (globalObject, globalNames) => {
replace(token, newToken) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replace' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError("'replace' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1"
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2"
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -260,21 +275,22 @@ exports.install = (globalObject, globalNames) => {
supports(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'supports' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'supports' called on an object that is not a valid instance of DOMTokenList."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1"
context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -285,7 +301,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of DOMTokenList."
);
}
return esValue[implSymbol]["length"];
@@ -295,7 +313,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of DOMTokenList."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -310,11 +330,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'set value' called on an object that is not a valid instance of DOMTokenList."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'value' property on 'DOMTokenList': The provided value"
context: "Failed to set the 'value' property on 'DOMTokenList': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -328,7 +351,9 @@ exports.install = (globalObject, globalNames) => {
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of DOMTokenList.");
throw new globalObject.TypeError(
"'toString' called on an object that is not a valid instance of DOMTokenList."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -351,16 +376,13 @@ exports.install = (globalObject, globalNames) => {
value: { enumerable: true },
toString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMTokenList", configurable: true },
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true },
keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true },
values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true },
entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true },
forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true }
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true },
keys: { value: globalObject.Array.prototype.keys, configurable: true, enumerable: true, writable: true },
values: { value: globalObject.Array.prototype.values, configurable: true, enumerable: true, writable: true },
entries: { value: globalObject.Array.prototype.entries, configurable: true, enumerable: true, writable: true },
forEach: { value: globalObject.Array.prototype.forEach, configurable: true, enumerable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMTokenList;
ctorRegistry[interfaceName] = DOMTokenList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
@@ -369,7 +391,12 @@ exports.install = (globalObject, globalNames) => {
});
};
const proxyHandler = {
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
@@ -390,7 +417,7 @@ const proxyHandler = {
return undefined;
}
return Reflect.apply(getter, receiver, []);
},
}
has(target, P) {
if (typeof P === "symbol") {
@@ -405,7 +432,7 @@ const proxyHandler = {
return Reflect.has(parent, P);
}
return false;
},
}
ownKeys(target) {
const keys = new Set();
@@ -418,7 +445,7 @@ const proxyHandler = {
keys.add(key);
}
return [...keys];
},
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
@@ -441,7 +468,7 @@ const proxyHandler = {
}
return Reflect.getOwnPropertyDescriptor(target, P);
},
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
@@ -450,6 +477,7 @@ const proxyHandler = {
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
@@ -496,36 +524,40 @@ const proxyHandler = {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
},
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
return Reflect.defineProperty(target, P, desc);
},
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol].item(index) !== null);
}
return Reflect.deleteProperty(target, P);
},
}
preventExtensions() {
return false;
}
};
}
const Impl = require("../nodes/DOMTokenList-impl.js");

File diff suppressed because it is too large Load Diff

View File

@@ -17,24 +17,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DocumentFragment'.`);
throw new globalObject.TypeError(`${context} is not of type 'DocumentFragment'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DocumentFragment"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DocumentFragment is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DocumentFragment"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -90,9 +90,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate DocumentFragment before Node");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DocumentFragment extends globalObject.Node {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
@@ -101,21 +99,22 @@ exports.install = (globalObject, globalNames) => {
getElementById(elementId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'getElementById' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'getElementById' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1"
context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -125,7 +124,9 @@ exports.install = (globalObject, globalNames) => {
prepend() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'prepend' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'prepend' called on an object that is not a valid instance of DocumentFragment."
);
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -134,7 +135,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1)
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -150,7 +152,9 @@ exports.install = (globalObject, globalNames) => {
append() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'append' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'append' called on an object that is not a valid instance of DocumentFragment."
);
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -159,7 +163,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1)
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -175,7 +180,9 @@ exports.install = (globalObject, globalNames) => {
replaceChildren() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceChildren' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'replaceChildren' called on an object that is not a valid instance of DocumentFragment."
);
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -184,14 +191,15 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceChildren' on 'DocumentFragment': parameter " + (i + 1)
context: "Failed to execute 'replaceChildren' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return utils.tryWrapperForImpl(esValue[implSymbol].replaceChildren(...args));
return esValue[implSymbol].replaceChildren(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@@ -200,21 +208,22 @@ exports.install = (globalObject, globalNames) => {
querySelector(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'querySelector' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'querySelector' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1"
context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -224,21 +233,22 @@ exports.install = (globalObject, globalNames) => {
querySelectorAll(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'querySelectorAll' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'querySelectorAll' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1"
context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -249,7 +259,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get children' called on an object that is not a valid instance of DocumentFragment.");
throw new globalObject.TypeError(
"'get children' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.getSameObject(this, "children", () => {
@@ -261,7 +273,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get firstElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
@@ -273,7 +285,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get lastElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
@@ -285,7 +297,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get childElementCount' called on an object that is not a valid instance of DocumentFragment."
);
}
@@ -310,10 +322,7 @@ exports.install = (globalObject, globalNames) => {
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DocumentFragment;
ctorRegistry[interfaceName] = DocumentFragment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,10 +3,10 @@
const enumerationValues = new Set(["loading", "interactive", "complete"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`);
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`);
}
return string;
};

View File

@@ -17,24 +17,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DocumentType'.`);
throw new globalObject.TypeError(`${context} is not of type 'DocumentType'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DocumentType"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DocumentType is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DocumentType"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -90,18 +90,16 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate DocumentType before Node");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DocumentType extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'before' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError("'before' called on an object that is not a valid instance of DocumentType.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -110,7 +108,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1)
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -126,7 +125,7 @@ exports.install = (globalObject, globalNames) => {
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'after' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError("'after' called on an object that is not a valid instance of DocumentType.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -135,7 +134,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1)
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -151,7 +151,9 @@ exports.install = (globalObject, globalNames) => {
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceWith' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError(
"'replaceWith' called on an object that is not a valid instance of DocumentType."
);
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
@@ -160,7 +162,8 @@ exports.install = (globalObject, globalNames) => {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1)
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
@@ -176,7 +179,7 @@ exports.install = (globalObject, globalNames) => {
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of DocumentType.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -191,7 +194,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["name"];
@@ -201,7 +206,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get publicId' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError(
"'get publicId' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["publicId"];
@@ -211,7 +218,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get systemId' called on an object that is not a valid instance of DocumentType.");
throw new globalObject.TypeError(
"'get systemId' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["systemId"];
@@ -231,10 +240,7 @@ exports.install = (globalObject, globalNames) => {
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DocumentType;
ctorRegistry[interfaceName] = DocumentType;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

File diff suppressed because it is too large Load Diff

View File

@@ -3,24 +3,24 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "is";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'is' that" });
value = conversions["DOMString"](value, { context: context + " has member 'is' that", globals: globalObject });
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -3,24 +3,27 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "extends";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'extends' that" });
value = conversions["DOMString"](value, {
context: context + " has member 'extends' that",
globals: globalObject
});
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -3,10 +3,10 @@
const enumerationValues = new Set(["transparent", "native"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`);
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`);
}
return string;
};

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'ErrorEvent'.`);
throw new globalObject.TypeError(`${context} is not of type 'ErrorEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["ErrorEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor ErrorEvent is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["ErrorEvent"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,25 +89,28 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate ErrorEvent before Event");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class ErrorEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'ErrorEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'ErrorEvent': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'ErrorEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = ErrorEventInit.convert(curArg, { context: "Failed to construct 'ErrorEvent': parameter 2" });
curArg = ErrorEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'ErrorEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -117,7 +120,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get message' called on an object that is not a valid instance of ErrorEvent.");
throw new globalObject.TypeError(
"'get message' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["message"];
@@ -127,7 +132,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get filename' called on an object that is not a valid instance of ErrorEvent.");
throw new globalObject.TypeError(
"'get filename' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["filename"];
@@ -137,7 +144,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get lineno' called on an object that is not a valid instance of ErrorEvent.");
throw new globalObject.TypeError(
"'get lineno' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["lineno"];
@@ -147,7 +156,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get colno' called on an object that is not a valid instance of ErrorEvent.");
throw new globalObject.TypeError("'get colno' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["colno"];
@@ -157,7 +166,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get error' called on an object that is not a valid instance of ErrorEvent.");
throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["error"];
@@ -171,10 +180,7 @@ exports.install = (globalObject, globalNames) => {
error: { enumerable: true },
[Symbol.toStringTag]: { value: "ErrorEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = ErrorEvent;
ctorRegistry[interfaceName] = ErrorEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -5,14 +5,17 @@ const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "colno";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned long"](value, { context: context + " has member 'colno' that" });
value = conversions["unsigned long"](value, {
context: context + " has member 'colno' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -24,7 +27,7 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "error";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["any"](value, { context: context + " has member 'error' that" });
value = conversions["any"](value, { context: context + " has member 'error' that", globals: globalObject });
ret[key] = value;
} else {
@@ -36,7 +39,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "filename";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["USVString"](value, { context: context + " has member 'filename' that" });
value = conversions["USVString"](value, {
context: context + " has member 'filename' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -48,7 +54,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "lineno";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned long"](value, { context: context + " has member 'lineno' that" });
value = conversions["unsigned long"](value, {
context: context + " has member 'lineno' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -60,7 +69,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "message";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'message' that" });
value = conversions["DOMString"](value, {
context: context + " has member 'message' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -69,12 +81,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -15,24 +15,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Event'.`);
throw new globalObject.TypeError(`${context} is not of type 'Event'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["Event"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Event is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Event"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -45,23 +45,33 @@ exports.createImpl = (globalObject, constructorArgs, privateData) => {
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Object.defineProperties(
wrapper,
Object.getOwnPropertyDescriptors({
function getUnforgeables(globalObject) {
let unforgeables = unforgeablesMap.get(globalObject);
if (unforgeables === undefined) {
unforgeables = Object.create(null);
utils.define(unforgeables, {
get isTrusted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get isTrusted' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'get isTrusted' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["isTrusted"];
}
})
);
});
Object.defineProperties(unforgeables, {
isTrusted: { configurable: false }
});
unforgeablesMap.set(globalObject, unforgeables);
}
return unforgeables;
}
Object.defineProperties(wrapper, { isTrusted: { configurable: false } });
exports._internalSetup = (wrapper, globalObject) => {
utils.define(wrapper, getUnforgeables(globalObject));
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
@@ -80,8 +90,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -96,28 +106,34 @@ exports.new = globalObject => {
return wrapper[implSymbol];
};
const unforgeablesMap = new WeakMap();
const exposed = new Set(["Window", "Worker", "AudioWorklet"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'Event': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Event': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'Event': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = EventInit.convert(curArg, { context: "Failed to construct 'Event': parameter 2" });
curArg = EventInit.convert(globalObject, curArg, { context: "Failed to construct 'Event': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -126,7 +142,7 @@ exports.install = (globalObject, globalNames) => {
composedPath() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'composedPath' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'composedPath' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].composedPath());
@@ -135,7 +151,9 @@ exports.install = (globalObject, globalNames) => {
stopPropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'stopPropagation' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'stopPropagation' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol].stopPropagation();
@@ -144,7 +162,9 @@ exports.install = (globalObject, globalNames) => {
stopImmediatePropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'stopImmediatePropagation' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'stopImmediatePropagation' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol].stopImmediatePropagation();
@@ -153,7 +173,7 @@ exports.install = (globalObject, globalNames) => {
preventDefault() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'preventDefault' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'preventDefault' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol].preventDefault();
@@ -162,24 +182,30 @@ exports.install = (globalObject, globalNames) => {
initEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'initEvent' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'initEvent' called on an object that is not a valid instance of Event.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initEvent' on 'Event': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'initEvent' on 'Event': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initEvent' on 'Event': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 2" });
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initEvent' on 'Event': parameter 2",
globals: globalObject
});
} else {
curArg = false;
}
@@ -188,7 +214,10 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 3" });
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initEvent' on 'Event': parameter 3",
globals: globalObject
});
} else {
curArg = false;
}
@@ -201,7 +230,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["type"];
@@ -211,7 +240,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get target' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["target"]);
@@ -221,7 +250,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get srcElement' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get srcElement' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["srcElement"]);
@@ -231,7 +260,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get currentTarget' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'get currentTarget' called on an object that is not a valid instance of Event."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["currentTarget"]);
@@ -241,7 +272,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get eventPhase' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get eventPhase' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["eventPhase"];
@@ -251,7 +282,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get cancelBubble' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'get cancelBubble' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["cancelBubble"];
@@ -261,11 +294,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set cancelBubble' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'set cancelBubble' called on an object that is not a valid instance of Event."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'cancelBubble' property on 'Event': The provided value"
context: "Failed to set the 'cancelBubble' property on 'Event': The provided value",
globals: globalObject
});
esValue[implSymbol]["cancelBubble"] = V;
@@ -275,7 +311,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get bubbles' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get bubbles' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["bubbles"];
@@ -285,7 +321,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get cancelable' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get cancelable' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["cancelable"];
@@ -295,7 +331,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get returnValue' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'get returnValue' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["returnValue"];
@@ -305,11 +343,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set returnValue' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'set returnValue' called on an object that is not a valid instance of Event."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'returnValue' property on 'Event': The provided value"
context: "Failed to set the 'returnValue' property on 'Event': The provided value",
globals: globalObject
});
esValue[implSymbol]["returnValue"] = V;
@@ -319,7 +360,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get defaultPrevented' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError(
"'get defaultPrevented' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["defaultPrevented"];
@@ -329,7 +372,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get composed' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get composed' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["composed"];
@@ -339,7 +382,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get timeStamp' called on an object that is not a valid instance of Event.");
throw new globalObject.TypeError("'get timeStamp' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["timeStamp"];
@@ -375,10 +418,7 @@ exports.install = (globalObject, globalNames) => {
AT_TARGET: { value: 2, enumerable: true },
BUBBLING_PHASE: { value: 3, enumerable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Event;
ctorRegistry[interfaceName] = Event;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,12 +3,8 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
function invokeTheCallbackFunction(event) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
@@ -18,7 +14,7 @@ exports.convert = (value, { context = "The provided value" } = {}) => {
callResult = Reflect.apply(value, thisArg, [event]);
}
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
@@ -28,7 +24,7 @@ exports.convert = (value, { context = "The provided value" } = {}) => {
let callResult = Reflect.construct(value, [event]);
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};

View File

@@ -3,12 +3,12 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "bubbles";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'bubbles' that" });
value = conversions["boolean"](value, { context: context + " has member 'bubbles' that", globals: globalObject });
ret[key] = value;
} else {
@@ -20,7 +20,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "cancelable";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'cancelable' that" });
value = conversions["boolean"](value, {
context: context + " has member 'cancelable' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -32,7 +35,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "composed";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
value = conversions["boolean"](value, {
context: context + " has member 'composed' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -41,12 +47,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -3,9 +3,9 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = function convert(value, { context = "The provided value" } = {}) {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (!utils.isObject(value)) {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
function callTheUserObjectsOperation(event) {
@@ -16,7 +16,7 @@ exports.convert = function convert(value, { context = "The provided value" } = {
if (typeof O !== "function") {
X = O["handleEvent"];
if (typeof X !== "function") {
throw new TypeError(`${context} does not correctly implement EventListener.`);
throw new globalObject.TypeError(`${context} does not correctly implement EventListener.`);
}
thisArg = O;
}

View File

@@ -3,12 +3,12 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "capture";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'capture' that" });
value = conversions["boolean"](value, { context: context + " has member 'capture' that", globals: globalObject });
ret[key] = value;
} else {
@@ -17,12 +17,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -5,14 +5,14 @@ const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "altKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'altKey' that" });
value = conversions["boolean"](value, { context: context + " has member 'altKey' that", globals: globalObject });
ret[key] = value;
} else {
@@ -24,7 +24,7 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "ctrlKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'ctrlKey' that" });
value = conversions["boolean"](value, { context: context + " has member 'ctrlKey' that", globals: globalObject });
ret[key] = value;
} else {
@@ -36,7 +36,7 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "metaKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'metaKey' that" });
value = conversions["boolean"](value, { context: context + " has member 'metaKey' that", globals: globalObject });
ret[key] = value;
} else {
@@ -48,7 +48,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierAltGraph";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierAltGraph' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierAltGraph' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -60,7 +63,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierCapsLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierCapsLock' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierCapsLock' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -72,7 +78,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierFn";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierFn' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierFn' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -84,7 +93,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierFnLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierFnLock' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierFnLock' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -96,7 +108,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierHyper";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierHyper' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierHyper' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -108,7 +123,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierNumLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierNumLock' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierNumLock' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -120,7 +138,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierScrollLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierScrollLock' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierScrollLock' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -132,7 +153,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierSuper";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSuper' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierSuper' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -144,7 +168,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierSymbol";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbol' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierSymbol' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -156,7 +183,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "modifierSymbolLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbolLock' that" });
value = conversions["boolean"](value, {
context: context + " has member 'modifierSymbolLock' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -168,7 +198,10 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
const key = "shiftKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'shiftKey' that" });
value = conversions["boolean"](value, {
context: context + " has member 'shiftKey' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -177,12 +210,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'EventTarget'.`);
throw new globalObject.TypeError(`${context} is not of type 'EventTarget'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["EventTarget"];
if (ctor === undefined) {
throw new Error("Internal error: constructor EventTarget is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["EventTarget"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -88,6 +88,8 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
@@ -96,21 +98,22 @@ exports.install = (globalObject, globalNames) => {
addEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'addEventListener' called on an object that is not a valid instance of EventTarget.");
throw new globalObject.TypeError(
"'addEventListener' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1"
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -119,7 +122,7 @@ exports.install = (globalObject, globalNames) => {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(curArg, {
curArg = EventListener.convert(globalObject, curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 2"
});
}
@@ -129,20 +132,22 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = AddEventListenerOptions.convert(curArg, {
curArg = AddEventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(curArg)) {
curArg = AddEventListenerOptions.convert(curArg, {
curArg = AddEventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + " dictionary"
});
} else if (typeof curArg === "boolean") {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
}
}
@@ -154,21 +159,22 @@ exports.install = (globalObject, globalNames) => {
removeEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'removeEventListener' called on an object that is not a valid instance of EventTarget.");
throw new globalObject.TypeError(
"'removeEventListener' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1"
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -177,7 +183,7 @@ exports.install = (globalObject, globalNames) => {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(curArg, {
curArg = EventListener.convert(globalObject, curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 2"
});
}
@@ -187,20 +193,22 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = EventListenerOptions.convert(curArg, {
curArg = EventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(curArg)) {
curArg = EventListenerOptions.convert(curArg, {
curArg = EventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + " dictionary"
});
} else if (typeof curArg === "boolean") {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
}
}
@@ -212,20 +220,22 @@ exports.install = (globalObject, globalNames) => {
dispatchEvent(event) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'dispatchEvent' called on an object that is not a valid instance of EventTarget.");
throw new globalObject.TypeError(
"'dispatchEvent' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Event.convert(curArg, { context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1" });
curArg = Event.convert(globalObject, curArg, {
context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].dispatchEvent(...args);
@@ -237,10 +247,7 @@ exports.install = (globalObject, globalNames) => {
dispatchEvent: { enumerable: true },
[Symbol.toStringTag]: { value: "EventTarget", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = EventTarget;
ctorRegistry[interfaceName] = EventTarget;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -14,24 +14,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'External'.`);
throw new globalObject.TypeError(`${context} is not of type 'External'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["External"];
if (ctor === undefined) {
throw new Error("Internal error: constructor External is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["External"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -62,8 +62,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -84,15 +84,19 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class External {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
AddSearchProvider() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'AddSearchProvider' called on an object that is not a valid instance of External.");
throw new globalObject.TypeError(
"'AddSearchProvider' called on an object that is not a valid instance of External."
);
}
return esValue[implSymbol].AddSearchProvider();
@@ -101,7 +105,7 @@ exports.install = (globalObject, globalNames) => {
IsSearchProviderInstalled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'IsSearchProviderInstalled' called on an object that is not a valid instance of External."
);
}
@@ -114,10 +118,7 @@ exports.install = (globalObject, globalNames) => {
IsSearchProviderInstalled: { enumerable: true },
[Symbol.toStringTag]: { value: "External", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = External;
ctorRegistry[interfaceName] = External;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'File'.`);
throw new globalObject.TypeError(`${context} is not of type 'File'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["File"];
if (ctor === undefined) {
throw new Error("Internal error: constructor File is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["File"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,21 +89,19 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.Blob === undefined) {
throw new Error("Internal error: attempting to evaluate File before Blob");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class File extends globalObject.Blob {
constructor(fileBits, fileName) {
if (arguments.length < 2) {
throw new TypeError(
"Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
if (!utils.isObject(curArg)) {
throw new TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
throw new globalObject.TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
@@ -114,7 +112,8 @@ exports.install = (globalObject, globalNames) => {
} else if (ArrayBuffer.isView(nextItem)) {
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'File': parameter 1" + "'s element"
context: "Failed to construct 'File': parameter 1" + "'s element",
globals: globalObject
});
}
V.push(nextItem);
@@ -125,12 +124,15 @@ exports.install = (globalObject, globalNames) => {
}
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'File': parameter 2" });
curArg = conversions["USVString"](curArg, {
context: "Failed to construct 'File': parameter 2",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = FilePropertyBag.convert(curArg, { context: "Failed to construct 'File': parameter 3" });
curArg = FilePropertyBag.convert(globalObject, curArg, { context: "Failed to construct 'File': parameter 3" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -140,7 +142,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of File.");
throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of File.");
}
return esValue[implSymbol]["name"];
@@ -150,7 +152,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get lastModified' called on an object that is not a valid instance of File.");
throw new globalObject.TypeError(
"'get lastModified' called on an object that is not a valid instance of File."
);
}
return esValue[implSymbol]["lastModified"];
@@ -161,10 +165,7 @@ exports.install = (globalObject, globalNames) => {
lastModified: { enumerable: true },
[Symbol.toStringTag]: { value: "File", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = File;
ctorRegistry[interfaceName] = File;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -14,24 +14,33 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FileList'.`);
throw new globalObject.TypeError(`${context} is not of type 'FileList'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["FileList"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FileList is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FileList"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
function makeProxy(wrapper, globalObject) {
let proxyHandler = proxyHandlerCache.get(globalObject);
if (proxyHandler === undefined) {
proxyHandler = new ProxyHandler(globalObject);
proxyHandlerCache.set(globalObject, proxyHandler);
}
return new Proxy(wrapper, proxyHandler);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -55,7 +64,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -64,8 +73,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -73,7 +82,7 @@ exports.new = globalObject => {
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -88,27 +97,30 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class FileList {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'item' called on an object that is not a valid instance of FileList.");
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of FileList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'item' on 'FileList': 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 'FileList': parameter 1"
context: "Failed to execute 'item' on 'FileList': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -119,7 +131,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of FileList.");
throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of FileList.");
}
return esValue[implSymbol]["length"];
@@ -129,12 +141,9 @@ exports.install = (globalObject, globalNames) => {
item: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "FileList", configurable: true },
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FileList;
ctorRegistry[interfaceName] = FileList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
@@ -143,7 +152,12 @@ exports.install = (globalObject, globalNames) => {
});
};
const proxyHandler = {
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
@@ -164,7 +178,7 @@ const proxyHandler = {
return undefined;
}
return Reflect.apply(getter, receiver, []);
},
}
has(target, P) {
if (typeof P === "symbol") {
@@ -179,7 +193,7 @@ const proxyHandler = {
return Reflect.has(parent, P);
}
return false;
},
}
ownKeys(target) {
const keys = new Set();
@@ -192,7 +206,7 @@ const proxyHandler = {
keys.add(key);
}
return [...keys];
},
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
@@ -215,7 +229,7 @@ const proxyHandler = {
}
return Reflect.getOwnPropertyDescriptor(target, P);
},
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
@@ -224,6 +238,7 @@ const proxyHandler = {
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
@@ -270,36 +285,40 @@ const proxyHandler = {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
},
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
return Reflect.defineProperty(target, P, desc);
},
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol].item(index) !== null);
}
return Reflect.deleteProperty(target, P);
},
}
preventExtensions() {
return false;
}
};
}
const Impl = require("../file-api/FileList-impl.js");

View File

@@ -5,26 +5,29 @@ const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
BlobPropertyBag._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
BlobPropertyBag._convertInherit(globalObject, obj, ret, { context });
{
const key = "lastModified";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["long long"](value, { context: context + " has member 'lastModified' that" });
value = conversions["long long"](value, {
context: context + " has member 'lastModified' that",
globals: globalObject
});
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -17,24 +17,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FileReader'.`);
throw new globalObject.TypeError(`${context} is not of type 'FileReader'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["FileReader"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FileReader is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FileReader"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -67,8 +67,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -90,9 +90,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.EventTarget === undefined) {
throw new Error("Internal error: attempting to evaluate FileReader before EventTarget");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class FileReader extends globalObject.EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
@@ -101,20 +99,20 @@ exports.install = (globalObject, globalNames) => {
readAsArrayBuffer(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsArrayBuffer' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'readAsArrayBuffer' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, {
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1"
});
args.push(curArg);
@@ -125,20 +123,20 @@ exports.install = (globalObject, globalNames) => {
readAsBinaryString(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsBinaryString' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'readAsBinaryString' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsBinaryString' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'readAsBinaryString' on 'FileReader': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, {
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1"
});
args.push(curArg);
@@ -149,27 +147,30 @@ exports.install = (globalObject, globalNames) => {
readAsText(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsText' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'readAsText' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsText' on 'FileReader': parameter 1" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'readAsText' on 'FileReader': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'readAsText' on 'FileReader': parameter 2"
context: "Failed to execute 'readAsText' on 'FileReader': parameter 2",
globals: globalObject
});
}
args.push(curArg);
@@ -180,20 +181,22 @@ exports.install = (globalObject, globalNames) => {
readAsDataURL(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsDataURL' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'readAsDataURL' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsDataURL(...args);
@@ -202,7 +205,7 @@ exports.install = (globalObject, globalNames) => {
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'abort' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError("'abort' called on an object that is not a valid instance of FileReader.");
}
return esValue[implSymbol].abort();
@@ -212,7 +215,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get readyState' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get readyState' called on an object that is not a valid instance of FileReader."
);
}
return esValue[implSymbol]["readyState"];
@@ -222,7 +227,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get result' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get result' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["result"]);
@@ -232,7 +239,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get error' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["error"]);
@@ -242,7 +249,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onloadstart' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onloadstart' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]);
@@ -252,13 +261,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onloadstart' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onloadstart' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onloadstart' property on 'FileReader': The provided value"
});
}
@@ -269,7 +280,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onprogress' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onprogress' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]);
@@ -279,13 +292,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onprogress' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onprogress' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onprogress' property on 'FileReader': The provided value"
});
}
@@ -296,7 +311,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onload' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onload' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]);
@@ -306,13 +323,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onload' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onload' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onload' property on 'FileReader': The provided value"
});
}
@@ -323,7 +342,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onabort' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onabort' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
@@ -333,13 +354,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onabort' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onabort' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onabort' property on 'FileReader': The provided value"
});
}
@@ -350,7 +373,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onerror' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onerror' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]);
@@ -360,13 +385,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onerror' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onerror' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onerror' property on 'FileReader': The provided value"
});
}
@@ -377,7 +404,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onloadend' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'get onloadend' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]);
@@ -387,13 +416,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onloadend' called on an object that is not a valid instance of FileReader.");
throw new globalObject.TypeError(
"'set onloadend' called on an object that is not a valid instance of FileReader."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onloadend' property on 'FileReader': The provided value"
});
}
@@ -425,10 +456,7 @@ exports.install = (globalObject, globalNames) => {
LOADING: { value: 1, enumerable: true },
DONE: { value: 2, enumerable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FileReader;
ctorRegistry[interfaceName] = FileReader;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FocusEvent'.`);
throw new globalObject.TypeError(`${context} is not of type 'FocusEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["FocusEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FocusEvent is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FocusEvent"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,25 +89,28 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.UIEvent === undefined) {
throw new Error("Internal error: attempting to evaluate FocusEvent before UIEvent");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class FocusEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to construct 'FocusEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'FocusEvent': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'FocusEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = FocusEventInit.convert(curArg, { context: "Failed to construct 'FocusEvent': parameter 2" });
curArg = FocusEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'FocusEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
@@ -117,7 +120,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relatedTarget' called on an object that is not a valid instance of FocusEvent.");
throw new globalObject.TypeError(
"'get relatedTarget' called on an object that is not a valid instance of FocusEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]);
@@ -127,10 +132,7 @@ exports.install = (globalObject, globalNames) => {
relatedTarget: { enumerable: true },
[Symbol.toStringTag]: { value: "FocusEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FocusEvent;
ctorRegistry[interfaceName] = FocusEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -6,8 +6,8 @@ const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "relatedTarget";
@@ -16,7 +16,7 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
if (value === null || value === undefined) {
value = null;
} else {
value = EventTarget.convert(value, { context: context + " has member 'relatedTarget' that" });
value = EventTarget.convert(globalObject, value, { context: context + " has member 'relatedTarget' that" });
}
ret[key] = value;
} else {
@@ -25,12 +25,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -6,55 +6,29 @@ const utils = require("./utils.js");
const HTMLFormElement = require("./HTMLFormElement.js");
const Blob = require("./Blob.js");
const Function = require("./Function.js");
const newObjectInRealm = utils.newObjectInRealm;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "FormData";
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
next: {
value: function next() {
const internal = this && this[utils.iterInternalSymbol];
if (!internal) {
throw new TypeError("next() called on a value that is not an iterator prototype object");
}
const { target, kind, index } = internal;
const values = Array.from(target[implSymbol]);
const len = values.length;
if (index >= len) {
return { value: undefined, done: true };
}
const pair = values[index];
internal.index = index + 1;
return utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind);
},
writable: true,
enumerable: true,
configurable: true
},
[Symbol.toStringTag]: {
value: "FormData Iterator",
configurable: true
}
});
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FormData'.`);
throw new globalObject.TypeError(`${context} is not of type 'FormData'.`);
};
exports.createDefaultIterator = (target, kind) => {
const iterator = Object.create(IteratorPrototype);
exports.createDefaultIterator = (globalObject, target, kind) => {
const ctorRegistry = globalObject[ctorRegistrySymbol];
const iteratorPrototype = ctorRegistry["FormData Iterator"];
const iterator = Object.create(iteratorPrototype);
Object.defineProperty(iterator, utils.iterInternalSymbol, {
value: { target, kind, index: 0 },
configurable: true
@@ -62,17 +36,17 @@ exports.createDefaultIterator = (target, kind) => {
return iterator;
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["FormData"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FormData is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FormData"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -103,8 +77,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -125,13 +99,17 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class FormData {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = HTMLFormElement.convert(curArg, { context: "Failed to construct 'FormData': parameter 1" });
curArg = HTMLFormElement.convert(globalObject, curArg, {
context: "Failed to construct 'FormData': parameter 1"
});
}
args.push(curArg);
}
@@ -141,12 +119,12 @@ exports.install = (globalObject, globalNames) => {
append(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'append' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'append' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'append' on 'FormData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
@@ -155,7 +133,8 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1"
context: "Failed to execute 'append' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -164,14 +143,17 @@ exports.install = (globalObject, globalNames) => {
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 2"
});
args.push(curArg);
}
} else {
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 2"
context: "Failed to execute 'append' on 'FormData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -182,20 +164,24 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1"
context: "Failed to execute 'append' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 3"
context: "Failed to execute 'append' on 'FormData': parameter 3",
globals: globalObject
});
}
args.push(curArg);
@@ -207,18 +193,21 @@ exports.install = (globalObject, globalNames) => {
delete(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'delete' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'delete' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'delete' on 'FormData': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'delete' on 'FormData': parameter 1" });
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'delete' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].delete(...args);
@@ -227,18 +216,21 @@ exports.install = (globalObject, globalNames) => {
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'get' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'get' on 'FormData': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'get' on 'FormData': parameter 1" });
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'get' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].get(...args));
@@ -247,18 +239,21 @@ exports.install = (globalObject, globalNames) => {
getAll(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'getAll' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'getAll' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'getAll' on 'FormData': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'getAll' on 'FormData': parameter 1" });
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'getAll' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
@@ -267,18 +262,21 @@ exports.install = (globalObject, globalNames) => {
has(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'has' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'has' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'has' on 'FormData': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'has' on 'FormData': parameter 1" });
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'has' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].has(...args);
@@ -287,12 +285,12 @@ exports.install = (globalObject, globalNames) => {
set(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'set' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
throw new globalObject.TypeError(
`Failed to execute 'set' on 'FormData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
@@ -301,7 +299,8 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1"
context: "Failed to execute 'set' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -310,14 +309,17 @@ exports.install = (globalObject, globalNames) => {
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 2"
});
args.push(curArg);
}
} else {
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 2"
context: "Failed to execute 'set' on 'FormData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
@@ -328,20 +330,24 @@ exports.install = (globalObject, globalNames) => {
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1"
context: "Failed to execute 'set' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
curArg = Blob.convert(globalObject, curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 3"
context: "Failed to execute 'set' on 'FormData': parameter 3",
globals: globalObject
});
}
args.push(curArg);
@@ -352,33 +358,35 @@ exports.install = (globalObject, globalNames) => {
keys() {
if (!exports.is(this)) {
throw new TypeError("'keys' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "key");
return exports.createDefaultIterator(globalObject, this, "key");
}
values() {
if (!exports.is(this)) {
throw new TypeError("'values' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'values' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "value");
return exports.createDefaultIterator(globalObject, this, "value");
}
entries() {
if (!exports.is(this)) {
throw new TypeError("'entries' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'entries' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "key+value");
return exports.createDefaultIterator(globalObject, this, "key+value");
}
forEach(callback) {
if (!exports.is(this)) {
throw new TypeError("'forEach' called on an object that is not a valid instance of FormData.");
throw new globalObject.TypeError("'forEach' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present.");
throw new globalObject.TypeError(
"Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present."
);
}
callback = Function.convert(callback, {
callback = Function.convert(globalObject, callback, {
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
});
const thisArg = arguments[1];
@@ -406,10 +414,33 @@ exports.install = (globalObject, globalNames) => {
[Symbol.toStringTag]: { value: "FormData", configurable: true },
[Symbol.iterator]: { value: FormData.prototype.entries, configurable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FormData;
ctorRegistry[interfaceName] = FormData;
ctorRegistry["FormData Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], {
[Symbol.toStringTag]: {
configurable: true,
value: "FormData Iterator"
}
});
utils.define(ctorRegistry["FormData Iterator"], {
next() {
const internal = this && this[utils.iterInternalSymbol];
if (!internal) {
throw new globalObject.TypeError("next() called on a value that is not a FormData iterator object");
}
const { target, kind, index } = internal;
const values = Array.from(target[implSymbol]);
const len = values.length;
if (index >= len) {
return newObjectInRealm(globalObject, { value: undefined, done: true });
}
const pair = values[index];
internal.index = index + 1;
return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind));
}
});
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -3,16 +3,12 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(...args) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
@@ -22,7 +18,7 @@ exports.convert = (value, { context = "The provided value" } = {}) => {
callResult = Reflect.apply(value, thisArg, args);
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
@@ -34,7 +30,7 @@ exports.convert = (value, { context = "The provided value" } = {}) => {
let callResult = Reflect.construct(value, args);
callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};

View File

@@ -3,12 +3,15 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "composed";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
value = conversions["boolean"](value, {
context: context + " has member 'composed' that",
globals: globalObject
});
ret[key] = value;
} else {
@@ -17,12 +20,12 @@ exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) =>
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAnchorElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLAnchorElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAnchorElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAnchorElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLAnchorElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAnchorElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLAnchorElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -119,11 +119,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set target' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set target' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'target' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -138,7 +141,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get download' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get download' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -154,11 +159,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set download' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set download' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'download' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'download' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -173,7 +181,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rel' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get rel' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -189,11 +199,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rel' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set rel' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rel' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'rel' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -208,7 +221,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relList' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get relList' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
return utils.getSameObject(this, "relList", () => {
@@ -220,12 +235,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set relList' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set relList' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
const Q = esValue["relList"];
if (!utils.isObject(Q)) {
throw new TypeError("Property 'relList' is not an object");
throw new globalObject.TypeError("Property 'relList' is not an object");
}
Reflect.set(Q, "value", V);
}
@@ -234,7 +251,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hreflang' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get hreflang' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -250,11 +269,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hreflang' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set hreflang' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'hreflang' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'hreflang' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -269,7 +291,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get type' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -285,11 +309,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set type' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set type' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'type' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'type' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -304,7 +331,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get text' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get text' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -319,11 +348,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set text' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set text' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'text' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'text' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -338,7 +370,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get coords' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get coords' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -354,11 +388,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set coords' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set coords' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'coords' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'coords' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -373,7 +410,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get charset' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get charset' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -389,11 +428,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set charset' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set charset' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'charset' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'charset' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -408,7 +450,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -424,11 +468,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set name' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'name' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -443,7 +490,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rev' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get rev' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -459,11 +508,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rev' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set rev' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rev' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'rev' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -478,7 +530,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get shape' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get shape' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -494,11 +548,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set shape' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set shape' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'shape' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'shape' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -513,7 +570,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get href' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get href' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -528,11 +587,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set href' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set href' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'href' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'href' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -546,7 +608,9 @@ exports.install = (globalObject, globalNames) => {
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'toString' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -561,7 +625,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get origin' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get origin' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
return esValue[implSymbol]["origin"];
@@ -571,7 +637,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get protocol' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get protocol' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -586,11 +654,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set protocol' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set protocol' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'protocol' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'protocol' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -605,7 +676,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get username' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get username' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -620,11 +693,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set username' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set username' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'username' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'username' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -639,7 +715,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get password' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get password' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -654,11 +732,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set password' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set password' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'password' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'password' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -673,7 +754,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get host' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get host' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -688,11 +771,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set host' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set host' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'host' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'host' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -707,7 +793,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hostname' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get hostname' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -722,11 +810,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hostname' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set hostname' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hostname' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'hostname' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -741,7 +832,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get port' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get port' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -756,11 +849,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set port' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set port' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'port' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'port' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -775,7 +871,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get pathname' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get pathname' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -790,11 +888,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set pathname' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set pathname' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'pathname' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'pathname' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -809,7 +910,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get search' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get search' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -824,11 +927,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set search' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set search' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'search' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'search' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -843,7 +949,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hash' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'get hash' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -858,11 +966,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hash' called on an object that is not a valid instance of HTMLAnchorElement.");
throw new globalObject.TypeError(
"'set hash' called on an object that is not a valid instance of HTMLAnchorElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hash' property on 'HTMLAnchorElement': The provided value"
context: "Failed to set the 'hash' property on 'HTMLAnchorElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -900,10 +1011,7 @@ exports.install = (globalObject, globalNames) => {
hash: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLAnchorElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAnchorElement;
ctorRegistry[interfaceName] = HTMLAnchorElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAreaElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLAreaElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAreaElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAreaElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLAreaElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAreaElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLAreaElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get alt' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get alt' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -119,11 +119,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set alt' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set alt' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'alt' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'alt' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -138,7 +141,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get coords' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get coords' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -154,11 +159,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set coords' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set coords' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'coords' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'coords' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -173,7 +181,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get shape' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get shape' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -189,11 +199,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set shape' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set shape' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'shape' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'shape' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -208,7 +221,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -224,11 +239,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set target' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set target' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'target' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -243,7 +261,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rel' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get rel' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -259,11 +279,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rel' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set rel' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rel' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'rel' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -278,7 +301,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relList' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get relList' called on an object that is not a valid instance of HTMLAreaElement."
);
}
return utils.getSameObject(this, "relList", () => {
@@ -290,12 +315,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set relList' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set relList' called on an object that is not a valid instance of HTMLAreaElement."
);
}
const Q = esValue["relList"];
if (!utils.isObject(Q)) {
throw new TypeError("Property 'relList' is not an object");
throw new globalObject.TypeError("Property 'relList' is not an object");
}
Reflect.set(Q, "value", V);
}
@@ -304,7 +331,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get noHref' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get noHref' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -319,11 +348,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set noHref' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set noHref' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'noHref' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'noHref' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -342,7 +374,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get href' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get href' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -357,11 +391,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set href' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set href' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'href' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'href' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -375,7 +412,9 @@ exports.install = (globalObject, globalNames) => {
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'toString' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -390,7 +429,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get origin' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get origin' called on an object that is not a valid instance of HTMLAreaElement."
);
}
return esValue[implSymbol]["origin"];
@@ -400,7 +441,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get protocol' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get protocol' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -415,11 +458,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set protocol' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set protocol' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'protocol' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'protocol' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -434,7 +480,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get username' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get username' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -449,11 +497,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set username' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set username' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'username' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'username' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -468,7 +519,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get password' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get password' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -483,11 +536,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set password' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set password' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'password' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'password' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -502,7 +558,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get host' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get host' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -517,11 +575,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set host' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set host' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'host' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'host' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -536,7 +597,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hostname' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get hostname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -551,11 +614,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hostname' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set hostname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hostname' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'hostname' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -570,7 +636,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get port' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get port' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -585,11 +653,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set port' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set port' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'port' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'port' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -604,7 +675,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get pathname' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get pathname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -619,11 +692,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set pathname' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set pathname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'pathname' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'pathname' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -638,7 +714,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get search' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get search' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -653,11 +731,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set search' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set search' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'search' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'search' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -672,7 +753,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hash' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'get hash' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -687,11 +770,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hash' called on an object that is not a valid instance of HTMLAreaElement.");
throw new globalObject.TypeError(
"'set hash' called on an object that is not a valid instance of HTMLAreaElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hash' property on 'HTMLAreaElement': The provided value"
context: "Failed to set the 'hash' property on 'HTMLAreaElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -724,10 +810,7 @@ exports.install = (globalObject, globalNames) => {
hash: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLAreaElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAreaElement;
ctorRegistry[interfaceName] = HTMLAreaElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAudioElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLAudioElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAudioElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAudioElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLAudioElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,9 +89,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLMediaElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAudioElement before HTMLMediaElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLAudioElement extends globalObject.HTMLMediaElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -100,10 +98,7 @@ exports.install = (globalObject, globalNames) => {
Object.defineProperties(HTMLAudioElement.prototype, {
[Symbol.toStringTag]: { value: "HTMLAudioElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAudioElement;
ctorRegistry[interfaceName] = HTMLAudioElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLBRElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLBRElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLBRElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLBRElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBRElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLBRElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBRElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get clear' called on an object that is not a valid instance of HTMLBRElement.");
throw new globalObject.TypeError(
"'get clear' called on an object that is not a valid instance of HTMLBRElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -119,11 +119,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set clear' called on an object that is not a valid instance of HTMLBRElement.");
throw new globalObject.TypeError(
"'set clear' called on an object that is not a valid instance of HTMLBRElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'clear' property on 'HTMLBRElement': The provided value"
context: "Failed to set the 'clear' property on 'HTMLBRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -138,10 +141,7 @@ exports.install = (globalObject, globalNames) => {
clear: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBRElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLBRElement;
ctorRegistry[interfaceName] = HTMLBRElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLBaseElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLBaseElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLBaseElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLBaseElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBaseElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLBaseElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBaseElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get href' called on an object that is not a valid instance of HTMLBaseElement.");
throw new globalObject.TypeError(
"'get href' called on an object that is not a valid instance of HTMLBaseElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -118,11 +118,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set href' called on an object that is not a valid instance of HTMLBaseElement.");
throw new globalObject.TypeError(
"'set href' called on an object that is not a valid instance of HTMLBaseElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'href' property on 'HTMLBaseElement': The provided value"
context: "Failed to set the 'href' property on 'HTMLBaseElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -137,7 +140,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of HTMLBaseElement.");
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLBaseElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -153,11 +158,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set target' called on an object that is not a valid instance of HTMLBaseElement.");
throw new globalObject.TypeError(
"'set target' called on an object that is not a valid instance of HTMLBaseElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLBaseElement': The provided value"
context: "Failed to set the 'target' property on 'HTMLBaseElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -173,10 +181,7 @@ exports.install = (globalObject, globalNames) => {
target: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBaseElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLBaseElement;
ctorRegistry[interfaceName] = HTMLBaseElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -20,24 +20,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLBodyElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLBodyElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLBodyElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLBodyElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBodyElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -70,8 +70,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -93,9 +93,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLBodyElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBodyElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -105,7 +103,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get text' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get text' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -121,11 +121,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set text' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set text' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'text' property on 'HTMLBodyElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -141,7 +144,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get link' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get link' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -157,11 +162,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set link' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set link' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'link' property on 'HTMLBodyElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -177,7 +185,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get vLink' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get vLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -193,11 +203,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set vLink' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set vLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'vLink' property on 'HTMLBodyElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -213,7 +226,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get aLink' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get aLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -229,11 +244,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set aLink' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set aLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'aLink' property on 'HTMLBodyElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -249,7 +267,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get bgColor' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get bgColor' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -265,11 +285,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set bgColor' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set bgColor' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'bgColor' property on 'HTMLBodyElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
@@ -285,7 +308,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get background' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get background' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -301,11 +326,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set background' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set background' called on an object that is not a valid instance of HTMLBodyElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'background' property on 'HTMLBodyElement': The provided value"
context: "Failed to set the 'background' property on 'HTMLBodyElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -320,7 +348,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onafterprint' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onafterprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]);
@@ -330,13 +360,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onafterprint' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onafterprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onafterprint' property on 'HTMLBodyElement': The provided value"
});
}
@@ -347,7 +379,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]);
@@ -357,13 +391,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onbeforeprint' property on 'HTMLBodyElement': The provided value"
});
}
@@ -374,7 +410,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -386,7 +422,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -394,7 +430,7 @@ exports.install = (globalObject, globalNames) => {
if (!utils.isObject(V)) {
V = null;
} else {
V = OnBeforeUnloadEventHandlerNonNull.convert(V, {
V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onbeforeunload' property on 'HTMLBodyElement': The provided value"
});
}
@@ -405,7 +441,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onhashchange' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onhashchange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]);
@@ -415,13 +453,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onhashchange' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onhashchange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onhashchange' property on 'HTMLBodyElement': The provided value"
});
}
@@ -432,7 +472,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -444,7 +484,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -452,7 +492,7 @@ exports.install = (globalObject, globalNames) => {
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onlanguagechange' property on 'HTMLBodyElement': The provided value"
});
}
@@ -463,7 +503,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onmessage' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onmessage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]);
@@ -473,13 +515,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onmessage' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onmessage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onmessage' property on 'HTMLBodyElement': The provided value"
});
}
@@ -490,7 +534,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get onmessageerror' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -502,7 +546,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set onmessageerror' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -510,7 +554,7 @@ exports.install = (globalObject, globalNames) => {
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onmessageerror' property on 'HTMLBodyElement': The provided value"
});
}
@@ -521,7 +565,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onoffline' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onoffline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]);
@@ -531,13 +577,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onoffline' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onoffline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onoffline' property on 'HTMLBodyElement': The provided value"
});
}
@@ -548,7 +596,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get ononline' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get ononline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]);
@@ -558,13 +608,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set ononline' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set ononline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'ononline' property on 'HTMLBodyElement': The provided value"
});
}
@@ -575,7 +627,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onpagehide' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onpagehide' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]);
@@ -585,13 +639,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onpagehide' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onpagehide' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpagehide' property on 'HTMLBodyElement': The provided value"
});
}
@@ -602,7 +658,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onpageshow' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onpageshow' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]);
@@ -612,13 +670,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onpageshow' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onpageshow' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpageshow' property on 'HTMLBodyElement': The provided value"
});
}
@@ -629,7 +689,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onpopstate' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onpopstate' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]);
@@ -639,13 +701,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onpopstate' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onpopstate' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpopstate' property on 'HTMLBodyElement': The provided value"
});
}
@@ -656,7 +720,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -668,7 +732,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -676,7 +740,7 @@ exports.install = (globalObject, globalNames) => {
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onrejectionhandled' property on 'HTMLBodyElement': The provided value"
});
}
@@ -687,7 +751,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onstorage' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onstorage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]);
@@ -697,13 +763,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onstorage' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onstorage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onstorage' property on 'HTMLBodyElement': The provided value"
});
}
@@ -714,7 +782,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -726,7 +794,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement."
);
}
@@ -734,7 +802,7 @@ exports.install = (globalObject, globalNames) => {
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onunhandledrejection' property on 'HTMLBodyElement': The provided value"
});
}
@@ -745,7 +813,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onunload' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'get onunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]);
@@ -755,13 +825,15 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onunload' called on an object that is not a valid instance of HTMLBodyElement.");
throw new globalObject.TypeError(
"'set onunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onunload' property on 'HTMLBodyElement': The provided value"
});
}
@@ -793,10 +865,7 @@ exports.install = (globalObject, globalNames) => {
onunload: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBodyElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLBodyElement;
ctorRegistry[interfaceName] = HTMLBodyElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLButtonElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLButtonElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLButtonElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLButtonElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLButtonElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLButtonElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLButtonElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -102,7 +100,9 @@ exports.install = (globalObject, globalNames) => {
checkValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'checkValidity' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'checkValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol].checkValidity();
@@ -111,7 +111,9 @@ exports.install = (globalObject, globalNames) => {
reportValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'reportValidity' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'reportValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol].reportValidity();
@@ -120,23 +122,22 @@ exports.install = (globalObject, globalNames) => {
setCustomValidity(error) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'setCustomValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'setCustomValidity' on 'HTMLButtonElement': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'setCustomValidity' on 'HTMLButtonElement': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'setCustomValidity' on 'HTMLButtonElement': parameter 1"
context: "Failed to execute 'setCustomValidity' on 'HTMLButtonElement': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -147,7 +148,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get autofocus' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get autofocus' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -162,11 +165,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set autofocus' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set autofocus' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'autofocus' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'autofocus' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -185,7 +191,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get disabled' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get disabled' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -200,11 +208,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set disabled' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set disabled' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'disabled' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'disabled' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -223,7 +234,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get form' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get form' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["form"]);
@@ -233,7 +246,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get formNoValidate' called on an object that is not a valid instance of HTMLButtonElement."
);
}
@@ -250,13 +263,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'set formNoValidate' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'formNoValidate' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'formNoValidate' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -275,7 +289,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get formTarget' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get formTarget' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -291,11 +307,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set formTarget' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set formTarget' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'formTarget' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'formTarget' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -310,7 +329,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -326,11 +347,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set name' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'name' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -345,7 +369,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get type' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -360,11 +386,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set type' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set type' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'type' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'type' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -379,7 +408,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -395,11 +426,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'set value' called on an object that is not a valid instance of HTMLButtonElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'value' property on 'HTMLButtonElement': The provided value"
context: "Failed to set the 'value' property on 'HTMLButtonElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -414,7 +448,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get willValidate' called on an object that is not a valid instance of HTMLButtonElement."
);
}
@@ -426,7 +460,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get validity' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get validity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]);
@@ -436,7 +472,7 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
throw new globalObject.TypeError(
"'get validationMessage' called on an object that is not a valid instance of HTMLButtonElement."
);
}
@@ -448,7 +484,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get labels' called on an object that is not a valid instance of HTMLButtonElement.");
throw new globalObject.TypeError(
"'get labels' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]);
@@ -472,10 +510,7 @@ exports.install = (globalObject, globalNames) => {
labels: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLButtonElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLButtonElement;
ctorRegistry[interfaceName] = HTMLButtonElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -19,24 +19,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLCanvasElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLCanvasElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLCanvasElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLCanvasElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLCanvasElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -69,8 +69,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -92,9 +92,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLCanvasElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLCanvasElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,28 +101,30 @@ exports.install = (globalObject, globalNames) => {
getContext(contextId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'getContext' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'getContext' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter 1"
context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter 1",
globals: globalObject
});
args.push(curArg);
}
for (let i = 1; i < arguments.length; i++) {
let curArg = arguments[i];
curArg = conversions["any"](curArg, {
context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter " + (i + 1)
context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter " + (i + 1),
globals: globalObject
});
args.push(curArg);
}
@@ -134,14 +134,17 @@ exports.install = (globalObject, globalNames) => {
toDataURL() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'toDataURL' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'toDataURL' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 1"
context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 1",
globals: globalObject
});
}
args.push(curArg);
@@ -150,7 +153,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 2"
context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 2",
globals: globalObject
});
}
args.push(curArg);
@@ -161,20 +165,20 @@ exports.install = (globalObject, globalNames) => {
toBlob(callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'toBlob' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'toBlob' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = BlobCallback.convert(curArg, {
curArg = BlobCallback.convert(globalObject, curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 1"
});
args.push(curArg);
@@ -183,7 +187,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 2"
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 2",
globals: globalObject
});
}
args.push(curArg);
@@ -192,7 +197,8 @@ exports.install = (globalObject, globalNames) => {
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 3"
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 3",
globals: globalObject
});
}
args.push(curArg);
@@ -204,7 +210,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get width' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'get width' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -219,11 +227,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set width' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'set width' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
V = conversions["unsigned long"](V, {
context: "Failed to set the 'width' property on 'HTMLCanvasElement': The provided value"
context: "Failed to set the 'width' property on 'HTMLCanvasElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -238,7 +249,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get height' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'get height' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -253,11 +266,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set height' called on an object that is not a valid instance of HTMLCanvasElement.");
throw new globalObject.TypeError(
"'set height' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
V = conversions["unsigned long"](V, {
context: "Failed to set the 'height' property on 'HTMLCanvasElement': The provided value"
context: "Failed to set the 'height' property on 'HTMLCanvasElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -276,10 +292,7 @@ exports.install = (globalObject, globalNames) => {
height: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLCanvasElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLCanvasElement;
ctorRegistry[interfaceName] = HTMLCanvasElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -14,24 +14,33 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLCollection'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLCollection'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLCollection"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLCollection is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLCollection"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
function makeProxy(wrapper, globalObject) {
let proxyHandler = proxyHandlerCache.get(globalObject);
if (proxyHandler === undefined) {
proxyHandler = new ProxyHandler(globalObject);
proxyHandlerCache.set(globalObject, proxyHandler);
}
return new Proxy(wrapper, proxyHandler);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -55,7 +64,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -64,8 +73,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -73,7 +82,7 @@ exports.new = globalObject => {
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
@@ -88,29 +97,30 @@ exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLCollection {
constructor() {
throw new TypeError("Illegal constructor");
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'item' called on an object that is not a valid instance of HTMLCollection.");
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of HTMLCollection.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'item' on 'HTMLCollection': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'item' on 'HTMLCollection': 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 'HTMLCollection': parameter 1"
context: "Failed to execute 'item' on 'HTMLCollection': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -120,21 +130,22 @@ exports.install = (globalObject, globalNames) => {
namedItem(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'namedItem' called on an object that is not a valid instance of HTMLCollection.");
throw new globalObject.TypeError(
"'namedItem' called on an object that is not a valid instance of HTMLCollection."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'namedItem' on 'HTMLCollection': 1 argument required, but only " +
arguments.length +
" present."
throw new globalObject.TypeError(
`Failed to execute 'namedItem' on 'HTMLCollection': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'namedItem' on 'HTMLCollection': parameter 1"
context: "Failed to execute 'namedItem' on 'HTMLCollection': parameter 1",
globals: globalObject
});
args.push(curArg);
}
@@ -145,7 +156,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of HTMLCollection.");
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of HTMLCollection."
);
}
return esValue[implSymbol]["length"];
@@ -156,12 +169,9 @@ exports.install = (globalObject, globalNames) => {
namedItem: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLCollection", configurable: true },
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLCollection;
ctorRegistry[interfaceName] = HTMLCollection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
@@ -170,7 +180,12 @@ exports.install = (globalObject, globalNames) => {
});
};
const proxyHandler = {
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
@@ -191,7 +206,7 @@ const proxyHandler = {
return undefined;
}
return Reflect.apply(getter, receiver, []);
},
}
has(target, P) {
if (typeof P === "symbol") {
@@ -206,7 +221,7 @@ const proxyHandler = {
return Reflect.has(parent, P);
}
return false;
},
}
ownKeys(target) {
const keys = new Set();
@@ -225,7 +240,7 @@ const proxyHandler = {
keys.add(key);
}
return [...keys];
},
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
@@ -259,7 +274,7 @@ const proxyHandler = {
}
return Reflect.getOwnPropertyDescriptor(target, P);
},
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
@@ -268,6 +283,7 @@ const proxyHandler = {
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
@@ -314,13 +330,15 @@ const proxyHandler = {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
},
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
@@ -331,13 +349,15 @@ const proxyHandler = {
}
}
return Reflect.defineProperty(target, P, desc);
},
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol].item(index) !== null);
@@ -348,11 +368,11 @@ const proxyHandler = {
}
return Reflect.deleteProperty(target, P);
},
}
preventExtensions() {
return false;
}
};
}
const Impl = require("../nodes/HTMLCollection-impl.js");

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLDListElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLDListElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLDListElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLDListElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDListElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLDListElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDListElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get compact' called on an object that is not a valid instance of HTMLDListElement.");
throw new globalObject.TypeError(
"'get compact' called on an object that is not a valid instance of HTMLDListElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -118,11 +118,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set compact' called on an object that is not a valid instance of HTMLDListElement.");
throw new globalObject.TypeError(
"'set compact' called on an object that is not a valid instance of HTMLDListElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'compact' property on 'HTMLDListElement': The provided value"
context: "Failed to set the 'compact' property on 'HTMLDListElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -141,10 +144,7 @@ exports.install = (globalObject, globalNames) => {
compact: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDListElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLDListElement;
ctorRegistry[interfaceName] = HTMLDListElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLDataElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLDataElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLDataElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLDataElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDataElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLDataElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDataElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of HTMLDataElement.");
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of HTMLDataElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -119,11 +119,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of HTMLDataElement.");
throw new globalObject.TypeError(
"'set value' called on an object that is not a valid instance of HTMLDataElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'value' property on 'HTMLDataElement': The provided value"
context: "Failed to set the 'value' property on 'HTMLDataElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -138,10 +141,7 @@ exports.install = (globalObject, globalNames) => {
value: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDataElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLDataElement;
ctorRegistry[interfaceName] = HTMLDataElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -16,24 +16,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLDataListElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLDataListElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLDataListElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLDataListElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDataListElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -66,8 +66,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -89,9 +89,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLDataListElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDataListElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -101,7 +99,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get options' called on an object that is not a valid instance of HTMLDataListElement.");
throw new globalObject.TypeError(
"'get options' called on an object that is not a valid instance of HTMLDataListElement."
);
}
return utils.getSameObject(this, "options", () => {
@@ -113,10 +113,7 @@ exports.install = (globalObject, globalNames) => {
options: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDataListElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLDataListElement;
ctorRegistry[interfaceName] = HTMLDataListElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

View File

@@ -18,24 +18,24 @@ exports.is = value => {
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLDetailsElement'.`);
throw new globalObject.TypeError(`${context} is not of type 'HTMLDetailsElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLDetailsElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLDetailsElement is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDetailsElement"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
@@ -68,8 +68,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@@ -91,9 +91,7 @@ exports.install = (globalObject, globalNames) => {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLDetailsElement before HTMLElement");
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDetailsElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
@@ -103,7 +101,9 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get open' called on an object that is not a valid instance of HTMLDetailsElement.");
throw new globalObject.TypeError(
"'get open' called on an object that is not a valid instance of HTMLDetailsElement."
);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -118,11 +118,14 @@ exports.install = (globalObject, globalNames) => {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set open' called on an object that is not a valid instance of HTMLDetailsElement.");
throw new globalObject.TypeError(
"'set open' called on an object that is not a valid instance of HTMLDetailsElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'open' property on 'HTMLDetailsElement': The provided value"
context: "Failed to set the 'open' property on 'HTMLDetailsElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
@@ -141,10 +144,7 @@ exports.install = (globalObject, globalNames) => {
open: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDetailsElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLDetailsElement;
ctorRegistry[interfaceName] = HTMLDetailsElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,

Some files were not shown because too many files have changed in this diff Show More