feat: initial commit of Railtrack Pro prototype with complete test suite

This commit is contained in:
Railtrack Pro Dev
2026-03-13 14:26:16 +00:00
commit 40500bb503
7790 changed files with 986332 additions and 0 deletions
+373
View File
@@ -0,0 +1,373 @@
"use strict";
const path = require("path");
const { pathToFileURL } = require("url");
const fs = require("fs").promises;
const vm = require("vm");
const toughCookie = require("tough-cookie");
const sniffHTMLEncoding = require("html-encoding-sniffer");
const whatwgURL = require("whatwg-url");
const { legacyHookDecode } = require("@exodus/bytes/encoding.js");
const { URL } = require("whatwg-url");
const { MIMEType } = require("whatwg-mimetype");
const { getGlobalDispatcher } = require("undici");
const idlUtils = require("./generated/idl/utils.js");
const VirtualConsole = require("./jsdom/virtual-console.js");
const { createWindow } = require("./jsdom/browser/Window.js");
const { parseIntoDocument } = require("./jsdom/browser/parser");
const { fragmentSerialization } = require("./jsdom/living/domparsing/serialization.js");
const createDecompressInterceptor = require("./jsdom/browser/resources/decompress-interceptor.js");
const {
JSDOMDispatcher, DEFAULT_USER_AGENT, fetchCollected
} = require("./jsdom/browser/resources/jsdom-dispatcher.js");
const requestInterceptor = require("./jsdom/browser/resources/request-interceptor.js");
class CookieJar extends toughCookie.CookieJar {
constructor(store, options) {
// jsdom cookie jars must be loose by default
super(store, { looseMode: true, ...options });
}
}
const window = Symbol("window");
let sharedFragmentDocument = null;
class JSDOM {
constructor(input = "", options = {}) {
const mimeType = new MIMEType(options.contentType === undefined ? "text/html" : options.contentType);
const { html, encoding } = normalizeHTML(input, mimeType);
options = transformOptions(options, encoding, mimeType);
this[window] = createWindow(options.windowOptions);
const documentImpl = idlUtils.implForWrapper(this[window]._document);
options.beforeParse(this[window]._globalProxy);
parseIntoDocument(html, documentImpl);
documentImpl.close();
}
get window() {
// It's important to grab the global proxy, instead of just the result of `createWindow(...)`, since otherwise
// things like `window.eval` don't exist.
return this[window]._globalProxy;
}
get virtualConsole() {
return this[window]._virtualConsole;
}
get cookieJar() {
// TODO NEWAPI move _cookieJar to window probably
return idlUtils.implForWrapper(this[window]._document)._cookieJar;
}
serialize() {
return fragmentSerialization(idlUtils.implForWrapper(this[window]._document), { requireWellFormed: false });
}
nodeLocation(node) {
if (!idlUtils.implForWrapper(this[window]._document)._parseOptions.sourceCodeLocationInfo) {
throw new Error("Location information was not saved for this jsdom. Use includeNodeLocations during creation.");
}
return idlUtils.implForWrapper(node).sourceCodeLocation;
}
getInternalVMContext() {
if (!vm.isContext(this[window])) {
throw new TypeError("This jsdom was not configured to allow script running. " +
"Use the runScripts option during creation.");
}
return this[window];
}
reconfigure(settings) {
if ("windowTop" in settings) {
this[window]._top = settings.windowTop;
}
if ("url" in settings) {
const document = idlUtils.implForWrapper(this[window]._document);
const url = whatwgURL.parseURL(settings.url);
if (url === null) {
throw new TypeError(`Could not parse "${settings.url}" as a URL`);
}
document._URL = url;
document._origin = whatwgURL.serializeURLOrigin(document._URL);
this[window]._sessionHistory.currentEntry.url = url;
document._clearBaseURLCache();
}
}
static fragment(string = "") {
if (!sharedFragmentDocument) {
sharedFragmentDocument = (new JSDOM()).window.document;
}
const template = sharedFragmentDocument.createElement("template");
template.innerHTML = string;
return template.content;
}
static async fromURL(url, options = {}) {
options = normalizeFromURLOptions(options);
// Build the dispatcher for the initial request
// For the initial fetch, we default to "usable" instead of no resource loading, since fromURL() implicitly requests
// fetching the initial resource. This does not impact further resource fetching, which uses options.resources.
const resourcesForInitialFetch = options.resources !== undefined ? options.resources : "usable";
const { effectiveDispatcher } = extractResourcesOptions(resourcesForInitialFetch, options.cookieJar);
const headers = { Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" };
if (options.referrer) {
headers.Referer = options.referrer;
}
const response = await fetchCollected(effectiveDispatcher, {
url,
headers
});
if (!response.ok) {
throw new Error(`Resource was not loaded. Status: ${response.status}`);
}
options = Object.assign(options, {
url: response.url,
contentType: response.headers["content-type"] || undefined,
referrer: options.referrer,
resources: options.resources
});
return new JSDOM(response.body, options);
}
static async fromFile(filename, options = {}) {
options = normalizeFromFileOptions(filename, options);
const nodeBuffer = await fs.readFile(filename);
return new JSDOM(nodeBuffer, options);
}
}
function normalizeFromURLOptions(options) {
// Checks on options that are invalid for `fromURL`
if (options.url !== undefined) {
throw new TypeError("Cannot supply a url option when using fromURL");
}
if (options.contentType !== undefined) {
throw new TypeError("Cannot supply a contentType option when using fromURL");
}
// Normalization of options which must be done before the rest of the fromURL code can use them, because they are
// given to request()
const normalized = { ...options };
if (options.referrer !== undefined) {
normalized.referrer = (new URL(options.referrer)).href;
}
if (options.cookieJar === undefined) {
normalized.cookieJar = new CookieJar();
}
return normalized;
// All other options don't need to be processed yet, and can be taken care of in the normal course of things when
// `fromURL` calls `new JSDOM(html, options)`.
}
function extractResourcesOptions(resources, cookieJar) {
// loadSubresources controls whether PerDocumentResourceLoader fetches scripts, stylesheets, etc.
// XHR always works regardless of this flag.
let userAgent, baseDispatcher, userInterceptors, loadSubresources;
if (resources === undefined) {
// resources: undefined means no automatic subresource fetching, but XHR still works
userAgent = DEFAULT_USER_AGENT;
baseDispatcher = getGlobalDispatcher();
userInterceptors = [];
loadSubresources = false;
} else if (resources === "usable") {
// resources: "usable" means use all defaults
userAgent = DEFAULT_USER_AGENT;
baseDispatcher = getGlobalDispatcher();
userInterceptors = [];
loadSubresources = true;
} else if (typeof resources === "object" && resources !== null) {
// resources: { userAgent?, dispatcher?, interceptors? }
userAgent = resources.userAgent !== undefined ? resources.userAgent : DEFAULT_USER_AGENT;
baseDispatcher = resources.dispatcher !== undefined ? resources.dispatcher : getGlobalDispatcher();
userInterceptors = resources.interceptors !== undefined ? resources.interceptors : [];
loadSubresources = true;
} else {
throw new TypeError(`resources must be undefined, "usable", or an object`);
}
// User interceptors come first (outermost), then decompress interceptor
const allUserInterceptors = [
...userInterceptors,
createDecompressInterceptor()
];
return {
userAgent,
effectiveDispatcher: new JSDOMDispatcher({
baseDispatcher,
cookieJar,
userAgent,
userInterceptors: allUserInterceptors
}),
loadSubresources
};
}
function normalizeFromFileOptions(filename, options) {
const normalized = { ...options };
if (normalized.contentType === undefined) {
const extname = path.extname(filename);
if (extname === ".xhtml" || extname === ".xht" || extname === ".xml") {
normalized.contentType = "application/xhtml+xml";
}
}
if (normalized.url === undefined) {
normalized.url = pathToFileURL(path.resolve(filename)).href;
}
return normalized;
}
function transformOptions(options, encoding, mimeType) {
const transformed = {
windowOptions: {
// Defaults
url: "about:blank",
referrer: "",
contentType: "text/html",
parsingMode: "html",
parseOptions: {
sourceCodeLocationInfo: false,
scriptingEnabled: false
},
runScripts: undefined,
encoding,
pretendToBeVisual: false,
storageQuota: 5000000,
// Defaults filled in later
dispatcher: undefined,
loadSubresources: undefined,
userAgent: undefined,
virtualConsole: undefined,
cookieJar: undefined
},
// Defaults
beforeParse() { }
};
// options.contentType was parsed into mimeType by the caller.
if (!mimeType.isHTML() && !mimeType.isXML()) {
throw new RangeError(`The given content type of "${options.contentType}" was not a HTML or XML content type`);
}
transformed.windowOptions.contentType = mimeType.essence;
transformed.windowOptions.parsingMode = mimeType.isHTML() ? "html" : "xml";
if (options.url !== undefined) {
transformed.windowOptions.url = (new URL(options.url)).href;
}
if (options.referrer !== undefined) {
transformed.windowOptions.referrer = (new URL(options.referrer)).href;
}
if (options.includeNodeLocations) {
if (transformed.windowOptions.parsingMode === "xml") {
throw new TypeError("Cannot set includeNodeLocations to true with an XML content type");
}
transformed.windowOptions.parseOptions = { sourceCodeLocationInfo: true };
}
transformed.windowOptions.cookieJar = options.cookieJar === undefined ?
new CookieJar() :
options.cookieJar;
transformed.windowOptions.virtualConsole = options.virtualConsole === undefined ?
(new VirtualConsole()).forwardTo(console) :
options.virtualConsole;
if (!(transformed.windowOptions.virtualConsole instanceof VirtualConsole)) {
throw new TypeError("virtualConsole must be an instance of VirtualConsole");
}
const { userAgent, effectiveDispatcher, loadSubresources } =
extractResourcesOptions(options.resources, transformed.windowOptions.cookieJar);
transformed.windowOptions.userAgent = userAgent;
transformed.windowOptions.dispatcher = effectiveDispatcher;
transformed.windowOptions.loadSubresources = loadSubresources;
if (options.runScripts !== undefined) {
transformed.windowOptions.runScripts = String(options.runScripts);
if (transformed.windowOptions.runScripts === "dangerously") {
transformed.windowOptions.parseOptions.scriptingEnabled = true;
} else if (transformed.windowOptions.runScripts !== "outside-only") {
throw new RangeError(`runScripts must be undefined, "dangerously", or "outside-only"`);
}
}
if (options.beforeParse !== undefined) {
transformed.beforeParse = options.beforeParse;
}
if (options.pretendToBeVisual !== undefined) {
transformed.windowOptions.pretendToBeVisual = Boolean(options.pretendToBeVisual);
}
if (options.storageQuota !== undefined) {
transformed.windowOptions.storageQuota = Number(options.storageQuota);
}
return transformed;
}
function normalizeHTML(html, mimeType) {
let encoding = "UTF-8";
if (html instanceof Uint8Array) {
// leave as-is
} else if (ArrayBuffer.isView(html)) {
html = new Uint8Array(html.buffer, html.byteOffset, html.byteLength);
} else if (html instanceof ArrayBuffer) {
html = new Uint8Array(html);
}
if (html instanceof Uint8Array) {
encoding = sniffHTMLEncoding(html, {
xml: mimeType.isXML(),
transportLayerEncodingLabel: mimeType.parameters.get("charset")
});
html = legacyHookDecode(html, encoding);
} else {
html = String(html);
}
return { html, encoding };
}
exports.JSDOM = JSDOM;
exports.VirtualConsole = VirtualConsole;
exports.CookieJar = CookieJar;
exports.requestInterceptor = requestInterceptor;
exports.toughCookie = toughCookie;
+115
View File
@@ -0,0 +1,115 @@
// This file is generated by scripts/generate-event-sets.js. Do not edit.
"use strict";
exports.globalEventHandlersEvents = new Set([
"abort",
"auxclick",
"beforeinput",
"beforematch",
"beforetoggle",
"blur",
"cancel",
"canplay",
"canplaythrough",
"change",
"click",
"close",
"contextlost",
"contextmenu",
"contextrestored",
"copy",
"cuechange",
"cut",
"dblclick",
"drag",
"dragend",
"dragenter",
"dragleave",
"dragover",
"dragstart",
"drop",
"durationchange",
"emptied",
"ended",
"error",
"focus",
"formdata",
"input",
"invalid",
"keydown",
"keypress",
"keyup",
"load",
"loadeddata",
"loadedmetadata",
"loadstart",
"mousedown",
"mouseenter",
"mouseleave",
"mousemove",
"mouseout",
"mouseover",
"mouseup",
"paste",
"pause",
"play",
"playing",
"progress",
"ratechange",
"reset",
"resize",
"scroll",
"scrollend",
"securitypolicyviolation",
"seeked",
"seeking",
"select",
"slotchange",
"stalled",
"submit",
"suspend",
"timeupdate",
"toggle",
"volumechange",
"waiting",
"webkitanimationend",
"webkitanimationiteration",
"webkitanimationstart",
"webkittransitionend",
"wheel",
"touchstart",
"touchend",
"touchmove",
"touchcancel",
"pointerover",
"pointerenter",
"pointerdown",
"pointermove",
"pointerrawupdate",
"pointerup",
"pointercancel",
"pointerout",
"pointerleave",
"gotpointercapture",
"lostpointercapture"
]);
exports.windowEventHandlersEvents = new Set([
"afterprint",
"beforeprint",
"beforeunload",
"hashchange",
"languagechange",
"message",
"messageerror",
"offline",
"online",
"pagehide",
"pageshow",
"popstate",
"rejectionhandled",
"storage",
"unhandledrejection",
"unload"
]);
+143
View File
@@ -0,0 +1,143 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "AbortController";
exports.is = value => {
return utils.isObject(value) && Object.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 'AbortController'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbortController"].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 AbortController {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'abort' called on an object that is not a valid instance of AbortController."
);
}
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 globalObject.TypeError(
"'get signal' called on an object that is not a valid instance of AbortController."
);
}
return utils.getSameObject(this, "signal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["signal"]);
});
}
}
Object.defineProperties(AbortController.prototype, {
abort: { enumerable: true },
signal: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortController", configurable: true }
});
ctorRegistry[interfaceName] = AbortController;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbortController
});
};
const Impl = require("../../jsdom/living/aborting/AbortController-impl.js");
+249
View File
@@ -0,0 +1,249 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const EventTarget = require("./EventTarget.js");
const interfaceName = "AbortSignal";
exports.is = value => {
return utils.isObject(value) && Object.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 'AbortSignal'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbortSignal"].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) => {
EventTarget._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 AbortSignal extends globalObject.EventTarget {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
throwIfAborted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'throwIfAborted' called on an object that is not a valid instance of AbortSignal."
);
}
return esValue[implSymbol].throwIfAborted();
}
get aborted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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 globalObject.TypeError(
"'get onabort' called on an object that is not a valid instance of AbortSignal."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
}
set onabort(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(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));
}
static timeout(milliseconds) {
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'timeout' on 'AbortSignal': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long long"](curArg, {
context: "Failed to execute 'timeout' on 'AbortSignal': parameter 1",
globals: globalObject,
enforceRange: true
});
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.timeout(globalObject, ...args));
}
static any(signals) {
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'any' on 'AbortSignal': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
if (!utils.isObject(curArg)) {
throw new globalObject.TypeError(
"Failed to execute 'any' on 'AbortSignal': parameter 1" + " is not an iterable object."
);
} else {
const V = [];
const tmp = curArg;
for (let nextItem of tmp) {
nextItem = exports.convert(globalObject, nextItem, {
context: "Failed to execute 'any' on 'AbortSignal': parameter 1" + "'s element"
});
V.push(nextItem);
}
curArg = V;
}
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.any(globalObject, ...args));
}
}
Object.defineProperties(AbortSignal.prototype, {
throwIfAborted: { enumerable: true },
aborted: { enumerable: true },
reason: { enumerable: true },
onabort: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortSignal", configurable: true }
});
Object.defineProperties(AbortSignal, {
abort: { enumerable: true },
timeout: { enumerable: true },
any: { enumerable: true }
});
ctorRegistry[interfaceName] = AbortSignal;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbortSignal
});
};
const Impl = require("../../jsdom/living/aborting/AbortSignal-impl.js");
+171
View File
@@ -0,0 +1,171 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "AbstractRange";
exports.is = value => {
return utils.isObject(value) && Object.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 'AbstractRange'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["AbstractRange"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class AbstractRange {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get startContainer() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get startContainer' called on an object that is not a valid instance of AbstractRange."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["startContainer"]);
}
get startOffset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get startOffset' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["startOffset"];
}
get endContainer() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get endContainer' called on an object that is not a valid instance of AbstractRange."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["endContainer"]);
}
get endOffset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get endOffset' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["endOffset"];
}
get collapsed() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get collapsed' called on an object that is not a valid instance of AbstractRange."
);
}
return esValue[implSymbol]["collapsed"];
}
}
Object.defineProperties(AbstractRange.prototype, {
startContainer: { enumerable: true },
startOffset: { enumerable: true },
endContainer: { enumerable: true },
endOffset: { enumerable: true },
collapsed: { enumerable: true },
[Symbol.toStringTag]: { value: "AbstractRange", configurable: true }
});
ctorRegistry[interfaceName] = AbstractRange;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbstractRange
});
};
const Impl = require("../../jsdom/living/range/AbstractRange-impl.js");
+53
View File
@@ -0,0 +1,53 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const AbortSignal = require("./AbortSignal.js");
const EventListenerOptions = require("./EventListenerOptions.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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", globals: globalObject });
ret[key] = value;
}
}
{
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 = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+28
View File
@@ -0,0 +1,28 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+219
View File
@@ -0,0 +1,219 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Node = require("./Node.js");
const interfaceName = "Attr";
exports.is = value => {
return utils.isObject(value) && Object.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 'Attr'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Attr"].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) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class Attr extends globalObject.Node {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get namespaceURI() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get namespaceURI' called on an object that is not a valid instance of Attr."
);
}
return esValue[implSymbol]["namespaceURI"];
}
get prefix() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get prefix' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["prefix"];
}
get localName() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get localName' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["localName"];
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["name"];
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get value' called on an object that is not a valid instance of Attr.");
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["value"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get ownerElement() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get ownerElement' called on an object that is not a valid instance of Attr."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ownerElement"]);
}
get specified() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get specified' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["specified"];
}
}
Object.defineProperties(Attr.prototype, {
namespaceURI: { enumerable: true },
prefix: { enumerable: true },
localName: { enumerable: true },
name: { enumerable: true },
value: { enumerable: true },
ownerElement: { enumerable: true },
specified: { enumerable: true },
[Symbol.toStringTag]: { value: "Attr", configurable: true }
});
ctorRegistry[interfaceName] = Attr;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Attr
});
};
const Impl = require("../../jsdom/living/attributes/Attr-impl.js");
+117
View File
@@ -0,0 +1,117 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "BarProp";
exports.is = value => {
return utils.isObject(value) && Object.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 'BarProp'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["BarProp"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class BarProp {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get visible() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get visible' called on an object that is not a valid instance of BarProp.");
}
return esValue[implSymbol]["visible"];
}
}
Object.defineProperties(BarProp.prototype, {
visible: { enumerable: true },
[Symbol.toStringTag]: { value: "BarProp", configurable: true }
});
ctorRegistry[interfaceName] = BarProp;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: BarProp
});
};
const Impl = require("../../jsdom/living/window/BarProp-impl.js");
+139
View File
@@ -0,0 +1,139 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "BeforeUnloadEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'BeforeUnloadEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["BeforeUnloadEvent"].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) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class BeforeUnloadEvent extends globalObject.Event {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get returnValue() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get returnValue' called on an object that is not a valid instance of BeforeUnloadEvent."
);
}
return esValue[implSymbol]["returnValue"];
}
set returnValue(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set returnValue' called on an object that is not a valid instance of BeforeUnloadEvent."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'returnValue' property on 'BeforeUnloadEvent': The provided value",
globals: globalObject
});
esValue[implSymbol]["returnValue"] = V;
}
}
Object.defineProperties(BeforeUnloadEvent.prototype, {
returnValue: { enumerable: true },
[Symbol.toStringTag]: { value: "BeforeUnloadEvent", configurable: true }
});
ctorRegistry[interfaceName] = BeforeUnloadEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: BeforeUnloadEvent
});
};
const Impl = require("../../jsdom/living/events/BeforeUnloadEvent-impl.js");
+12
View File
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["blob", "arraybuffer"]);
exports.enumerationValues = enumerationValues;
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`);
}
return string;
};
+253
View File
@@ -0,0 +1,253 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Blob";
exports.is = value => {
return utils.isObject(value) && Object.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 'Blob'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Blob"].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 Blob {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
if (!utils.isObject(curArg)) {
throw new globalObject.TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
for (let nextItem of tmp) {
if (exports.is(nextItem)) {
nextItem = utils.implForWrapper(nextItem);
} else if (utils.isArrayBuffer(nextItem)) {
nextItem = conversions["ArrayBuffer"](nextItem, {
context: "Failed to construct 'Blob': parameter 1" + "'s element",
globals: globalObject
});
} else if (ArrayBuffer.isView(nextItem)) {
nextItem = conversions["ArrayBufferView"](nextItem, {
context: "Failed to construct 'Blob': parameter 1" + "'s element",
globals: globalObject
});
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'Blob': parameter 1" + "'s element",
globals: globalObject
});
}
V.push(nextItem);
}
curArg = V;
}
}
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
slice() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'slice' called on an object that is not a valid instance of Blob.");
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 1",
globals: globalObject,
clamp: true
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 2",
globals: globalObject,
clamp: true
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 3",
globals: globalObject
});
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].slice(...args));
}
text() {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'text' called on an object that is not a valid instance of Blob.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].text());
} catch (e) {
return globalObject.Promise.reject(e);
}
}
arrayBuffer() {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'arrayBuffer' called on an object that is not a valid instance of Blob.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].arrayBuffer());
} catch (e) {
return globalObject.Promise.reject(e);
}
}
bytes() {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'bytes' called on an object that is not a valid instance of Blob.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].bytes());
} catch (e) {
return globalObject.Promise.reject(e);
}
}
get size() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get size' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["size"];
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["type"];
}
}
Object.defineProperties(Blob.prototype, {
slice: { enumerable: true },
text: { enumerable: true },
arrayBuffer: { enumerable: true },
bytes: { enumerable: true },
size: { enumerable: true },
type: { enumerable: true },
[Symbol.toStringTag]: { value: "Blob", configurable: true }
});
ctorRegistry[interfaceName] = Blob;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Blob
});
};
const Impl = require("../../jsdom/living/file-api/Blob-impl.js");
+30
View File
@@ -0,0 +1,30 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(blob) {
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
blob = utils.tryWrapperForImpl(blob);
callResult = Reflect.apply(value, thisArg, [blob]);
}
invokeTheCallbackFunction.construct = blob => {
blob = utils.tryWrapperForImpl(blob);
let callResult = Reflect.construct(value, [blob]);
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
+157
View File
@@ -0,0 +1,157 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobEventInit = require("./BlobEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "BlobEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'BlobEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["BlobEvent"].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) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class BlobEvent extends globalObject.Event {
constructor(type, eventInitDict) {
if (arguments.length < 2) {
throw new globalObject.TypeError(
`Failed to construct 'BlobEvent': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'BlobEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = BlobEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'BlobEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get data() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get data' called on an object that is not a valid instance of BlobEvent.");
}
return utils.getSameObject(this, "data", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["data"]);
});
}
get timecode() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get timecode' called on an object that is not a valid instance of BlobEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["timecode"]);
}
}
Object.defineProperties(BlobEvent.prototype, {
data: { enumerable: true },
timecode: { enumerable: true },
[Symbol.toStringTag]: { value: "BlobEvent", configurable: true }
});
ctorRegistry[interfaceName] = BlobEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: BlobEvent
});
};
const Impl = require("../../jsdom/living/events/BlobEvent-impl.js");
+43
View File
@@ -0,0 +1,43 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "data";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = Blob.convert(globalObject, value, { context: context + " has member 'data' that" });
ret[key] = value;
} else {
throw new globalObject.TypeError("data is required in 'BlobEventInit'");
}
}
{
const key = "timecode";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["double"](value, { context: context + " has member 'timecode' that", globals: globalObject });
ret[key] = value;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+42
View File
@@ -0,0 +1,42 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EndingType = require("./EndingType.js");
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(globalObject, value, { context: context + " has member 'endings' that" });
ret[key] = value;
} else {
ret[key] = "transparent";
}
}
{
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+109
View File
@@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Text = require("./Text.js");
const interfaceName = "CDATASection";
exports.is = value => {
return utils.isObject(value) && Object.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 'CDATASection'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CDATASection"].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) => {
Text._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CDATASection extends globalObject.Text {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(CDATASection.prototype, {
[Symbol.toStringTag]: { value: "CDATASection", configurable: true }
});
ctorRegistry[interfaceName] = CDATASection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CDATASection
});
};
const Impl = require("../../jsdom/living/nodes/CDATASection-impl.js");
+12
View File
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["", "maybe", "probably"]);
exports.enumerationValues = enumerationValues;
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`);
}
return string;
};
+455
View File
@@ -0,0 +1,455 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CharacterData";
exports.is = value => {
return utils.isObject(value) && Object.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 'CharacterData'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CharacterData"].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) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CharacterData extends globalObject.Node {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
substringData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'substringData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].substringData(...args);
}
appendData(data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'appendData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].appendData(...args);
}
insertData(offset, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'insertData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].insertData(...args);
}
deleteData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'deleteData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].deleteData(...args);
}
replaceData(offset, count, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'replaceData' called on an object that is not a valid instance of CharacterData."
);
}
if (arguments.length < 3) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].replaceData(...args);
}
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].before(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].after(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replaceWith(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of CharacterData.");
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove();
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get data() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get data' called on an object that is not a valid instance of CharacterData."
);
}
return esValue[implSymbol]["data"];
}
set data(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
esValue[implSymbol]["data"] = V;
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of CharacterData."
);
}
return esValue[implSymbol]["length"];
}
get previousElementSibling() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get previousElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["previousElementSibling"]);
}
get nextElementSibling() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get nextElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["nextElementSibling"]);
}
}
Object.defineProperties(CharacterData.prototype, {
substringData: { enumerable: true },
appendData: { enumerable: true },
insertData: { enumerable: true },
deleteData: { enumerable: true },
replaceData: { enumerable: true },
before: { enumerable: true },
after: { enumerable: true },
replaceWith: { enumerable: true },
remove: { enumerable: true },
data: { enumerable: true },
length: { enumerable: true },
previousElementSibling: { enumerable: true },
nextElementSibling: { enumerable: true },
[Symbol.toStringTag]: { value: "CharacterData", configurable: true },
[Symbol.unscopables]: {
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
configurable: true
}
});
ctorRegistry[interfaceName] = CharacterData;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CharacterData
});
};
const Impl = require("../../jsdom/living/nodes/CharacterData-impl.js");
+168
View File
@@ -0,0 +1,168 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CloseEventInit = require("./CloseEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "CloseEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'CloseEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CloseEvent"].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) => {
Event._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 CloseEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
get wasClean() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get wasClean' called on an object that is not a valid instance of CloseEvent."
);
}
return esValue[implSymbol]["wasClean"];
}
get code() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get code' called on an object that is not a valid instance of CloseEvent.");
}
return esValue[implSymbol]["code"];
}
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 CloseEvent."
);
}
return esValue[implSymbol]["reason"];
}
}
Object.defineProperties(CloseEvent.prototype, {
wasClean: { enumerable: true },
code: { enumerable: true },
reason: { enumerable: true },
[Symbol.toStringTag]: { value: "CloseEvent", configurable: true }
});
ctorRegistry[interfaceName] = CloseEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CloseEvent
});
};
const Impl = require("../../jsdom/living/events/CloseEvent-impl.js");
+65
View File
@@ -0,0 +1,65 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = "";
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+120
View File
@@ -0,0 +1,120 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CharacterData = require("./CharacterData.js");
const interfaceName = "Comment";
exports.is = value => {
return utils.isObject(value) && Object.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 'Comment'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Comment"].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) => {
CharacterData._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class 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",
globals: globalObject
});
} else {
curArg = "";
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
}
Object.defineProperties(Comment.prototype, { [Symbol.toStringTag]: { value: "Comment", configurable: true } });
ctorRegistry[interfaceName] = Comment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Comment
});
};
const Impl = require("../../jsdom/living/nodes/Comment-impl.js");
+219
View File
@@ -0,0 +1,219 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CompositionEventInit = require("./CompositionEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const UIEvent = require("./UIEvent.js");
const interfaceName = "CompositionEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'CompositionEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CompositionEvent"].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) => {
UIEvent._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CompositionEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CompositionEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'CompositionEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
initCompositionEvent(typeArg) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'initCompositionEvent' called on an object that is not a valid instance of CompositionEvent."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = utils.tryImplForWrapper(curArg);
}
} else {
curArg = null;
}
args.push(curArg);
}
{
let curArg = arguments[4];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5",
globals: globalObject
});
} else {
curArg = "";
}
args.push(curArg);
}
return esValue[implSymbol].initCompositionEvent(...args);
}
get data() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get data' called on an object that is not a valid instance of CompositionEvent."
);
}
return esValue[implSymbol]["data"];
}
}
Object.defineProperties(CompositionEvent.prototype, {
initCompositionEvent: { enumerable: true },
data: { enumerable: true },
[Symbol.toStringTag]: { value: "CompositionEvent", configurable: true }
});
ctorRegistry[interfaceName] = CompositionEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CompositionEvent
});
};
const Impl = require("../../jsdom/living/events/CompositionEvent-impl.js");
+32
View File
@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+148
View File
@@ -0,0 +1,148 @@
"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) && Object.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)) {
curArg = conversions["ArrayBufferView"](curArg, {
context: "Failed to execute 'getRandomValues' on 'Crypto': parameter 1",
globals: globalObject
});
} 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);
}
randomUUID() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'randomUUID' called on an object that is not a valid instance of Crypto.");
}
return esValue[implSymbol].randomUUID();
}
}
Object.defineProperties(Crypto.prototype, {
getRandomValues: { enumerable: true },
randomUUID: { enumerable: true },
[Symbol.toStringTag]: { value: "Crypto", configurable: true }
});
ctorRegistry[interfaceName] = Crypto;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Crypto
});
};
const Impl = require("../../jsdom/living/crypto/Crypto-impl.js");
+34
View File
@@ -0,0 +1,34 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction() {
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
callResult = Reflect.apply(value, thisArg, []);
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
invokeTheCallbackFunction.construct = () => {
let callResult = Reflect.construct(value, []);
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
+269
View File
@@ -0,0 +1,269 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CustomElementConstructor = require("./CustomElementConstructor.js");
const ElementDefinitionOptions = require("./ElementDefinitionOptions.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const Node = require("./Node.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CustomElementRegistry";
exports.is = value => {
return utils.isObject(value) && Object.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 'CustomElementRegistry'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CustomElementRegistry"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class CustomElementRegistry {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
define(name, constructor) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'define' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CustomElementConstructor.convert(globalObject, curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = ElementDefinitionOptions.convert(globalObject, curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 3"
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].define(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].get(...args);
}
getName(constructor) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getName' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'getName' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = CustomElementConstructor.convert(globalObject, curArg, {
context: "Failed to execute 'getName' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].getName(...args);
}
whenDefined(name) {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'whenDefined' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].whenDefined(...args));
} catch (e) {
return globalObject.Promise.reject(e);
}
}
upgrade(root) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'upgrade' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'upgrade' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].upgrade(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(CustomElementRegistry.prototype, {
define: { enumerable: true },
get: { enumerable: true },
getName: { enumerable: true },
whenDefined: { enumerable: true },
upgrade: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomElementRegistry", configurable: true }
});
ctorRegistry[interfaceName] = CustomElementRegistry;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CustomElementRegistry
});
};
const Impl = require("../../jsdom/living/custom-elements/CustomElementRegistry-impl.js");
+206
View File
@@ -0,0 +1,206 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CustomEventInit = require("./CustomEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "CustomEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'CustomEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CustomEvent"].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) => {
Event._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 CustomEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
initCustomEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'initCustomEvent' called on an object that is not a valid instance of CustomEvent."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4",
globals: globalObject
});
} else {
curArg = null;
}
args.push(curArg);
}
return esValue[implSymbol].initCustomEvent(...args);
}
get detail() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get detail' called on an object that is not a valid instance of CustomEvent."
);
}
return esValue[implSymbol]["detail"];
}
}
Object.defineProperties(CustomEvent.prototype, {
initCustomEvent: { enumerable: true },
detail: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomEvent", configurable: true }
});
ctorRegistry[interfaceName] = CustomEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CustomEvent
});
};
const Impl = require("../../jsdom/living/events/CustomEvent-impl.js");
+32
View File
@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+222
View File
@@ -0,0 +1,222 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMException";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMException'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMException"].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 DOMException {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DOMException': parameter 1",
globals: globalObject
});
} else {
curArg = "";
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DOMException': parameter 2",
globals: globalObject
});
} else {
curArg = "Error";
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of DOMException."
);
}
return esValue[implSymbol]["name"];
}
get message() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get message' called on an object that is not a valid instance of DOMException."
);
}
return esValue[implSymbol]["message"];
}
get code() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get code' called on an object that is not a valid instance of DOMException."
);
}
return esValue[implSymbol]["code"];
}
}
Object.defineProperties(DOMException.prototype, {
name: { enumerable: true },
message: { enumerable: true },
code: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMException", configurable: true },
INDEX_SIZE_ERR: { value: 1, enumerable: true },
DOMSTRING_SIZE_ERR: { value: 2, enumerable: true },
HIERARCHY_REQUEST_ERR: { value: 3, enumerable: true },
WRONG_DOCUMENT_ERR: { value: 4, enumerable: true },
INVALID_CHARACTER_ERR: { value: 5, enumerable: true },
NO_DATA_ALLOWED_ERR: { value: 6, enumerable: true },
NO_MODIFICATION_ALLOWED_ERR: { value: 7, enumerable: true },
NOT_FOUND_ERR: { value: 8, enumerable: true },
NOT_SUPPORTED_ERR: { value: 9, enumerable: true },
INUSE_ATTRIBUTE_ERR: { value: 10, enumerable: true },
INVALID_STATE_ERR: { value: 11, enumerable: true },
SYNTAX_ERR: { value: 12, enumerable: true },
INVALID_MODIFICATION_ERR: { value: 13, enumerable: true },
NAMESPACE_ERR: { value: 14, enumerable: true },
INVALID_ACCESS_ERR: { value: 15, enumerable: true },
VALIDATION_ERR: { value: 16, enumerable: true },
TYPE_MISMATCH_ERR: { value: 17, enumerable: true },
SECURITY_ERR: { value: 18, enumerable: true },
NETWORK_ERR: { value: 19, enumerable: true },
ABORT_ERR: { value: 20, enumerable: true },
URL_MISMATCH_ERR: { value: 21, enumerable: true },
QUOTA_EXCEEDED_ERR: { value: 22, enumerable: true },
TIMEOUT_ERR: { value: 23, enumerable: true },
INVALID_NODE_TYPE_ERR: { value: 24, enumerable: true },
DATA_CLONE_ERR: { value: 25, enumerable: true }
});
Object.defineProperties(DOMException, {
INDEX_SIZE_ERR: { value: 1, enumerable: true },
DOMSTRING_SIZE_ERR: { value: 2, enumerable: true },
HIERARCHY_REQUEST_ERR: { value: 3, enumerable: true },
WRONG_DOCUMENT_ERR: { value: 4, enumerable: true },
INVALID_CHARACTER_ERR: { value: 5, enumerable: true },
NO_DATA_ALLOWED_ERR: { value: 6, enumerable: true },
NO_MODIFICATION_ALLOWED_ERR: { value: 7, enumerable: true },
NOT_FOUND_ERR: { value: 8, enumerable: true },
NOT_SUPPORTED_ERR: { value: 9, enumerable: true },
INUSE_ATTRIBUTE_ERR: { value: 10, enumerable: true },
INVALID_STATE_ERR: { value: 11, enumerable: true },
SYNTAX_ERR: { value: 12, enumerable: true },
INVALID_MODIFICATION_ERR: { value: 13, enumerable: true },
NAMESPACE_ERR: { value: 14, enumerable: true },
INVALID_ACCESS_ERR: { value: 15, enumerable: true },
VALIDATION_ERR: { value: 16, enumerable: true },
TYPE_MISMATCH_ERR: { value: 17, enumerable: true },
SECURITY_ERR: { value: 18, enumerable: true },
NETWORK_ERR: { value: 19, enumerable: true },
ABORT_ERR: { value: 20, enumerable: true },
URL_MISMATCH_ERR: { value: 21, enumerable: true },
QUOTA_EXCEEDED_ERR: { value: 22, enumerable: true },
TIMEOUT_ERR: { value: 23, enumerable: true },
INVALID_NODE_TYPE_ERR: { value: 24, enumerable: true },
DATA_CLONE_ERR: { value: 25, enumerable: true }
});
ctorRegistry[interfaceName] = DOMException;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMException
});
};
const Impl = require("../../jsdom/living/webidl/DOMException-impl.js");
+237
View File
@@ -0,0 +1,237 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DocumentType = require("./DocumentType.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMImplementation";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMImplementation'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMImplementation"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMImplementation {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
createDocumentType(qualifiedName, publicId, systemId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'createDocumentType' called on an object that is not a valid instance of DOMImplementation."
);
}
if (arguments.length < 3) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args));
}
createDocument(namespace, qualifiedName) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'createDocument' called on an object that is not a valid instance of DOMImplementation."
);
}
if (arguments.length < 2) {
throw new globalObject.TypeError(
`Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1",
globals: globalObject
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2",
globals: globalObject,
treatNullAsEmptyString: true
});
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = DocumentType.convert(globalObject, curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3"
});
}
} else {
curArg = null;
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args));
}
createHTMLDocument() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1",
globals: globalObject
});
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args));
}
hasFeature() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'hasFeature' called on an object that is not a valid instance of DOMImplementation."
);
}
return esValue[implSymbol].hasFeature();
}
}
Object.defineProperties(DOMImplementation.prototype, {
createDocumentType: { enumerable: true },
createDocument: { enumerable: true },
createHTMLDocument: { enumerable: true },
hasFeature: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMImplementation", configurable: true }
});
ctorRegistry[interfaceName] = DOMImplementation;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMImplementation
});
};
const Impl = require("../../jsdom/living/nodes/DOMImplementation-impl.js");
+140
View File
@@ -0,0 +1,140 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const SupportedType = require("./SupportedType.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMParser";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMParser'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMParser"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMParser {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
parseFromString(str, type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'parseFromString' called on an object that is not a valid instance of DOMParser."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = SupportedType.convert(globalObject, curArg, {
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].parseFromString(...args));
}
}
Object.defineProperties(DOMParser.prototype, {
parseFromString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMParser", configurable: true }
});
ctorRegistry[interfaceName] = DOMParser;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMParser
});
};
const Impl = require("../../jsdom/living/domparsing/DOMParser-impl.js");
+276
View File
@@ -0,0 +1,276 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DOMRectInit = require("./DOMRectInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const DOMRectReadOnly = require("./DOMRectReadOnly.js");
const interfaceName = "DOMRect";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMRect'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMRect"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
DOMRectReadOnly._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMRect extends globalObject.DOMRectReadOnly {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRect': parameter 1",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRect': parameter 2",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRect': parameter 3",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRect': parameter 4",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get x() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get x' called on an object that is not a valid instance of DOMRect.");
}
return esValue[implSymbol]["x"];
}
set x(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set x' called on an object that is not a valid instance of DOMRect.");
}
V = conversions["unrestricted double"](V, {
context: "Failed to set the 'x' property on 'DOMRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["x"] = V;
}
get y() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get y' called on an object that is not a valid instance of DOMRect.");
}
return esValue[implSymbol]["y"];
}
set y(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set y' called on an object that is not a valid instance of DOMRect.");
}
V = conversions["unrestricted double"](V, {
context: "Failed to set the 'y' property on 'DOMRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["y"] = V;
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get width' called on an object that is not a valid instance of DOMRect.");
}
return esValue[implSymbol]["width"];
}
set width(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set width' called on an object that is not a valid instance of DOMRect.");
}
V = conversions["unrestricted double"](V, {
context: "Failed to set the 'width' property on 'DOMRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["width"] = V;
}
get height() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get height' called on an object that is not a valid instance of DOMRect.");
}
return esValue[implSymbol]["height"];
}
set height(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set height' called on an object that is not a valid instance of DOMRect.");
}
V = conversions["unrestricted double"](V, {
context: "Failed to set the 'height' property on 'DOMRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["height"] = V;
}
static fromRect() {
const args = [];
{
let curArg = arguments[0];
curArg = DOMRectInit.convert(globalObject, curArg, {
context: "Failed to execute 'fromRect' on 'DOMRect': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.fromRect(globalObject, ...args));
}
}
Object.defineProperties(DOMRect.prototype, {
x: { enumerable: true },
y: { enumerable: true },
width: { enumerable: true },
height: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMRect", configurable: true }
});
Object.defineProperties(DOMRect, { fromRect: { enumerable: true } });
ctorRegistry[interfaceName] = DOMRect;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMRect
});
};
const Impl = require("../../jsdom/living/geometry/DOMRect-impl.js");
+76
View File
@@ -0,0 +1,76 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "height";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unrestricted double"](value, {
context: context + " has member 'height' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "width";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unrestricted double"](value, {
context: context + " has member 'width' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "x";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unrestricted double"](value, {
context: context + " has member 'x' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "y";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unrestricted double"](value, {
context: context + " has member 'y' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+285
View File
@@ -0,0 +1,285 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DOMRectInit = require("./DOMRectInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMRectReadOnly";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMRectReadOnly'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMRectReadOnly"].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 DOMRectReadOnly {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRectReadOnly': parameter 1",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRectReadOnly': parameter 2",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRectReadOnly': parameter 3",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
curArg = conversions["unrestricted double"](curArg, {
context: "Failed to construct 'DOMRectReadOnly': parameter 4",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
toJSON() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'toJSON' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol].toJSON();
}
get x() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get x' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["x"];
}
get y() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get y' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["y"];
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get width' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["width"];
}
get height() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get height' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["height"];
}
get top() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get top' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["top"];
}
get right() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get right' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["right"];
}
get bottom() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get bottom' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["bottom"];
}
get left() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get left' called on an object that is not a valid instance of DOMRectReadOnly."
);
}
return esValue[implSymbol]["left"];
}
static fromRect() {
const args = [];
{
let curArg = arguments[0];
curArg = DOMRectInit.convert(globalObject, curArg, {
context: "Failed to execute 'fromRect' on 'DOMRectReadOnly': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(Impl.implementation.fromRect(globalObject, ...args));
}
}
Object.defineProperties(DOMRectReadOnly.prototype, {
toJSON: { enumerable: true },
x: { enumerable: true },
y: { enumerable: true },
width: { enumerable: true },
height: { enumerable: true },
top: { enumerable: true },
right: { enumerable: true },
bottom: { enumerable: true },
left: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMRectReadOnly", configurable: true }
});
Object.defineProperties(DOMRectReadOnly, { fromRect: { enumerable: true } });
ctorRegistry[interfaceName] = DOMRectReadOnly;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMRectReadOnly
});
};
const Impl = require("../../jsdom/living/geometry/DOMRectReadOnly-impl.js");
+299
View File
@@ -0,0 +1,299 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMStringMap";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMStringMap'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMStringMap"].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) => {
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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMStringMap {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(DOMStringMap.prototype, {
[Symbol.toStringTag]: { value: "DOMStringMap", configurable: true }
});
ctorRegistry[interfaceName] = DOMStringMap;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMStringMap
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
if (!Object.hasOwn(target, key)) {
keys.add(`${key}`);
}
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
const namedValue = target[implSymbol][utils.namedGet](P);
if (namedValue !== undefined && !Object.hasOwn(target, P) && !ignoreNamedProps) {
return {
writable: true,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(namedValue)
};
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
if (typeof P === "string") {
let namedValue = V;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
if (creating) {
target[implSymbol][utils.namedSetNew](P, namedValue);
} else {
target[implSymbol][utils.namedSetExisting](P, namedValue);
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
return true;
}
}
let ownDesc;
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (desc.get || desc.set) {
return false;
}
let namedValue = desc.value;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
if (creating) {
target[implSymbol][utils.namedSetNew](P, namedValue);
} else {
target[implSymbol][utils.namedSetExisting](P, namedValue);
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
return true;
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (target[implSymbol][utils.namedGet](P) !== undefined && !Object.hasOwn(target, P)) {
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
target[implSymbol][utils.namedDelete](P);
return true;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/nodes/DOMStringMap-impl.js");
+539
View File
@@ -0,0 +1,539 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMTokenList";
exports.is = value => {
return utils.isObject(value) && Object.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 'DOMTokenList'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMTokenList"].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) => {
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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMTokenList {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].item(...args);
}
contains(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'contains' called on an object that is not a valid instance of DOMTokenList."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].contains(...args);
}
add() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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),
globals: globalObject
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].add(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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),
globals: globalObject
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
toggle(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'toggle' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2",
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].toggle(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
replace(token, newToken) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'replace' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2",
globals: globalObject
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replace(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
supports(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'supports' called on an object that is not a valid instance of DOMTokenList."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].supports(...args);
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of DOMTokenList."
);
}
return esValue[implSymbol]["length"];
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of DOMTokenList."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["value"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'toString' called on an object that is not a valid instance of DOMTokenList."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(DOMTokenList.prototype, {
item: { enumerable: true },
contains: { enumerable: true },
add: { enumerable: true },
remove: { enumerable: true },
toggle: { enumerable: true },
replace: { enumerable: true },
supports: { enumerable: true },
length: { enumerable: true },
value: { enumerable: true },
toString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMTokenList", configurable: 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 }
});
ctorRegistry[interfaceName] = DOMTokenList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMTokenList
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
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("../../jsdom/living/nodes/DOMTokenList-impl.js");
+183
View File
@@ -0,0 +1,183 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DeviceMotionEventInit = require("./DeviceMotionEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "DeviceMotionEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'DeviceMotionEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DeviceMotionEvent"].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) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DeviceMotionEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to construct 'DeviceMotionEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DeviceMotionEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = DeviceMotionEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'DeviceMotionEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get acceleration() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get acceleration' called on an object that is not a valid instance of DeviceMotionEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["acceleration"]);
}
get accelerationIncludingGravity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get accelerationIncludingGravity' called on an object that is not a valid instance of DeviceMotionEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["accelerationIncludingGravity"]);
}
get rotationRate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get rotationRate' called on an object that is not a valid instance of DeviceMotionEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["rotationRate"]);
}
get interval() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get interval' called on an object that is not a valid instance of DeviceMotionEvent."
);
}
return esValue[implSymbol]["interval"];
}
}
Object.defineProperties(DeviceMotionEvent.prototype, {
acceleration: { enumerable: true },
accelerationIncludingGravity: { enumerable: true },
rotationRate: { enumerable: true },
interval: { enumerable: true },
[Symbol.toStringTag]: { value: "DeviceMotionEvent", configurable: true }
});
ctorRegistry[interfaceName] = DeviceMotionEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DeviceMotionEvent
});
};
const Impl = require("../../jsdom/living/events/DeviceMotionEvent-impl.js");
+145
View File
@@ -0,0 +1,145 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DeviceMotionEventAcceleration";
exports.is = value => {
return utils.isObject(value) && Object.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 'DeviceMotionEventAcceleration'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DeviceMotionEventAcceleration"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DeviceMotionEventAcceleration {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get x() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get x' called on an object that is not a valid instance of DeviceMotionEventAcceleration."
);
}
return esValue[implSymbol]["x"];
}
get y() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get y' called on an object that is not a valid instance of DeviceMotionEventAcceleration."
);
}
return esValue[implSymbol]["y"];
}
get z() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get z' called on an object that is not a valid instance of DeviceMotionEventAcceleration."
);
}
return esValue[implSymbol]["z"];
}
}
Object.defineProperties(DeviceMotionEventAcceleration.prototype, {
x: { enumerable: true },
y: { enumerable: true },
z: { enumerable: true },
[Symbol.toStringTag]: { value: "DeviceMotionEventAcceleration", configurable: true }
});
ctorRegistry[interfaceName] = DeviceMotionEventAcceleration;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DeviceMotionEventAcceleration
});
};
const Impl = require("../../jsdom/living/deviceorientation/DeviceMotionEventAcceleration-impl.js");
@@ -0,0 +1,61 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "x";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'x' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "y";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'y' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "z";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'z' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+70
View File
@@ -0,0 +1,70 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DeviceMotionEventAccelerationInit = require("./DeviceMotionEventAccelerationInit.js");
const DeviceMotionEventRotationRateInit = require("./DeviceMotionEventRotationRateInit.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "acceleration";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = DeviceMotionEventAccelerationInit.convert(globalObject, value, {
context: context + " has member 'acceleration' that"
});
ret[key] = value;
}
}
{
const key = "accelerationIncludingGravity";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = DeviceMotionEventAccelerationInit.convert(globalObject, value, {
context: context + " has member 'accelerationIncludingGravity' that"
});
ret[key] = value;
}
}
{
const key = "interval";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["double"](value, { context: context + " has member 'interval' that", globals: globalObject });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "rotationRate";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = DeviceMotionEventRotationRateInit.convert(globalObject, value, {
context: context + " has member 'rotationRate' that"
});
ret[key] = value;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+145
View File
@@ -0,0 +1,145 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DeviceMotionEventRotationRate";
exports.is = value => {
return utils.isObject(value) && Object.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 'DeviceMotionEventRotationRate'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DeviceMotionEventRotationRate"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DeviceMotionEventRotationRate {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get alpha() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get alpha' called on an object that is not a valid instance of DeviceMotionEventRotationRate."
);
}
return esValue[implSymbol]["alpha"];
}
get beta() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get beta' called on an object that is not a valid instance of DeviceMotionEventRotationRate."
);
}
return esValue[implSymbol]["beta"];
}
get gamma() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get gamma' called on an object that is not a valid instance of DeviceMotionEventRotationRate."
);
}
return esValue[implSymbol]["gamma"];
}
}
Object.defineProperties(DeviceMotionEventRotationRate.prototype, {
alpha: { enumerable: true },
beta: { enumerable: true },
gamma: { enumerable: true },
[Symbol.toStringTag]: { value: "DeviceMotionEventRotationRate", configurable: true }
});
ctorRegistry[interfaceName] = DeviceMotionEventRotationRate;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DeviceMotionEventRotationRate
});
};
const Impl = require("../../jsdom/living/deviceorientation/DeviceMotionEventRotationRate-impl.js");
@@ -0,0 +1,61 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "alpha";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'alpha' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "beta";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'beta' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "gamma";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'gamma' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+183
View File
@@ -0,0 +1,183 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DeviceOrientationEventInit = require("./DeviceOrientationEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "DeviceOrientationEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'DeviceOrientationEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DeviceOrientationEvent"].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) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DeviceOrientationEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to construct 'DeviceOrientationEvent': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DeviceOrientationEvent': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = DeviceOrientationEventInit.convert(globalObject, curArg, {
context: "Failed to construct 'DeviceOrientationEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get alpha() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get alpha' called on an object that is not a valid instance of DeviceOrientationEvent."
);
}
return esValue[implSymbol]["alpha"];
}
get beta() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get beta' called on an object that is not a valid instance of DeviceOrientationEvent."
);
}
return esValue[implSymbol]["beta"];
}
get gamma() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get gamma' called on an object that is not a valid instance of DeviceOrientationEvent."
);
}
return esValue[implSymbol]["gamma"];
}
get absolute() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get absolute' called on an object that is not a valid instance of DeviceOrientationEvent."
);
}
return esValue[implSymbol]["absolute"];
}
}
Object.defineProperties(DeviceOrientationEvent.prototype, {
alpha: { enumerable: true },
beta: { enumerable: true },
gamma: { enumerable: true },
absolute: { enumerable: true },
[Symbol.toStringTag]: { value: "DeviceOrientationEvent", configurable: true }
});
ctorRegistry[interfaceName] = DeviceOrientationEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DeviceOrientationEvent
});
};
const Impl = require("../../jsdom/living/events/DeviceOrientationEvent-impl.js");
+80
View File
@@ -0,0 +1,80 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "absolute";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, {
context: context + " has member 'absolute' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "alpha";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'alpha' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "beta";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'beta' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "gamma";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = conversions["double"](value, { context: context + " has member 'gamma' that", globals: globalObject });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+4511
View File
File diff suppressed because it is too large Load Diff
+336
View File
@@ -0,0 +1,336 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DocumentFragment";
exports.is = value => {
return utils.isObject(value) && Object.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 'DocumentFragment'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DocumentFragment"].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) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DocumentFragment extends globalObject.Node {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
getElementById(elementId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getElementById' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args));
}
prepend() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].prepend(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
append() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].append(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
replaceChildren() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceChildren' on 'DocumentFragment': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replaceChildren(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
querySelector(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'querySelector' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args));
}
querySelectorAll(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'querySelectorAll' called on an object that is not a valid instance of DocumentFragment."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args));
}
get children() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get children' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.getSameObject(this, "children", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["children"]);
});
}
get firstElementChild() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get firstElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]);
}
get lastElementChild() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get lastElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]);
}
get childElementCount() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get childElementCount' called on an object that is not a valid instance of DocumentFragment."
);
}
return esValue[implSymbol]["childElementCount"];
}
}
Object.defineProperties(DocumentFragment.prototype, {
getElementById: { enumerable: true },
prepend: { enumerable: true },
append: { enumerable: true },
replaceChildren: { enumerable: true },
querySelector: { enumerable: true },
querySelectorAll: { enumerable: true },
children: { enumerable: true },
firstElementChild: { enumerable: true },
lastElementChild: { enumerable: true },
childElementCount: { enumerable: true },
[Symbol.toStringTag]: { value: "DocumentFragment", configurable: true },
[Symbol.unscopables]: {
value: { prepend: true, append: true, replaceChildren: true, __proto__: null },
configurable: true
}
});
ctorRegistry[interfaceName] = DocumentFragment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DocumentFragment
});
};
const Impl = require("../../jsdom/living/nodes/DocumentFragment-impl.js");
+12
View File
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["loading", "interactive", "complete"]);
exports.enumerationValues = enumerationValues;
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`);
}
return string;
};
+254
View File
@@ -0,0 +1,254 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DocumentType";
exports.is = value => {
return utils.isObject(value) && Object.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 'DocumentType'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DocumentType"].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) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DocumentType extends globalObject.Node {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].before(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].after(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1),
globals: globalObject
});
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replaceWith(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of DocumentType.");
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove();
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["name"];
}
get publicId() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get publicId' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["publicId"];
}
get systemId() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get systemId' called on an object that is not a valid instance of DocumentType."
);
}
return esValue[implSymbol]["systemId"];
}
}
Object.defineProperties(DocumentType.prototype, {
before: { enumerable: true },
after: { enumerable: true },
replaceWith: { enumerable: true },
remove: { enumerable: true },
name: { enumerable: true },
publicId: { enumerable: true },
systemId: { enumerable: true },
[Symbol.toStringTag]: { value: "DocumentType", configurable: true },
[Symbol.unscopables]: {
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
configurable: true
}
});
ctorRegistry[interfaceName] = DocumentType;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DocumentType
});
};
const Impl = require("../../jsdom/living/nodes/DocumentType-impl.js");
+3720
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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", globals: globalObject });
ret[key] = value;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+29
View File
@@ -0,0 +1,29 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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",
globals: globalObject
});
ret[key] = value;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["transparent", "native"]);
exports.enumerationValues = enumerationValues;
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`);
}
return string;
};
+192
View File
@@ -0,0 +1,192 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ErrorEventInit = require("./ErrorEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "ErrorEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'ErrorEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["ErrorEvent"].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) => {
Event._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 ErrorEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
get message() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get message' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["message"];
}
get filename() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get filename' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["filename"];
}
get lineno() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get lineno' called on an object that is not a valid instance of ErrorEvent."
);
}
return esValue[implSymbol]["lineno"];
}
get colno() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get colno' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["colno"];
}
get error() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["error"];
}
}
Object.defineProperties(ErrorEvent.prototype, {
message: { enumerable: true },
filename: { enumerable: true },
lineno: { enumerable: true },
colno: { enumerable: true },
error: { enumerable: true },
[Symbol.toStringTag]: { value: "ErrorEvent", configurable: true }
});
ctorRegistry[interfaceName] = ErrorEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: ErrorEvent
});
};
const Impl = require("../../jsdom/living/events/ErrorEvent-impl.js");
+92
View File
@@ -0,0 +1,92 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = null;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = "";
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+430
View File
@@ -0,0 +1,430 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Event";
exports.is = value => {
return utils.isObject(value) && Object.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 'Event'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["Event"].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);
};
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 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;
}
exports._internalSetup = (wrapper, globalObject) => {
utils.define(wrapper, getUnforgeables(globalObject));
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const unforgeablesMap = new WeakMap();
const exposed = new Set(["Window", "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 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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
composedPath() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'composedPath' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].composedPath());
}
stopPropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'stopPropagation' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol].stopPropagation();
}
stopImmediatePropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'stopImmediatePropagation' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol].stopImmediatePropagation();
}
preventDefault() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'preventDefault' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol].preventDefault();
}
initEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'initEvent' called on an object that is not a valid instance of Event.");
}
if (arguments.length < 1) {
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",
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",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initEvent' on 'Event': parameter 3",
globals: globalObject
});
} else {
curArg = false;
}
args.push(curArg);
}
return esValue[implSymbol].initEvent(...args);
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["type"];
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get target' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["target"]);
}
get srcElement() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get srcElement' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["srcElement"]);
}
get currentTarget() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get currentTarget' called on an object that is not a valid instance of Event."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["currentTarget"]);
}
get eventPhase() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get eventPhase' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["eventPhase"];
}
get cancelBubble() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cancelBubble' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["cancelBubble"];
}
set cancelBubble(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
esValue[implSymbol]["cancelBubble"] = V;
}
get bubbles() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get bubbles' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["bubbles"];
}
get cancelable() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get cancelable' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["cancelable"];
}
get returnValue() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get returnValue' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["returnValue"];
}
set returnValue(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
esValue[implSymbol]["returnValue"] = V;
}
get defaultPrevented() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get defaultPrevented' called on an object that is not a valid instance of Event."
);
}
return esValue[implSymbol]["defaultPrevented"];
}
get composed() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get composed' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["composed"];
}
get timeStamp() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get timeStamp' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["timeStamp"];
}
}
Object.defineProperties(Event.prototype, {
composedPath: { enumerable: true },
stopPropagation: { enumerable: true },
stopImmediatePropagation: { enumerable: true },
preventDefault: { enumerable: true },
initEvent: { enumerable: true },
type: { enumerable: true },
target: { enumerable: true },
srcElement: { enumerable: true },
currentTarget: { enumerable: true },
eventPhase: { enumerable: true },
cancelBubble: { enumerable: true },
bubbles: { enumerable: true },
cancelable: { enumerable: true },
returnValue: { enumerable: true },
defaultPrevented: { enumerable: true },
composed: { enumerable: true },
timeStamp: { enumerable: true },
[Symbol.toStringTag]: { value: "Event", configurable: true },
NONE: { value: 0, enumerable: true },
CAPTURING_PHASE: { value: 1, enumerable: true },
AT_TARGET: { value: 2, enumerable: true },
BUBBLING_PHASE: { value: 3, enumerable: true }
});
Object.defineProperties(Event, {
NONE: { value: 0, enumerable: true },
CAPTURING_PHASE: { value: 1, enumerable: true },
AT_TARGET: { value: 2, enumerable: true },
BUBBLING_PHASE: { value: 3, enumerable: true }
});
ctorRegistry[interfaceName] = Event;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Event
});
};
const Impl = require("../../jsdom/living/events/Event-impl.js");
+36
View File
@@ -0,0 +1,36 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
function invokeTheCallbackFunction(event) {
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
if (typeof value === "function") {
event = utils.tryWrapperForImpl(event);
callResult = Reflect.apply(value, thisArg, [event]);
}
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
invokeTheCallbackFunction.construct = event => {
event = utils.tryWrapperForImpl(event);
let callResult = Reflect.construct(value, [event]);
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
+58
View File
@@ -0,0 +1,58 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+35
View File
@@ -0,0 +1,35 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (!utils.isObject(value)) {
throw new globalObject.TypeError(`${context} is not an object.`);
}
function callTheUserObjectsOperation(event) {
let thisArg = utils.tryWrapperForImpl(this);
let O = value;
let X = O;
if (typeof O !== "function") {
X = O["handleEvent"];
if (typeof X !== "function") {
throw new globalObject.TypeError(`${context} does not correctly implement EventListener.`);
}
thisArg = O;
}
event = utils.tryWrapperForImpl(event);
let callResult = Reflect.apply(X, thisArg, [event]);
}
callTheUserObjectsOperation[utils.wrapperSymbol] = value;
callTheUserObjectsOperation.objectReference = value;
return callTheUserObjectsOperation;
};
exports.install = (globalObject, globalNames) => {};
+28
View File
@@ -0,0 +1,28 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+221
View File
@@ -0,0 +1,221 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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", globals: globalObject });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+259
View File
@@ -0,0 +1,259 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventListener = require("./EventListener.js");
const AddEventListenerOptions = require("./AddEventListenerOptions.js");
const EventListenerOptions = require("./EventListenerOptions.js");
const Event = require("./Event.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "EventTarget";
exports.is = value => {
return utils.isObject(value) && Object.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 'EventTarget'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["EventTarget"].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", "AudioWorklet"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
addEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'addEventListener' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(globalObject, curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 2"
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = AddEventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(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",
globals: globalObject
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
}
}
args.push(curArg);
}
return esValue[implSymbol].addEventListener(...args);
}
removeEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'removeEventListener' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 2) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(globalObject, curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 2"
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = EventListenerOptions.convert(globalObject, curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(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",
globals: globalObject
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3",
globals: globalObject
});
}
}
args.push(curArg);
}
return esValue[implSymbol].removeEventListener(...args);
}
dispatchEvent(event) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'dispatchEvent' called on an object that is not a valid instance of EventTarget."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].dispatchEvent(...args);
}
}
Object.defineProperties(EventTarget.prototype, {
addEventListener: { enumerable: true },
removeEventListener: { enumerable: true },
dispatchEvent: { enumerable: true },
[Symbol.toStringTag]: { value: "EventTarget", configurable: true }
});
ctorRegistry[interfaceName] = EventTarget;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: EventTarget
});
};
const Impl = require("../../jsdom/living/events/EventTarget-impl.js");
+130
View File
@@ -0,0 +1,130 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "External";
exports.is = value => {
return utils.isObject(value) && Object.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 'External'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["External"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class External {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
AddSearchProvider() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'AddSearchProvider' called on an object that is not a valid instance of External."
);
}
return esValue[implSymbol].AddSearchProvider();
}
IsSearchProviderInstalled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'IsSearchProviderInstalled' called on an object that is not a valid instance of External."
);
}
return esValue[implSymbol].IsSearchProviderInstalled();
}
}
Object.defineProperties(External.prototype, {
AddSearchProvider: { enumerable: true },
IsSearchProviderInstalled: { enumerable: true },
[Symbol.toStringTag]: { value: "External", configurable: true }
});
ctorRegistry[interfaceName] = External;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: External
});
};
const Impl = require("../../jsdom/living/window/External-impl.js");
+185
View File
@@ -0,0 +1,185 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const FilePropertyBag = require("./FilePropertyBag.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "File";
exports.is = value => {
return utils.isObject(value) && Object.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 'File'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["File"].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) => {
Blob._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 File extends globalObject.Blob {
constructor(fileBits, fileName) {
if (arguments.length < 2) {
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 globalObject.TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
for (let nextItem of tmp) {
if (Blob.is(nextItem)) {
nextItem = utils.implForWrapper(nextItem);
} else if (utils.isArrayBuffer(nextItem)) {
nextItem = conversions["ArrayBuffer"](nextItem, {
context: "Failed to construct 'File': parameter 1" + "'s element",
globals: globalObject
});
} else if (ArrayBuffer.isView(nextItem)) {
nextItem = conversions["ArrayBufferView"](nextItem, {
context: "Failed to construct 'File': parameter 1" + "'s element",
globals: globalObject
});
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'File': parameter 1" + "'s element",
globals: globalObject
});
}
V.push(nextItem);
}
curArg = V;
}
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, {
context: "Failed to construct 'File': parameter 2",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[2];
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);
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of File.");
}
return esValue[implSymbol]["name"];
}
get lastModified() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get lastModified' called on an object that is not a valid instance of File."
);
}
return esValue[implSymbol]["lastModified"];
}
}
Object.defineProperties(File.prototype, {
name: { enumerable: true },
lastModified: { enumerable: true },
[Symbol.toStringTag]: { value: "File", configurable: true }
});
ctorRegistry[interfaceName] = File;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: File
});
};
const Impl = require("../../jsdom/living/file-api/File-impl.js");
+298
View File
@@ -0,0 +1,298 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "FileList";
exports.is = value => {
return utils.isObject(value) && Object.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 'FileList'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FileList"].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) => {
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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
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 FileList {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of FileList.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].item(...args));
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of FileList.");
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(FileList.prototype, {
item: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "FileList", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = FileList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FileList
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
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("../../jsdom/living/file-api/FileList-impl.js");
+33
View File
@@ -0,0 +1,33 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag.js");
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",
globals: globalObject
});
ret[key] = value;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+468
View File
@@ -0,0 +1,468 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const EventTarget = require("./EventTarget.js");
const interfaceName = "FileReader";
exports.is = value => {
return utils.isObject(value) && Object.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 'FileReader'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FileReader"].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) => {
EventTarget._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 FileReader extends globalObject.EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
readAsArrayBuffer(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'readAsArrayBuffer' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsArrayBuffer(...args);
}
readAsBinaryString(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'readAsBinaryString' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsBinaryString(...args);
}
readAsText(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'readAsText' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
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(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",
globals: globalObject
});
}
args.push(curArg);
}
return esValue[implSymbol].readAsText(...args);
}
readAsDataURL(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'readAsDataURL' called on an object that is not a valid instance of FileReader."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsDataURL(...args);
}
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'abort' called on an object that is not a valid instance of FileReader.");
}
return esValue[implSymbol].abort();
}
get readyState() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get readyState' called on an object that is not a valid instance of FileReader."
);
}
return esValue[implSymbol]["readyState"];
}
get result() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get result' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["result"]);
}
get error() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["error"]);
}
get onloadstart() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onloadstart' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]);
}
set onloadstart(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onloadstart' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onloadstart"] = V;
}
get onprogress() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onprogress' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]);
}
set onprogress(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onprogress' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onprogress"] = V;
}
get onload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onload' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]);
}
set onload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onload' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onload"] = V;
}
get onabort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onabort' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
}
set onabort(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onabort' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onabort"] = V;
}
get onerror() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onerror' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]);
}
set onerror(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onerror' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onerror"] = V;
}
get onloadend() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onloadend' called on an object that is not a valid instance of FileReader."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]);
}
set onloadend(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onloadend' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onloadend"] = V;
}
}
Object.defineProperties(FileReader.prototype, {
readAsArrayBuffer: { enumerable: true },
readAsBinaryString: { enumerable: true },
readAsText: { enumerable: true },
readAsDataURL: { enumerable: true },
abort: { enumerable: true },
readyState: { enumerable: true },
result: { enumerable: true },
error: { enumerable: true },
onloadstart: { enumerable: true },
onprogress: { enumerable: true },
onload: { enumerable: true },
onabort: { enumerable: true },
onerror: { enumerable: true },
onloadend: { enumerable: true },
[Symbol.toStringTag]: { value: "FileReader", configurable: true },
EMPTY: { value: 0, enumerable: true },
LOADING: { value: 1, enumerable: true },
DONE: { value: 2, enumerable: true }
});
Object.defineProperties(FileReader, {
EMPTY: { value: 0, enumerable: true },
LOADING: { value: 1, enumerable: true },
DONE: { value: 2, enumerable: true }
});
ctorRegistry[interfaceName] = FileReader;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FileReader
});
};
const Impl = require("../../jsdom/living/file-api/FileReader-impl.js");
+144
View File
@@ -0,0 +1,144 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const FocusEventInit = require("./FocusEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const UIEvent = require("./UIEvent.js");
const interfaceName = "FocusEvent";
exports.is = value => {
return utils.isObject(value) && Object.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 'FocusEvent'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FocusEvent"].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) => {
UIEvent._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class FocusEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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);
}
get relatedTarget() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get relatedTarget' called on an object that is not a valid instance of FocusEvent."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]);
}
}
Object.defineProperties(FocusEvent.prototype, {
relatedTarget: { enumerable: true },
[Symbol.toStringTag]: { value: "FocusEvent", configurable: true }
});
ctorRegistry[interfaceName] = FocusEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FocusEvent
});
};
const Impl = require("../../jsdom/living/events/FocusEvent-impl.js");
+36
View File
@@ -0,0 +1,36 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(globalObject, obj, ret, { context });
{
const key = "relatedTarget";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = EventTarget.convert(globalObject, value, { context: context + " has member 'relatedTarget' that" });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
+468
View File
@@ -0,0 +1,468 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLFormElement = require("./HTMLFormElement.js");
const HTMLElement = require("./HTMLElement.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";
exports.is = value => {
return utils.isObject(value) && Object.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 'FormData'.`);
};
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
});
return iterator;
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["FormData"].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 FormData {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = HTMLFormElement.convert(globalObject, curArg, {
context: "Failed to construct 'FormData': parameter 1"
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = HTMLElement.convert(globalObject, curArg, {
context: "Failed to construct 'FormData': parameter 2"
});
}
} else {
curArg = null;
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
append(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'append' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new globalObject.TypeError(
`Failed to execute 'append' on 'FormData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
switch (arguments.length) {
case 2:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
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",
globals: globalObject
});
args.push(curArg);
}
}
}
break;
default:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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",
globals: globalObject
});
}
args.push(curArg);
}
}
return esValue[implSymbol].append(...args);
}
delete(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'delete' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].delete(...args);
}
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].get(...args));
}
getAll(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'getAll' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
}
has(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'has' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].has(...args);
}
set(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new globalObject.TypeError(
`Failed to execute 'set' on 'FormData': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
switch (arguments.length) {
case 2:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
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",
globals: globalObject
});
args.push(curArg);
}
}
}
break;
default:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
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",
globals: globalObject
});
}
args.push(curArg);
}
}
return esValue[implSymbol].set(...args);
}
keys() {
if (!exports.is(this)) {
throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(globalObject, this, "key");
}
values() {
if (!exports.is(this)) {
throw new globalObject.TypeError("'values' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(globalObject, this, "value");
}
entries() {
if (!exports.is(this)) {
throw new globalObject.TypeError("'entries' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(globalObject, this, "key+value");
}
forEach(callback) {
if (!exports.is(this)) {
throw new globalObject.TypeError("'forEach' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
"Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present."
);
}
callback = Function.convert(globalObject, callback, {
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
});
const thisArg = arguments[1];
let pairs = Array.from(this[implSymbol]);
let i = 0;
while (i < pairs.length) {
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
callback.call(thisArg, value, key, this);
pairs = Array.from(this[implSymbol]);
i++;
}
}
}
Object.defineProperties(FormData.prototype, {
append: { enumerable: true },
delete: { enumerable: true },
get: { enumerable: true },
getAll: { enumerable: true },
has: { enumerable: true },
set: { enumerable: true },
keys: { enumerable: true },
values: { enumerable: true },
entries: { enumerable: true },
forEach: { enumerable: true },
[Symbol.toStringTag]: { value: "FormData", configurable: true },
[Symbol.iterator]: { value: FormData.prototype.entries, configurable: true, writable: true }
});
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,
writable: true,
value: FormData
});
};
const Impl = require("../../jsdom/living/xhr/FormData-impl.js");
+42
View File
@@ -0,0 +1,42 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(...args) {
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
for (let i = 0; i < args.length; i++) {
args[i] = utils.tryWrapperForImpl(args[i]);
}
callResult = Reflect.apply(value, thisArg, args);
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
}
invokeTheCallbackFunction.construct = (...args) => {
for (let i = 0; i < args.length; i++) {
args[i] = utils.tryWrapperForImpl(args[i]);
}
let callResult = Reflect.construct(value, args);
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
+31
View File
@@ -0,0 +1,31 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
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",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new globalObject.TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(globalObject, obj, ret, { context });
return ret;
};
File diff suppressed because it is too large Load Diff
+825
View File
@@ -0,0 +1,825 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLAreaElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLAreaElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLAreaElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLAreaElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get alt() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get alt' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("alt");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set alt(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("alt", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get coords() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get coords' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("coords");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set coords(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("coords", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get shape() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get shape' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("shape");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set shape(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("shape", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("target");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set target(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("target", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get rel() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get rel' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("rel");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set rel(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("rel", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get relList() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get relList' called on an object that is not a valid instance of HTMLAreaElement."
);
}
return utils.getSameObject(this, "relList", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]);
});
}
set relList(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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 globalObject.TypeError("Property 'relList' is not an object");
}
Reflect.set(Q, "value", V);
}
get noHref() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get noHref' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("nohref") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set noHref(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("nohref", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("nohref");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get href() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get href' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set href(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["href"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'toString' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get origin() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get origin' called on an object that is not a valid instance of HTMLAreaElement."
);
}
return esValue[implSymbol]["origin"];
}
get protocol() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get protocol' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["protocol"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set protocol(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["protocol"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get username() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get username' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["username"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set username(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["username"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get password() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get password' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["password"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set password(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["password"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get host() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get host' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["host"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set host(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["host"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get hostname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get hostname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hostname"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set hostname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hostname"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get port() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get port' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["port"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set port(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["port"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get pathname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get pathname' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["pathname"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set pathname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["pathname"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get search() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get search' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["search"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set search(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["search"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get hash() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get hash' called on an object that is not a valid instance of HTMLAreaElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hash"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set hash(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hash"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLAreaElement.prototype, {
alt: { enumerable: true },
coords: { enumerable: true },
shape: { enumerable: true },
target: { enumerable: true },
rel: { enumerable: true },
relList: { enumerable: true },
noHref: { enumerable: true },
href: { enumerable: true },
toString: { enumerable: true },
origin: { enumerable: true },
protocol: { enumerable: true },
username: { enumerable: true },
password: { enumerable: true },
host: { enumerable: true },
hostname: { enumerable: true },
port: { enumerable: true },
pathname: { enumerable: true },
search: { enumerable: true },
hash: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLAreaElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLAreaElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLAreaElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLAreaElement-impl.js");
+111
View File
@@ -0,0 +1,111 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLMediaElement = require("./HTMLMediaElement.js");
const interfaceName = "HTMLAudioElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLAudioElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLAudioElement"].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) => {
HTMLMediaElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLAudioElement extends globalObject.HTMLMediaElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
}
Object.defineProperties(HTMLAudioElement.prototype, {
[Symbol.toStringTag]: { value: "HTMLAudioElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLAudioElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLAudioElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLAudioElement-impl.js");
+156
View File
@@ -0,0 +1,156 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLBRElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLBRElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBRElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBRElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get clear() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get clear' called on an object that is not a valid instance of HTMLBRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("clear");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set clear(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("clear", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLBRElement.prototype, {
clear: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBRElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLBRElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLBRElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLBRElement-impl.js");
+196
View File
@@ -0,0 +1,196 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLBaseElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLBaseElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBaseElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBaseElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get href() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get href' called on an object that is not a valid instance of HTMLBaseElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set href(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["href"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLBaseElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("target");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set target(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("target", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLBaseElement.prototype, {
href: { enumerable: true },
target: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBaseElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLBaseElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLBaseElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLBaseElement-impl.js");
+880
View File
@@ -0,0 +1,880 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLBodyElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLBodyElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLBodyElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLBodyElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get text() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get text' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("text");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set text(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("text", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get link() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get link' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("link");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set link(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("link", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get vLink() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get vLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("vlink");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set vLink(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("vlink", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get aLink() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get aLink' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("alink");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set aLink(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("alink", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get bgColor() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get bgColor' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("bgcolor");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set bgColor(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("bgcolor", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get background() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get background' called on an object that is not a valid instance of HTMLBodyElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("background");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set background(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("background", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get onafterprint() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onafterprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]);
}
set onafterprint(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onafterprint' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onafterprint"] = V;
}
get onbeforeprint() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]);
}
set onbeforeprint(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onbeforeprint' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onbeforeprint"] = V;
}
get onbeforeunload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]);
}
set onbeforeunload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onbeforeunload' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onbeforeunload"] = V;
}
get onhashchange() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onhashchange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]);
}
set onhashchange(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onhashchange' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onhashchange"] = V;
}
get onlanguagechange() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]);
}
set onlanguagechange(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onlanguagechange' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onlanguagechange"] = V;
}
get onmessage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onmessage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]);
}
set onmessage(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onmessage' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onmessage"] = V;
}
get onmessageerror() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onmessageerror' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]);
}
set onmessageerror(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onmessageerror' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onmessageerror' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onmessageerror"] = V;
}
get onoffline() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onoffline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]);
}
set onoffline(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onoffline' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onoffline"] = V;
}
get ononline() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get ononline' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]);
}
set ononline(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'ononline' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["ononline"] = V;
}
get onpagehide() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpagehide' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]);
}
set onpagehide(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onpagehide' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onpagehide"] = V;
}
get onpageshow() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpageshow' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]);
}
set onpageshow(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onpageshow' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onpageshow"] = V;
}
get onpopstate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpopstate' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]);
}
set onpopstate(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onpopstate' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onpopstate"] = V;
}
get onrejectionhandled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]);
}
set onrejectionhandled(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onrejectionhandled' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onrejectionhandled"] = V;
}
get onstorage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onstorage' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]);
}
set onstorage(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onstorage' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onstorage"] = V;
}
get onunhandledrejection() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]);
}
set onunhandledrejection(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onunhandledrejection' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onunhandledrejection"] = V;
}
get onunload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onunload' called on an object that is not a valid instance of HTMLBodyElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]);
}
set onunload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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(globalObject, V, {
context: "Failed to set the 'onunload' property on 'HTMLBodyElement': The provided value"
});
}
esValue[implSymbol]["onunload"] = V;
}
}
Object.defineProperties(HTMLBodyElement.prototype, {
text: { enumerable: true },
link: { enumerable: true },
vLink: { enumerable: true },
aLink: { enumerable: true },
bgColor: { enumerable: true },
background: { enumerable: true },
onafterprint: { enumerable: true },
onbeforeprint: { enumerable: true },
onbeforeunload: { enumerable: true },
onhashchange: { enumerable: true },
onlanguagechange: { enumerable: true },
onmessage: { enumerable: true },
onmessageerror: { enumerable: true },
onoffline: { enumerable: true },
ononline: { enumerable: true },
onpagehide: { enumerable: true },
onpageshow: { enumerable: true },
onpopstate: { enumerable: true },
onrejectionhandled: { enumerable: true },
onstorage: { enumerable: true },
onunhandledrejection: { enumerable: true },
onunload: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBodyElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLBodyElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLBodyElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLBodyElement-impl.js");
+525
View File
@@ -0,0 +1,525 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLButtonElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLButtonElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLButtonElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLButtonElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
checkValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'checkValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol].checkValidity();
}
reportValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'reportValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol].reportValidity();
}
setCustomValidity(error) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'setCustomValidity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].setCustomValidity(...args);
}
get autofocus() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get autofocus' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("autofocus") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set autofocus(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("autofocus", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("autofocus");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get disabled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get disabled' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("disabled") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set disabled(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("disabled", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("disabled");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get form() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get form' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["form"]);
}
get formNoValidate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get formNoValidate' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("formnovalidate") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set formNoValidate(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("formnovalidate", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("formnovalidate");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get formTarget() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get formTarget' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("formtarget");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set formTarget(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("formtarget", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get type' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["type"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set type(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["type"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of HTMLButtonElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("value");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("value", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get willValidate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get willValidate' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol]["willValidate"];
}
get validity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get validity' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]);
}
get validationMessage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get validationMessage' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return esValue[implSymbol]["validationMessage"];
}
get labels() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get labels' called on an object that is not a valid instance of HTMLButtonElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]);
}
}
Object.defineProperties(HTMLButtonElement.prototype, {
checkValidity: { enumerable: true },
reportValidity: { enumerable: true },
setCustomValidity: { enumerable: true },
autofocus: { enumerable: true },
disabled: { enumerable: true },
form: { enumerable: true },
formNoValidate: { enumerable: true },
formTarget: { enumerable: true },
name: { enumerable: true },
type: { enumerable: true },
value: { enumerable: true },
willValidate: { enumerable: true },
validity: { enumerable: true },
validationMessage: { enumerable: true },
labels: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLButtonElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLButtonElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLButtonElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLButtonElement-impl.js");
+307
View File
@@ -0,0 +1,307 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const BlobCallback = require("./BlobCallback.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLCanvasElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLCanvasElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLCanvasElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLCanvasElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
getContext(contextId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getContext' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
if (arguments.length < 1) {
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",
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),
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getContext(...args));
}
toDataURL() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 2",
globals: globalObject
});
}
args.push(curArg);
}
return esValue[implSymbol].toDataURL(...args);
}
toBlob(callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'toBlob' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
if (arguments.length < 1) {
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(globalObject, curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 2",
globals: globalObject
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 3",
globals: globalObject
});
}
args.push(curArg);
}
return esValue[implSymbol].toBlob(...args);
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get width' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["width"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set width(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["width"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get height() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get height' called on an object that is not a valid instance of HTMLCanvasElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["height"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set height(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["height"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLCanvasElement.prototype, {
getContext: { enumerable: true },
toDataURL: { enumerable: true },
toBlob: { enumerable: true },
width: { enumerable: true },
height: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLCanvasElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLCanvasElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLCanvasElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLCanvasElement-impl.js");
+352
View File
@@ -0,0 +1,352 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "HTMLCollection";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLCollection'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLCollection"].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) => {
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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLCollection {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'item' called on an object that is not a valid instance of HTMLCollection.");
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].item(...args));
}
namedItem(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'namedItem' called on an object that is not a valid instance of HTMLCollection."
);
}
if (arguments.length < 1) {
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",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args));
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of HTMLCollection."
);
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(HTMLCollection.prototype, {
item: { enumerable: true },
namedItem: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLCollection", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = HTMLCollection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLCollection
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
if (!(key in target)) {
keys.add(`${key}`);
}
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
const namedValue = target[implSymbol].namedItem(P);
if (namedValue !== null && !(P in target) && !ignoreNamedProps) {
return {
writable: false,
enumerable: false,
configurable: true,
value: utils.tryWrapperForImpl(namedValue)
};
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
if (!Object.hasOwn(target, P)) {
const creating = !(target[implSymbol].namedItem(P) !== null);
if (!creating) {
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);
}
if (target[implSymbol].namedItem(P) !== null && !(P in target)) {
return false;
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/nodes/HTMLCollection-impl.js");
+159
View File
@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDListElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDListElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDListElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDListElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get compact() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get compact' called on an object that is not a valid instance of HTMLDListElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("compact") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set compact(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("compact", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("compact");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDListElement.prototype, {
compact: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDListElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDListElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDListElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDListElement-impl.js");
+156
View File
@@ -0,0 +1,156 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDataElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDataElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDataElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDataElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get value' called on an object that is not a valid instance of HTMLDataElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("value");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("value", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDataElement.prototype, {
value: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDataElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDataElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDataElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDataElement-impl.js");
+126
View File
@@ -0,0 +1,126 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDataListElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDataListElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDataListElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDataListElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get options() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get options' called on an object that is not a valid instance of HTMLDataListElement."
);
}
return utils.getSameObject(this, "options", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["options"]);
});
}
}
Object.defineProperties(HTMLDataListElement.prototype, {
options: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDataListElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDataListElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDataListElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDataListElement-impl.js");
+159
View File
@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDetailsElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDetailsElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDetailsElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDetailsElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get open() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get open' called on an object that is not a valid instance of HTMLDetailsElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("open") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set open(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
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",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("open", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("open");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDetailsElement.prototype, {
open: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDetailsElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDetailsElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDetailsElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDetailsElement-impl.js");
+159
View File
@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDialogElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDialogElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDialogElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDialogElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get open() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get open' called on an object that is not a valid instance of HTMLDialogElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("open") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set open(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set open' called on an object that is not a valid instance of HTMLDialogElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'open' property on 'HTMLDialogElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("open", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("open");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDialogElement.prototype, {
open: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDialogElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDialogElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDialogElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDialogElement-impl.js");
+159
View File
@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDirectoryElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDirectoryElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDirectoryElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDirectoryElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get compact() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get compact' called on an object that is not a valid instance of HTMLDirectoryElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("compact") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set compact(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set compact' called on an object that is not a valid instance of HTMLDirectoryElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'compact' property on 'HTMLDirectoryElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("compact", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("compact");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDirectoryElement.prototype, {
compact: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDirectoryElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDirectoryElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDirectoryElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDirectoryElement-impl.js");
+156
View File
@@ -0,0 +1,156 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLDivElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLDivElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLDivElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLDivElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get align() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get align' called on an object that is not a valid instance of HTMLDivElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set align(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set align' called on an object that is not a valid instance of HTMLDivElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'align' property on 'HTMLDivElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLDivElement.prototype, {
align: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLDivElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLDivElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLDivElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLDivElement-impl.js");
File diff suppressed because it is too large Load Diff
+381
View File
@@ -0,0 +1,381 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLEmbedElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLEmbedElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLEmbedElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLEmbedElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get src() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get src' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const impl = esValue[implSymbol];
const value = impl._reflectGetTheContentAttribute("src");
if (value === null) {
return "";
}
const document = impl._ownerDocument;
if (this._srcURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
return this._srcURLCache;
}
this._srcURLCacheKey = value;
this._baseURLCache = document._baseURLCache;
const urlRecord = document.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set src(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set src' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'src' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("src", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get type' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("type");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set type(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set type' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'type' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("type", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get width' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("width");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set width(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set width' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'width' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("width", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get height() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get height' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("height");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set height(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set height' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'height' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("height", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get align() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get align' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set align(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set align' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'align' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLEmbedElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLEmbedElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLEmbedElement.prototype, {
src: { enumerable: true },
type: { enumerable: true },
width: { enumerable: true },
height: { enumerable: true },
align: { enumerable: true },
name: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLEmbedElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLEmbedElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLEmbedElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLEmbedElement-impl.js");
+332
View File
@@ -0,0 +1,332 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLFieldSetElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFieldSetElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFieldSetElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFieldSetElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
checkValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'checkValidity' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return esValue[implSymbol].checkValidity();
}
reportValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'reportValidity' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return esValue[implSymbol].reportValidity();
}
setCustomValidity(error) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'setCustomValidity' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'setCustomValidity' on 'HTMLFieldSetElement': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'setCustomValidity' on 'HTMLFieldSetElement': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].setCustomValidity(...args);
}
get disabled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get disabled' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("disabled") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set disabled(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set disabled' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'disabled' property on 'HTMLFieldSetElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("disabled", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("disabled");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get form() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get form' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["form"]);
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLFieldSetElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get type' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return esValue[implSymbol]["type"];
}
get elements() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get elements' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return utils.getSameObject(this, "elements", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["elements"]);
});
}
get willValidate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get willValidate' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return esValue[implSymbol]["willValidate"];
}
get validity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get validity' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return utils.getSameObject(this, "validity", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]);
});
}
get validationMessage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get validationMessage' called on an object that is not a valid instance of HTMLFieldSetElement."
);
}
return esValue[implSymbol]["validationMessage"];
}
}
Object.defineProperties(HTMLFieldSetElement.prototype, {
checkValidity: { enumerable: true },
reportValidity: { enumerable: true },
setCustomValidity: { enumerable: true },
disabled: { enumerable: true },
form: { enumerable: true },
name: { enumerable: true },
type: { enumerable: true },
elements: { enumerable: true },
willValidate: { enumerable: true },
validity: { enumerable: true },
validationMessage: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFieldSetElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLFieldSetElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFieldSetElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLFieldSetElement-impl.js");
+239
View File
@@ -0,0 +1,239 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLFontElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFontElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFontElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFontElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get color() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get color' called on an object that is not a valid instance of HTMLFontElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("color");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set color(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set color' called on an object that is not a valid instance of HTMLFontElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'color' property on 'HTMLFontElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("color", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get face() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get face' called on an object that is not a valid instance of HTMLFontElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("face");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set face(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set face' called on an object that is not a valid instance of HTMLFontElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'face' property on 'HTMLFontElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("face", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get size() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get size' called on an object that is not a valid instance of HTMLFontElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("size");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set size(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set size' called on an object that is not a valid instance of HTMLFontElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'size' property on 'HTMLFontElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("size", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLFontElement.prototype, {
color: { enumerable: true },
face: { enumerable: true },
size: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFontElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLFontElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFontElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLFontElement-impl.js");
+318
View File
@@ -0,0 +1,318 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLCollection = require("./HTMLCollection.js");
const interfaceName = "HTMLFormControlsCollection";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFormControlsCollection'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFormControlsCollection"].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) => {
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) => {
HTMLCollection._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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFormControlsCollection extends globalObject.HTMLCollection {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
namedItem(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'namedItem' called on an object that is not a valid instance of HTMLFormControlsCollection."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'namedItem' on 'HTMLFormControlsCollection': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'namedItem' on 'HTMLFormControlsCollection': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args));
}
}
Object.defineProperties(HTMLFormControlsCollection.prototype, {
namedItem: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFormControlsCollection", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = HTMLFormControlsCollection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFormControlsCollection
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
if (!(key in target)) {
keys.add(`${key}`);
}
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
const namedValue = target[implSymbol].namedItem(P);
if (namedValue !== null && !(P in target) && !ignoreNamedProps) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(namedValue)
};
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
if (!Object.hasOwn(target, P)) {
const creating = !(target[implSymbol].namedItem(P) !== null);
if (!creating) {
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);
}
if (target[implSymbol].namedItem(P) !== null && !(P in target)) {
return false;
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/nodes/HTMLFormControlsCollection-impl.js");
+661
View File
@@ -0,0 +1,661 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const HTMLElement = require("./HTMLElement.js");
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "HTMLFormElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFormElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFormElement"].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) => {
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) => {
HTMLElement._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 = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFormElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
submit() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'submit' called on an object that is not a valid instance of HTMLFormElement."
);
}
return esValue[implSymbol].submit();
}
requestSubmit() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'requestSubmit' called on an object that is not a valid instance of HTMLFormElement."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = HTMLElement.convert(globalObject, curArg, {
context: "Failed to execute 'requestSubmit' on 'HTMLFormElement': parameter 1"
});
}
args.push(curArg);
}
return esValue[implSymbol].requestSubmit(...args);
}
reset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'reset' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].reset();
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
checkValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'checkValidity' called on an object that is not a valid instance of HTMLFormElement."
);
}
return esValue[implSymbol].checkValidity();
}
reportValidity() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'reportValidity' called on an object that is not a valid instance of HTMLFormElement."
);
}
return esValue[implSymbol].reportValidity();
}
get acceptCharset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get acceptCharset' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("accept-charset");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set acceptCharset(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set acceptCharset' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'acceptCharset' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("accept-charset", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get action() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get action' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["action"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set action(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set action' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'action' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["action"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get enctype() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get enctype' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["enctype"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set enctype(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set enctype' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'enctype' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["enctype"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get method() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get method' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["method"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set method(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set method' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'method' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["method"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get noValidate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get noValidate' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("novalidate") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set noValidate(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set noValidate' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'noValidate' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("novalidate", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("novalidate");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get target' called on an object that is not a valid instance of HTMLFormElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("target");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set target(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set target' called on an object that is not a valid instance of HTMLFormElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLFormElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("target", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get elements() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get elements' called on an object that is not a valid instance of HTMLFormElement."
);
}
return utils.getSameObject(this, "elements", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["elements"]);
});
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get length' called on an object that is not a valid instance of HTMLFormElement."
);
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(HTMLFormElement.prototype, {
submit: { enumerable: true },
requestSubmit: { enumerable: true },
reset: { enumerable: true },
checkValidity: { enumerable: true },
reportValidity: { enumerable: true },
acceptCharset: { enumerable: true },
action: { enumerable: true },
enctype: { enumerable: true },
method: { enumerable: true },
name: { enumerable: true },
noValidate: { enumerable: true },
target: { enumerable: true },
elements: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFormElement", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = HTMLFormElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFormElement
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol][utils.indexedGet](index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol][utils.indexedGet](index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc);
}
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][utils.indexedGet](index) !== null);
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/nodes/HTMLFormElement-impl.js");
+513
View File
@@ -0,0 +1,513 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLFrameElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFrameElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFrameElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFrameElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set name' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get scrolling() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get scrolling' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("scrolling");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set scrolling(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set scrolling' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'scrolling' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("scrolling", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get src() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get src' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const impl = esValue[implSymbol];
const value = impl._reflectGetTheContentAttribute("src");
if (value === null) {
return "";
}
const document = impl._ownerDocument;
if (this._srcURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
return this._srcURLCache;
}
this._srcURLCacheKey = value;
this._baseURLCache = document._baseURLCache;
const urlRecord = document.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set src(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set src' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'src' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("src", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get frameBorder() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get frameBorder' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("frameborder");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set frameBorder(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set frameBorder' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'frameBorder' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("frameborder", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get longDesc() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get longDesc' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const impl = esValue[implSymbol];
const value = impl._reflectGetTheContentAttribute("longdesc");
if (value === null) {
return "";
}
const document = impl._ownerDocument;
if (this._longdescURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
return this._longdescURLCache;
}
this._longdescURLCacheKey = value;
this._baseURLCache = document._baseURLCache;
const urlRecord = document.encodingParseAURL(value);
if (urlRecord !== null) {
this._longdescURLCache = serializeURLwhatwg_url(urlRecord);
return this._longdescURLCache;
}
this._longdescURLCache = conversions.USVString(value);
return this._longdescURLCache;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set longDesc(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set longDesc' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["USVString"](V, {
context: "Failed to set the 'longDesc' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("longdesc", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get noResize() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get noResize' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("noresize") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set noResize(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set noResize' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'noResize' property on 'HTMLFrameElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("noresize", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("noresize");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get contentDocument() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get contentDocument' called on an object that is not a valid instance of HTMLFrameElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["contentDocument"]);
}
get contentWindow() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get contentWindow' called on an object that is not a valid instance of HTMLFrameElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["contentWindow"]);
}
get marginHeight() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get marginHeight' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("marginheight");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set marginHeight(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set marginHeight' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'marginHeight' property on 'HTMLFrameElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("marginheight", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get marginWidth() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get marginWidth' called on an object that is not a valid instance of HTMLFrameElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("marginwidth");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set marginWidth(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set marginWidth' called on an object that is not a valid instance of HTMLFrameElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'marginWidth' property on 'HTMLFrameElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("marginwidth", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLFrameElement.prototype, {
name: { enumerable: true },
scrolling: { enumerable: true },
src: { enumerable: true },
frameBorder: { enumerable: true },
longDesc: { enumerable: true },
noResize: { enumerable: true },
contentDocument: { enumerable: true },
contentWindow: { enumerable: true },
marginHeight: { enumerable: true },
marginWidth: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFrameElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLFrameElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFrameElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLFrameElement-impl.js");
+711
View File
@@ -0,0 +1,711 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLFrameSetElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLFrameSetElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLFrameSetElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLFrameSetElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get cols() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cols' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("cols");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set cols(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set cols' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'cols' property on 'HTMLFrameSetElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("cols", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get rows() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get rows' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("rows");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set rows(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set rows' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rows' property on 'HTMLFrameSetElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("rows", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get onafterprint() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onafterprint' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]);
}
set onafterprint(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onafterprint' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onafterprint' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onafterprint"] = V;
}
get onbeforeprint() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onbeforeprint' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]);
}
set onbeforeprint(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onbeforeprint' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onbeforeprint' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onbeforeprint"] = V;
}
get onbeforeunload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onbeforeunload' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]);
}
set onbeforeunload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onbeforeunload' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onbeforeunload' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onbeforeunload"] = V;
}
get onhashchange() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onhashchange' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]);
}
set onhashchange(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onhashchange' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onhashchange' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onhashchange"] = V;
}
get onlanguagechange() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onlanguagechange' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]);
}
set onlanguagechange(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onlanguagechange' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onlanguagechange' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onlanguagechange"] = V;
}
get onmessage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onmessage' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]);
}
set onmessage(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onmessage' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onmessage' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onmessage"] = V;
}
get onmessageerror() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onmessageerror' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]);
}
set onmessageerror(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onmessageerror' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onmessageerror' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onmessageerror"] = V;
}
get onoffline() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onoffline' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]);
}
set onoffline(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onoffline' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onoffline' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onoffline"] = V;
}
get ononline() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get ononline' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]);
}
set ononline(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set ononline' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'ononline' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["ononline"] = V;
}
get onpagehide() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpagehide' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]);
}
set onpagehide(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onpagehide' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpagehide' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onpagehide"] = V;
}
get onpageshow() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpageshow' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]);
}
set onpageshow(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onpageshow' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpageshow' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onpageshow"] = V;
}
get onpopstate() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onpopstate' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]);
}
set onpopstate(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onpopstate' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onpopstate' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onpopstate"] = V;
}
get onrejectionhandled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onrejectionhandled' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]);
}
set onrejectionhandled(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onrejectionhandled' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onrejectionhandled' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onrejectionhandled"] = V;
}
get onstorage() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onstorage' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]);
}
set onstorage(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onstorage' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onstorage' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onstorage"] = V;
}
get onunhandledrejection() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onunhandledrejection' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]);
}
set onunhandledrejection(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onunhandledrejection' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onunhandledrejection' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onunhandledrejection"] = V;
}
get onunload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get onunload' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]);
}
set onunload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set onunload' called on an object that is not a valid instance of HTMLFrameSetElement."
);
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(globalObject, V, {
context: "Failed to set the 'onunload' property on 'HTMLFrameSetElement': The provided value"
});
}
esValue[implSymbol]["onunload"] = V;
}
}
Object.defineProperties(HTMLFrameSetElement.prototype, {
cols: { enumerable: true },
rows: { enumerable: true },
onafterprint: { enumerable: true },
onbeforeprint: { enumerable: true },
onbeforeunload: { enumerable: true },
onhashchange: { enumerable: true },
onlanguagechange: { enumerable: true },
onmessage: { enumerable: true },
onmessageerror: { enumerable: true },
onoffline: { enumerable: true },
ononline: { enumerable: true },
onpagehide: { enumerable: true },
onpageshow: { enumerable: true },
onpopstate: { enumerable: true },
onrejectionhandled: { enumerable: true },
onstorage: { enumerable: true },
onunhandledrejection: { enumerable: true },
onunload: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFrameSetElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLFrameSetElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLFrameSetElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLFrameSetElement-impl.js");
+323
View File
@@ -0,0 +1,323 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLHRElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLHRElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLHRElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLHRElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get align() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get align' called on an object that is not a valid instance of HTMLHRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set align(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set align' called on an object that is not a valid instance of HTMLHRElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'align' property on 'HTMLHRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get color() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get color' called on an object that is not a valid instance of HTMLHRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("color");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set color(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set color' called on an object that is not a valid instance of HTMLHRElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'color' property on 'HTMLHRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("color", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get noShade() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get noShade' called on an object that is not a valid instance of HTMLHRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]._reflectGetTheContentAttribute("noshade") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set noShade(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set noShade' called on an object that is not a valid instance of HTMLHRElement."
);
}
V = conversions["boolean"](V, {
context: "Failed to set the 'noShade' property on 'HTMLHRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol]._reflectSetTheContentAttribute("noshade", "");
} else {
esValue[implSymbol]._reflectDeleteTheContentAttribute("noshade");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get size() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get size' called on an object that is not a valid instance of HTMLHRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("size");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set size(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set size' called on an object that is not a valid instance of HTMLHRElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'size' property on 'HTMLHRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("size", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get width' called on an object that is not a valid instance of HTMLHRElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("width");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set width(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set width' called on an object that is not a valid instance of HTMLHRElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'width' property on 'HTMLHRElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("width", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLHRElement.prototype, {
align: { enumerable: true },
color: { enumerable: true },
noShade: { enumerable: true },
size: { enumerable: true },
width: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLHRElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLHRElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLHRElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLHRElement-impl.js");
+111
View File
@@ -0,0 +1,111 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLHeadElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLHeadElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLHeadElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLHeadElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
}
Object.defineProperties(HTMLHeadElement.prototype, {
[Symbol.toStringTag]: { value: "HTMLHeadElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLHeadElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLHeadElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLHeadElement-impl.js");
+156
View File
@@ -0,0 +1,156 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLHeadingElement";
exports.is = value => {
return utils.isObject(value) && Object.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 'HTMLHeadingElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLHeadingElement"].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) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLHeadingElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get align() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get align' called on an object that is not a valid instance of HTMLHeadingElement."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set align(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set align' called on an object that is not a valid instance of HTMLHeadingElement."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'align' property on 'HTMLHeadingElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLHeadingElement.prototype, {
align: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLHeadingElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLHeadingElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLHeadingElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLHeadingElement-impl.js");

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