This commit is contained in:
Your Name
2026-07-23 17:56:25 +08:00
parent a05dae8412
commit 4970d8f8d3
4262 changed files with 735221 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;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+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");
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSGroupingRule = require("./CSSGroupingRule.js");
const interfaceName = "CSSConditionRule";
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 'CSSConditionRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSConditionRule"].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) => {
CSSGroupingRule._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 CSSConditionRule extends globalObject.CSSGroupingRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get conditionText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get conditionText' called on an object that is not a valid instance of CSSConditionRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["conditionText"]);
}
}
Object.defineProperties(CSSConditionRule.prototype, {
conditionText: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSConditionRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSConditionRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSConditionRule
});
};
const Impl = require("../../jsdom/living/css/CSSConditionRule-impl.js");
+135
View File
@@ -0,0 +1,135 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSConditionRule = require("./CSSConditionRule.js");
const interfaceName = "CSSContainerRule";
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 'CSSContainerRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSContainerRule"].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) => {
CSSConditionRule._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 CSSContainerRule extends globalObject.CSSConditionRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get containerName() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get containerName' called on an object that is not a valid instance of CSSContainerRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["containerName"]);
}
get containerQuery() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get containerQuery' called on an object that is not a valid instance of CSSContainerRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["containerQuery"]);
}
}
Object.defineProperties(CSSContainerRule.prototype, {
containerName: { enumerable: true },
containerQuery: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSContainerRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSContainerRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSContainerRule
});
};
const Impl = require("../../jsdom/living/css/CSSContainerRule-impl.js");
+439
View File
@@ -0,0 +1,439 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSCounterStyleRule";
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 'CSSCounterStyleRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSCounterStyleRule"].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) => {
CSSRule._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 CSSCounterStyleRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
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 CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["name"]);
}
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 CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["name"] = V;
}
get system() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get system' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["system"]);
}
set system(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set system' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'system' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["system"] = V;
}
get symbols() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get symbols' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["symbols"]);
}
set symbols(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set symbols' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'symbols' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["symbols"] = V;
}
get additiveSymbols() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get additiveSymbols' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["additiveSymbols"]);
}
set additiveSymbols(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set additiveSymbols' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'additiveSymbols' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["additiveSymbols"] = V;
}
get negative() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get negative' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["negative"]);
}
set negative(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set negative' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'negative' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["negative"] = V;
}
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 CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["prefix"]);
}
set prefix(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set prefix' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'prefix' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["prefix"] = V;
}
get suffix() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get suffix' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["suffix"]);
}
set suffix(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set suffix' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'suffix' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["suffix"] = V;
}
get range() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get range' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["range"]);
}
set range(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set range' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'range' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["range"] = V;
}
get pad() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get pad' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["pad"]);
}
set pad(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set pad' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'pad' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["pad"] = V;
}
get speakAs() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get speakAs' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["speakAs"]);
}
set speakAs(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set speakAs' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'speakAs' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["speakAs"] = V;
}
get fallback() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get fallback' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["fallback"]);
}
set fallback(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set fallback' called on an object that is not a valid instance of CSSCounterStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'fallback' property on 'CSSCounterStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["fallback"] = V;
}
}
Object.defineProperties(CSSCounterStyleRule.prototype, {
name: { enumerable: true },
system: { enumerable: true },
symbols: { enumerable: true },
additiveSymbols: { enumerable: true },
negative: { enumerable: true },
prefix: { enumerable: true },
suffix: { enumerable: true },
range: { enumerable: true },
pad: { enumerable: true },
speakAs: { enumerable: true },
fallback: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSCounterStyleRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSCounterStyleRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSCounterStyleRule
});
};
const Impl = require("../../jsdom/living/css/CSSCounterStyleRule-impl.js");
+140
View File
@@ -0,0 +1,140 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSFontFaceRule";
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 'CSSFontFaceRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSFontFaceRule"].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) => {
CSSRule._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 CSSFontFaceRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get style() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get style' called on an object that is not a valid instance of CSSFontFaceRule."
);
}
return utils.getSameObject(this, "style", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["style"]);
});
}
set style(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set style' called on an object that is not a valid instance of CSSFontFaceRule."
);
}
const Q = esValue["style"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'style' is not an object");
}
Reflect.set(Q, "cssText", V);
}
}
Object.defineProperties(CSSFontFaceRule.prototype, {
style: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSFontFaceRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSFontFaceRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSFontFaceRule
});
};
const Impl = require("../../jsdom/living/css/CSSFontFaceRule-impl.js");
+188
View File
@@ -0,0 +1,188 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSGroupingRule";
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 'CSSGroupingRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSGroupingRule"].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) => {
CSSRule._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 CSSGroupingRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
insertRule(rule) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'insertRule' called on an object that is not a valid instance of CSSGroupingRule."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'insertRule' on 'CSSGroupingRule': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'insertRule' on 'CSSGroupingRule': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'insertRule' on 'CSSGroupingRule': parameter 2",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
return esValue[implSymbol].insertRule(...args);
}
deleteRule(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'deleteRule' called on an object that is not a valid instance of CSSGroupingRule."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'deleteRule' on 'CSSGroupingRule': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteRule' on 'CSSGroupingRule': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].deleteRule(...args);
}
get cssRules() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cssRules' called on an object that is not a valid instance of CSSGroupingRule."
);
}
return utils.getSameObject(this, "cssRules", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["cssRules"]);
});
}
}
Object.defineProperties(CSSGroupingRule.prototype, {
insertRule: { enumerable: true },
deleteRule: { enumerable: true },
cssRules: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSGroupingRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSGroupingRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSGroupingRule
});
};
const Impl = require("../../jsdom/living/css/CSSGroupingRule-impl.js");
+194
View File
@@ -0,0 +1,194 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSImportRule";
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 'CSSImportRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSImportRule"].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) => {
CSSRule._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 CSSImportRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
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 CSSImportRule."
);
}
return esValue[implSymbol]["href"];
}
get media() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get media' called on an object that is not a valid instance of CSSImportRule."
);
}
return utils.getSameObject(this, "media", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["media"]);
});
}
set media(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set media' called on an object that is not a valid instance of CSSImportRule."
);
}
const Q = esValue["media"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'media' is not an object");
}
Reflect.set(Q, "mediaText", V);
}
get styleSheet() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get styleSheet' called on an object that is not a valid instance of CSSImportRule."
);
}
return utils.getSameObject(this, "styleSheet", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["styleSheet"]);
});
}
get layerName() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get layerName' called on an object that is not a valid instance of CSSImportRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["layerName"]);
}
get supportsText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get supportsText' called on an object that is not a valid instance of CSSImportRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["supportsText"]);
}
}
Object.defineProperties(CSSImportRule.prototype, {
href: { enumerable: true },
media: { enumerable: true },
styleSheet: { enumerable: true },
layerName: { enumerable: true },
supportsText: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSImportRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSImportRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSImportRule
});
};
const Impl = require("../../jsdom/living/css/CSSImportRule-impl.js");
+170
View File
@@ -0,0 +1,170 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSKeyframeRule";
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 'CSSKeyframeRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSKeyframeRule"].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) => {
CSSRule._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 CSSKeyframeRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get keyText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get keyText' called on an object that is not a valid instance of CSSKeyframeRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["keyText"]);
}
set keyText(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set keyText' called on an object that is not a valid instance of CSSKeyframeRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'keyText' property on 'CSSKeyframeRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["keyText"] = V;
}
get style() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get style' called on an object that is not a valid instance of CSSKeyframeRule."
);
}
return utils.getSameObject(this, "style", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["style"]);
});
}
set style(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set style' called on an object that is not a valid instance of CSSKeyframeRule."
);
}
const Q = esValue["style"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'style' is not an object");
}
Reflect.set(Q, "cssText", V);
}
}
Object.defineProperties(CSSKeyframeRule.prototype, {
keyText: { enumerable: true },
style: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSKeyframeRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSKeyframeRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSKeyframeRule
});
};
const Impl = require("../../jsdom/living/css/CSSKeyframeRule-impl.js");
+404
View File
@@ -0,0 +1,404 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSKeyframesRule";
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 'CSSKeyframesRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSKeyframesRule"].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) => {
CSSRule._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 CSSKeyframesRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
appendRule(rule) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'appendRule' called on an object that is not a valid instance of CSSKeyframesRule."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'appendRule' on 'CSSKeyframesRule': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'appendRule' on 'CSSKeyframesRule': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].appendRule(...args);
}
deleteRule(select) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'deleteRule' called on an object that is not a valid instance of CSSKeyframesRule."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'deleteRule' on 'CSSKeyframesRule': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'deleteRule' on 'CSSKeyframesRule': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].deleteRule(...args);
}
findRule(select) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'findRule' called on an object that is not a valid instance of CSSKeyframesRule."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'findRule' on 'CSSKeyframesRule': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'findRule' on 'CSSKeyframesRule': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].findRule(...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 CSSKeyframesRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["name"]);
}
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 CSSKeyframesRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'CSSKeyframesRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["name"] = V;
}
get cssRules() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cssRules' called on an object that is not a valid instance of CSSKeyframesRule."
);
}
return utils.getSameObject(this, "cssRules", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["cssRules"]);
});
}
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 CSSKeyframesRule."
);
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(CSSKeyframesRule.prototype, {
appendRule: { enumerable: true },
deleteRule: { enumerable: true },
findRule: { enumerable: true },
name: { enumerable: true },
cssRules: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSKeyframesRule", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = CSSKeyframesRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSKeyframesRule
});
};
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;
if (target[implSymbol][utils.supportsPropertyIndex](index)) {
const indexedValue = target[implSymbol][utils.indexedGet](index);
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;
if (target[implSymbol][utils.supportsPropertyIndex](index)) {
const indexedValue = target[implSymbol][utils.indexedGet](index);
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.supportsPropertyIndex](index);
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/css/CSSKeyframesRule-impl.js");
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSGroupingRule = require("./CSSGroupingRule.js");
const interfaceName = "CSSLayerBlockRule";
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 'CSSLayerBlockRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSLayerBlockRule"].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) => {
CSSGroupingRule._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 CSSLayerBlockRule extends globalObject.CSSGroupingRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
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 CSSLayerBlockRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["name"]);
}
}
Object.defineProperties(CSSLayerBlockRule.prototype, {
name: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSLayerBlockRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSLayerBlockRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSLayerBlockRule
});
};
const Impl = require("../../jsdom/living/css/CSSLayerBlockRule-impl.js");
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSLayerStatementRule";
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 'CSSLayerStatementRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSLayerStatementRule"].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) => {
CSSRule._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 CSSLayerStatementRule extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get nameList() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get nameList' called on an object that is not a valid instance of CSSLayerStatementRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["nameList"]);
}
}
Object.defineProperties(CSSLayerStatementRule.prototype, {
nameList: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSLayerStatementRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSLayerStatementRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSLayerStatementRule
});
};
const Impl = require("../../jsdom/living/css/CSSLayerStatementRule-impl.js");
+153
View File
@@ -0,0 +1,153 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSConditionRule = require("./CSSConditionRule.js");
const interfaceName = "CSSMediaRule";
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 'CSSMediaRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSMediaRule"].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) => {
CSSConditionRule._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 CSSMediaRule extends globalObject.CSSConditionRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get media() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get media' called on an object that is not a valid instance of CSSMediaRule."
);
}
return utils.getSameObject(this, "media", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["media"]);
});
}
set media(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set media' called on an object that is not a valid instance of CSSMediaRule."
);
}
const Q = esValue["media"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'media' is not an object");
}
Reflect.set(Q, "mediaText", V);
}
get matches() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get matches' called on an object that is not a valid instance of CSSMediaRule."
);
}
return esValue[implSymbol]["matches"];
}
}
Object.defineProperties(CSSMediaRule.prototype, {
media: { enumerable: true },
matches: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSMediaRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSMediaRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSMediaRule
});
};
const Impl = require("../../jsdom/living/css/CSSMediaRule-impl.js");
+135
View File
@@ -0,0 +1,135 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSNamespaceRule";
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 'CSSNamespaceRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSNamespaceRule"].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) => {
CSSRule._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 CSSNamespaceRule extends globalObject.CSSRule {
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 CSSNamespaceRule."
);
}
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 CSSNamespaceRule."
);
}
return esValue[implSymbol]["prefix"];
}
}
Object.defineProperties(CSSNamespaceRule.prototype, {
namespaceURI: { enumerable: true },
prefix: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSNamespaceRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSNamespaceRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSNamespaceRule
});
};
const Impl = require("../../jsdom/living/css/CSSNamespaceRule-impl.js");
+140
View File
@@ -0,0 +1,140 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSRule = require("./CSSRule.js");
const interfaceName = "CSSNestedDeclarations";
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 'CSSNestedDeclarations'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSNestedDeclarations"].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) => {
CSSRule._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 CSSNestedDeclarations extends globalObject.CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get style() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get style' called on an object that is not a valid instance of CSSNestedDeclarations."
);
}
return utils.getSameObject(this, "style", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["style"]);
});
}
set style(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set style' called on an object that is not a valid instance of CSSNestedDeclarations."
);
}
const Q = esValue["style"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'style' is not an object");
}
Reflect.set(Q, "cssText", V);
}
}
Object.defineProperties(CSSNestedDeclarations.prototype, {
style: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSNestedDeclarations", configurable: true }
});
ctorRegistry[interfaceName] = CSSNestedDeclarations;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSNestedDeclarations
});
};
const Impl = require("../../jsdom/living/css/CSSNestedDeclarations-impl.js");
+170
View File
@@ -0,0 +1,170 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSGroupingRule = require("./CSSGroupingRule.js");
const interfaceName = "CSSPageRule";
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 'CSSPageRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSPageRule"].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) => {
CSSGroupingRule._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 CSSPageRule extends globalObject.CSSGroupingRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get selectorText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get selectorText' called on an object that is not a valid instance of CSSPageRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["selectorText"]);
}
set selectorText(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set selectorText' called on an object that is not a valid instance of CSSPageRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'selectorText' property on 'CSSPageRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["selectorText"] = V;
}
get style() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get style' called on an object that is not a valid instance of CSSPageRule."
);
}
return utils.getSameObject(this, "style", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["style"]);
});
}
set style(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set style' called on an object that is not a valid instance of CSSPageRule."
);
}
const Q = esValue["style"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'style' is not an object");
}
Reflect.set(Q, "cssText", V);
}
}
Object.defineProperties(CSSPageRule.prototype, {
selectorText: { enumerable: true },
style: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSPageRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSPageRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSPageRule
});
};
const Impl = require("../../jsdom/living/css/CSSPageRule-impl.js");
+197
View File
@@ -0,0 +1,197 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CSSRule";
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 'CSSRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSRule"].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 CSSRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get cssText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get cssText' called on an object that is not a valid instance of CSSRule.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["cssText"]);
}
set cssText(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set cssText' called on an object that is not a valid instance of CSSRule.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'cssText' property on 'CSSRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["cssText"] = V;
}
get parentRule() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get parentRule' called on an object that is not a valid instance of CSSRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["parentRule"]);
}
get parentStyleSheet() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get parentStyleSheet' called on an object that is not a valid instance of CSSRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["parentStyleSheet"]);
}
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 CSSRule.");
}
return esValue[implSymbol]["type"];
}
}
Object.defineProperties(CSSRule.prototype, {
cssText: { enumerable: true },
parentRule: { enumerable: true },
parentStyleSheet: { enumerable: true },
type: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSRule", configurable: true },
STYLE_RULE: { value: 1, enumerable: true },
CHARSET_RULE: { value: 2, enumerable: true },
IMPORT_RULE: { value: 3, enumerable: true },
MEDIA_RULE: { value: 4, enumerable: true },
FONT_FACE_RULE: { value: 5, enumerable: true },
PAGE_RULE: { value: 6, enumerable: true },
MARGIN_RULE: { value: 9, enumerable: true },
NAMESPACE_RULE: { value: 10, enumerable: true },
KEYFRAMES_RULE: { value: 7, enumerable: true },
KEYFRAME_RULE: { value: 8, enumerable: true },
COUNTER_STYLE_RULE: { value: 11, enumerable: true },
SUPPORTS_RULE: { value: 12, enumerable: true },
FONT_FEATURE_VALUES_RULE: { value: 14, enumerable: true }
});
Object.defineProperties(CSSRule, {
STYLE_RULE: { value: 1, enumerable: true },
CHARSET_RULE: { value: 2, enumerable: true },
IMPORT_RULE: { value: 3, enumerable: true },
MEDIA_RULE: { value: 4, enumerable: true },
FONT_FACE_RULE: { value: 5, enumerable: true },
PAGE_RULE: { value: 6, enumerable: true },
MARGIN_RULE: { value: 9, enumerable: true },
NAMESPACE_RULE: { value: 10, enumerable: true },
KEYFRAMES_RULE: { value: 7, enumerable: true },
KEYFRAME_RULE: { value: 8, enumerable: true },
COUNTER_STYLE_RULE: { value: 11, enumerable: true },
SUPPORTS_RULE: { value: 12, enumerable: true },
FONT_FEATURE_VALUES_RULE: { value: 14, enumerable: true }
});
ctorRegistry[interfaceName] = CSSRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSRule
});
};
const Impl = require("../../jsdom/living/css/CSSRule-impl.js");
+300
View File
@@ -0,0 +1,300 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CSSRuleList";
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 'CSSRuleList'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSRuleList"].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 CSSRuleList {
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 CSSRuleList.");
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'item' on 'CSSRuleList': 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 'CSSRuleList': 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 CSSRuleList."
);
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(CSSRuleList.prototype, {
item: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSRuleList", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = CSSRuleList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSRuleList
});
};
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/css/CSSRuleList-impl.js");
+133
View File
@@ -0,0 +1,133 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSGroupingRule = require("./CSSGroupingRule.js");
const interfaceName = "CSSScopeRule";
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 'CSSScopeRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSScopeRule"].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) => {
CSSGroupingRule._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 CSSScopeRule extends globalObject.CSSGroupingRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get start() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get start' called on an object that is not a valid instance of CSSScopeRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["start"]);
}
get end() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get end' called on an object that is not a valid instance of CSSScopeRule.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["end"]);
}
}
Object.defineProperties(CSSScopeRule.prototype, {
start: { enumerable: true },
end: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSScopeRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSScopeRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSScopeRule
});
};
const Impl = require("../../jsdom/living/css/CSSScopeRule-impl.js");
+497
View File
@@ -0,0 +1,497 @@
"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 = "CSSStyleDeclaration";
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 'CSSStyleDeclaration'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSStyleDeclaration"].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 CSSStyleDeclaration {
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 CSSStyleDeclaration."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'item' on 'CSSStyleDeclaration': 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 'CSSStyleDeclaration': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].item(...args));
}
getPropertyValue(property) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getPropertyValue' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'getPropertyValue' on 'CSSStyleDeclaration': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'getPropertyValue' on 'CSSStyleDeclaration': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getPropertyValue(...args));
}
getPropertyPriority(property) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'getPropertyPriority' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'getPropertyPriority' on 'CSSStyleDeclaration': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'getPropertyPriority' on 'CSSStyleDeclaration': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getPropertyPriority(...args));
}
setProperty(property, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'setProperty' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
if (arguments.length < 2) {
throw new globalObject.TypeError(
`Failed to execute 'setProperty' on 'CSSStyleDeclaration': 2 arguments required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'setProperty' on 'CSSStyleDeclaration': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'setProperty' on 'CSSStyleDeclaration': parameter 2",
globals: globalObject,
treatNullAsEmptyString: true
});
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'setProperty' on 'CSSStyleDeclaration': parameter 3",
globals: globalObject,
treatNullAsEmptyString: true
});
} else {
curArg = "";
}
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].setProperty(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
removeProperty(property) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'removeProperty' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'removeProperty' on 'CSSStyleDeclaration': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'removeProperty' on 'CSSStyleDeclaration': parameter 1",
globals: globalObject
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return utils.tryWrapperForImpl(esValue[implSymbol].removeProperty(...args));
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get cssText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cssText' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return utils.tryWrapperForImpl(esValue[implSymbol]["cssText"]);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set cssText(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set cssText' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'cssText' property on 'CSSStyleDeclaration': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["cssText"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
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 CSSStyleDeclaration."
);
}
return esValue[implSymbol]["length"];
}
get parentRule() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get parentRule' called on an object that is not a valid instance of CSSStyleDeclaration."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["parentRule"]);
}
}
Object.defineProperties(CSSStyleDeclaration.prototype, {
item: { enumerable: true },
getPropertyValue: { enumerable: true },
getPropertyPriority: { enumerable: true },
setProperty: { enumerable: true },
removeProperty: { enumerable: true },
cssText: { enumerable: true },
length: { enumerable: true },
parentRule: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSStyleDeclaration", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = CSSStyleDeclaration;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSStyleDeclaration
});
};
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;
if (target[implSymbol][utils.supportsPropertyIndex](index)) {
const indexedValue = target[implSymbol].item(index);
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return 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;
if (target[implSymbol][utils.supportsPropertyIndex](index)) {
const indexedValue = target[implSymbol].item(index);
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
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.supportsPropertyIndex](index);
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../../jsdom/living/css/CSSStyleDeclaration-impl.js");
File diff suppressed because it is too large Load Diff
+170
View File
@@ -0,0 +1,170 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSGroupingRule = require("./CSSGroupingRule.js");
const interfaceName = "CSSStyleRule";
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 'CSSStyleRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSStyleRule"].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) => {
CSSGroupingRule._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 CSSStyleRule extends globalObject.CSSGroupingRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get selectorText() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get selectorText' called on an object that is not a valid instance of CSSStyleRule."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["selectorText"]);
}
set selectorText(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set selectorText' called on an object that is not a valid instance of CSSStyleRule."
);
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'selectorText' property on 'CSSStyleRule': The provided value",
globals: globalObject
});
esValue[implSymbol]["selectorText"] = V;
}
get style() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get style' called on an object that is not a valid instance of CSSStyleRule."
);
}
return utils.getSameObject(this, "style", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["style"]);
});
}
set style(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set style' called on an object that is not a valid instance of CSSStyleRule."
);
}
const Q = esValue["style"];
if (!utils.isObject(Q)) {
throw new globalObject.TypeError("Property 'style' is not an object");
}
Reflect.set(Q, "cssText", V);
}
}
Object.defineProperties(CSSStyleRule.prototype, {
selectorText: { enumerable: true },
style: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSStyleRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSStyleRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSStyleRule
});
};
const Impl = require("../../jsdom/living/css/CSSStyleRule-impl.js");
+351
View File
@@ -0,0 +1,351 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CSSStyleSheetInit = require("./CSSStyleSheetInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const StyleSheet = require("./StyleSheet.js");
const interfaceName = "CSSStyleSheet";
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 'CSSStyleSheet'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSStyleSheet"].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) => {
StyleSheet._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 CSSStyleSheet extends globalObject.StyleSheet {
constructor() {
const args = [];
{
let curArg = arguments[0];
curArg = CSSStyleSheetInit.convert(globalObject, curArg, {
context: "Failed to construct 'CSSStyleSheet': parameter 1"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
insertRule(rule) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'insertRule' called on an object that is not a valid instance of CSSStyleSheet."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'insertRule' on 'CSSStyleSheet': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'insertRule' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'insertRule' on 'CSSStyleSheet': parameter 2",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
return esValue[implSymbol].insertRule(...args);
}
deleteRule(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'deleteRule' called on an object that is not a valid instance of CSSStyleSheet."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'deleteRule' on 'CSSStyleSheet': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteRule' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].deleteRule(...args);
}
replace(text) {
try {
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 CSSStyleSheet."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'replace' on 'CSSStyleSheet': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'replace' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].replace(...args));
} catch (e) {
return globalObject.Promise.reject(e);
}
}
replaceSync(text) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'replaceSync' called on an object that is not a valid instance of CSSStyleSheet."
);
}
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'replaceSync' on 'CSSStyleSheet': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'replaceSync' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
args.push(curArg);
}
return esValue[implSymbol].replaceSync(...args);
}
addRule() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'addRule' called on an object that is not a valid instance of CSSStyleSheet."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'addRule' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
} else {
curArg = "undefined";
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'addRule' on 'CSSStyleSheet': parameter 2",
globals: globalObject
});
} else {
curArg = "undefined";
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'addRule' on 'CSSStyleSheet': parameter 3",
globals: globalObject
});
}
args.push(curArg);
}
return esValue[implSymbol].addRule(...args);
}
removeRule() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'removeRule' called on an object that is not a valid instance of CSSStyleSheet."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'removeRule' on 'CSSStyleSheet': parameter 1",
globals: globalObject
});
} else {
curArg = 0;
}
args.push(curArg);
}
return esValue[implSymbol].removeRule(...args);
}
get ownerRule() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get ownerRule' called on an object that is not a valid instance of CSSStyleSheet."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ownerRule"]);
}
get cssRules() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get cssRules' called on an object that is not a valid instance of CSSStyleSheet."
);
}
return utils.getSameObject(this, "cssRules", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["cssRules"]);
});
}
get rules() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get rules' called on an object that is not a valid instance of CSSStyleSheet."
);
}
return utils.getSameObject(this, "rules", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["rules"]);
});
}
}
Object.defineProperties(CSSStyleSheet.prototype, {
insertRule: { enumerable: true },
deleteRule: { enumerable: true },
replace: { enumerable: true },
replaceSync: { enumerable: true },
addRule: { enumerable: true },
removeRule: { enumerable: true },
ownerRule: { enumerable: true },
cssRules: { enumerable: true },
rules: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSStyleSheet", configurable: true }
});
ctorRegistry[interfaceName] = CSSStyleSheet;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSStyleSheet
});
};
const Impl = require("../../jsdom/living/css/CSSStyleSheet-impl.js");
+66
View File
@@ -0,0 +1,66 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const MediaList = require("./MediaList.js");
exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
{
const key = "baseURL";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, {
context: context + " has member 'baseURL' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = "";
}
}
{
const key = "disabled";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, {
context: context + " has member 'disabled' that",
globals: globalObject
});
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "media";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (MediaList.is(value)) {
value = utils.implForWrapper(value);
} else {
value = conversions["DOMString"](value, {
context: context + " has member 'media' 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;
};
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CSSConditionRule = require("./CSSConditionRule.js");
const interfaceName = "CSSSupportsRule";
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 'CSSSupportsRule'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["CSSSupportsRule"].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) => {
CSSConditionRule._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 CSSSupportsRule extends globalObject.CSSConditionRule {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get matches() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get matches' called on an object that is not a valid instance of CSSSupportsRule."
);
}
return esValue[implSymbol]["matches"];
}
}
Object.defineProperties(CSSSupportsRule.prototype, {
matches: { enumerable: true },
[Symbol.toStringTag]: { value: "CSSSupportsRule", configurable: true }
});
ctorRegistry[interfaceName] = CSSSupportsRule;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CSSSupportsRule
});
};
const Impl = require("../../jsdom/living/css/CSSSupportsRule-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

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