feat(lib-core): biblioteca atomica @pulse-libs/core v1.0.0-beta.1
Esta commit conteudo a estrutura atomica completa:
- types: Result<T,E>, AsyncState<T>, Paginated<T>, SortConfig<T>
- utils: date, str, num, cn, debounce, throttle, storage, arr, obj
- validators: Zod schemas — email, password, uuid, url, phone, CPF/CNPJ, sanitizedStr, safeParse
- hooks: useToggle, useAsync, useDebounce, useLocalStorage, useMedia, useInterval, useOnClickOutside, useClipboard, useFetch
- components: Button, Input, Alert, Card, Spinner (atomic design pattern)
- build: tsup v8 ESM+CJS + DTS + sourcemaps — 0 erros
- tests: 57 testes 100% usuarios
- docker: multi-stage Dockerfile (node 20-alpine)
- config: vitest, tsup, tsconfig strict, .npmignore
Filosofia atomica:/utils ← /types ← /validators ← /hooks ← /components
Build: npm run build | Test: npm test | Publish: npm publish
🤖 Generated with Pulse (openclaw + nova-self-improver)
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2010 Elijah Insua
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
+555
@@ -0,0 +1,555 @@
|
||||
<h1 align="center">
|
||||
<img width="100" height="100" src="logo.svg" alt=""><br>
|
||||
jsdom
|
||||
</h1>
|
||||
|
||||
jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG [DOM](https://dom.spec.whatwg.org/) and [HTML](https://html.spec.whatwg.org/multipage/) Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications.
|
||||
|
||||
The latest versions of jsdom require newer Node.js versions; see the `package.json` `"engines"` field for details.
|
||||
|
||||
## Basic usage
|
||||
|
||||
```js
|
||||
const jsdom = require("jsdom");
|
||||
const { JSDOM } = jsdom;
|
||||
```
|
||||
|
||||
To use jsdom, you will primarily use the `JSDOM` constructor, which is a named export of the jsdom main module. Pass the constructor a string. You will get back a `JSDOM` object, which has a number of useful properties, notably `window`:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
|
||||
console.log(dom.window.document.querySelector("p").textContent); // "Hello world"
|
||||
```
|
||||
|
||||
(Note that jsdom will parse the HTML you pass it just like a browser does, including implied `<html>`, `<head>`, and `<body>` tags.)
|
||||
|
||||
The resulting object is an instance of the `JSDOM` class, which contains a number of useful properties and methods besides `window`. In general, it can be used to act on the jsdom from the "outside," doing things that are not possible with the normal DOM APIs. For simple cases, where you don't need any of this functionality, we recommend a coding pattern like
|
||||
|
||||
```js
|
||||
const { window } = new JSDOM(`...`);
|
||||
// or even
|
||||
const { document } = (new JSDOM(`...`)).window;
|
||||
```
|
||||
|
||||
Full documentation on everything you can do with the `JSDOM` class is below, in the section "`JSDOM` Object API".
|
||||
|
||||
## Customizing jsdom
|
||||
|
||||
The `JSDOM` constructor accepts a second parameter which can be used to customize your jsdom in the following ways.
|
||||
|
||||
### Simple options
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(``, {
|
||||
url: "https://example.org/",
|
||||
referrer: "https://example.com/",
|
||||
contentType: "text/html",
|
||||
includeNodeLocations: true,
|
||||
storageQuota: 10000000
|
||||
});
|
||||
```
|
||||
|
||||
- `url` sets the value returned by `window.location`, `document.URL`, and `document.documentURI`, and affects things like resolution of relative URLs within the document and the same-origin restrictions and referrer used while fetching subresources. It defaults to `"about:blank"`.
|
||||
- `referrer` just affects the value read from `document.referrer`. It defaults to no referrer (which reflects as the empty string).
|
||||
- `contentType` affects the value read from `document.contentType`, as well as how the document is parsed: as HTML or as XML. Values that are not a [HTML MIME type](https://mimesniff.spec.whatwg.org/#html-mime-type) or an [XML MIME type](https://mimesniff.spec.whatwg.org/#xml-mime-type) will throw. It defaults to `"text/html"`. If a `charset` parameter is present, it can affect [binary data processing](#encoding-sniffing).
|
||||
- `includeNodeLocations` preserves the location info produced by the HTML parser, allowing you to retrieve it with the `nodeLocation()` method (described below). It also ensures that line numbers reported in exception stack traces for code running inside `<script>` elements are correct. It defaults to `false` to give the best performance, and cannot be used with an XML content type since our XML parser does not support location info.
|
||||
- `storageQuota` is the maximum size in code units for the separate storage areas used by `localStorage` and `sessionStorage`. Attempts to store data larger than this limit will cause a `DOMException` to be thrown. By default, it is set to 5,000,000 code units per origin, as inspired by the HTML specification.
|
||||
|
||||
Note that both `url` and `referrer` are canonicalized before they're used, so e.g. if you pass in `"https:example.com"`, jsdom will interpret that as if you had given `"https://example.com/"`. If you pass an unparseable URL, the call will throw. (URLs are parsed and serialized according to the [URL Standard](https://url.spec.whatwg.org/).)
|
||||
|
||||
### Executing scripts
|
||||
|
||||
jsdom's most powerful ability is that it can execute scripts inside the jsdom. These scripts can modify the content of the page and access all the web platform APIs jsdom implements.
|
||||
|
||||
However, this is also highly dangerous when dealing with untrusted content. The jsdom sandbox is not foolproof, and code running inside the DOM's `<script>`s can, if it tries hard enough, get access to the Node.js environment, and thus to your machine. As such, the ability to execute scripts embedded in the HTML is disabled by default:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<body>
|
||||
<div id="content"></div>
|
||||
<script>document.getElementById("content").append(document.createElement("hr"));</script>
|
||||
</body>`);
|
||||
|
||||
// The script will not be executed, by default:
|
||||
console.log(dom.window.document.getElementById("content").children.length); // 0
|
||||
```
|
||||
|
||||
To enable executing scripts inside the page, you can use the `runScripts: "dangerously"` option:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<body>
|
||||
<div id="content"></div>
|
||||
<script>document.getElementById("content").append(document.createElement("hr"));</script>
|
||||
</body>`, { runScripts: "dangerously" });
|
||||
|
||||
// The script will be executed and modify the DOM:
|
||||
console.log(dom.window.document.getElementById("content").children.length); // 1
|
||||
```
|
||||
|
||||
Again we emphasize to only use this when feeding jsdom code you know is safe. If you use it on arbitrary user-supplied code, or code from the Internet, you are effectively running untrusted Node.js code, and your machine could be compromised.
|
||||
|
||||
If you want to execute _external_ scripts, included via `<script src="">`, you'll also need to ensure that they load them. To do this, add the option `resources: "usable"` [as described below](#loading-subresources). (You'll likely also want to set the `url` option, for the reasons discussed there.)
|
||||
|
||||
Event handler attributes, like `<div onclick="">`, are also governed by this setting; they will not function unless `runScripts` is set to `"dangerously"`. (However, event handler _properties_, like `div.onclick = ...`, will function regardless of `runScripts`.) Note that this guarantee covers the web content being processed by jsdom. It does not cover scenarios where the host Node.js environment itself has been compromised (e.g. through prototype pollution). See the [security policy](https://github.com/jsdom/.github/blob/master/SECURITY.md) for more details.
|
||||
|
||||
If you are simply trying to execute script "from the outside", instead of letting `<script>` elements and event handlers attributes run "from the inside", you can use the `runScripts: "outside-only"` option, which enables fresh copies of all the JavaScript spec-provided globals to be installed on `window`. This includes things like `window.Array`, `window.Promise`, etc. It also, notably, includes `window.eval`, which allows running scripts, but with the jsdom `window` as the global:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<body>
|
||||
<div id="content"></div>
|
||||
<script>document.getElementById("content").append(document.createElement("hr"));</script>
|
||||
</body>`, { runScripts: "outside-only" });
|
||||
|
||||
// run a script outside of JSDOM:
|
||||
dom.window.eval('document.getElementById("content").append(document.createElement("p"));');
|
||||
|
||||
console.log(dom.window.document.getElementById("content").children.length); // 1
|
||||
console.log(dom.window.document.getElementsByTagName("hr").length); // 0
|
||||
console.log(dom.window.document.getElementsByTagName("p").length); // 1
|
||||
```
|
||||
|
||||
This is turned off by default for performance reasons, but is safe to enable.
|
||||
|
||||
Note that in the default configuration, without setting `runScripts`, the values of `window.Array`, `window.eval`, etc. will be the same as those provided by the outer Node.js environment. That is, `window.eval === eval` will hold, so `window.eval` will not run scripts in a useful way.
|
||||
|
||||
We strongly advise against trying to "execute scripts" by mashing together the jsdom and Node global environments (e.g. by doing `global.window = dom.window`), and then executing scripts or test code inside the Node global environment. Instead, you should treat jsdom like you would a browser, and run all scripts and tests that need access to a DOM inside the jsdom environment, using `window.eval` or `runScripts: "dangerously"`. This might require, for example, creating a browserify bundle to execute as a `<script>` element—just like you would in a browser.
|
||||
|
||||
Finally, for advanced use cases you can use the `dom.getInternalVMContext()` method, documented below.
|
||||
|
||||
### Pretending to be a visual browser
|
||||
|
||||
jsdom does not have the capability to render visual content, and will act like a headless browser by default. It provides hints to web pages through APIs such as `document.hidden` that their content is not visible.
|
||||
|
||||
When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying content. It does this by:
|
||||
|
||||
- Changing `document.hidden` to return `false` instead of `true`
|
||||
- Changing `document.visibilityState` to return `"visible"` instead of `"prerender"`
|
||||
- Enabling `window.requestAnimationFrame()` and `window.cancelAnimationFrame()` methods, which otherwise do not exist
|
||||
|
||||
```js
|
||||
const window = (new JSDOM(``, { pretendToBeVisual: true })).window;
|
||||
|
||||
window.requestAnimationFrame(timestamp => {
|
||||
console.log(timestamp > 0);
|
||||
});
|
||||
```
|
||||
|
||||
Note that jsdom still [does not do any layout or rendering](#unimplemented-parts-of-the-web-platform), so this is really just about _pretending_ to be visual, not about implementing the parts of the platform a real, visual web browser would implement.
|
||||
|
||||
### Loading subresources
|
||||
|
||||
#### Basic options
|
||||
|
||||
By default, jsdom will not load any subresources such as scripts, stylesheets, images, or iframes. If you'd like jsdom to load such resources, you can pass the `resources: "usable"` option, which will load all usable resources. Those are:
|
||||
|
||||
- Frames and iframes, via `<frame>` and `<iframe>`
|
||||
- Stylesheets, via `<link rel="stylesheet">`
|
||||
- Scripts, via `<script>`, but only if `runScripts: "dangerously"` is also set
|
||||
- Images, via `<img>`, but only if the `canvas` npm package is also installed (see "[Canvas Support](#canvas-support)" below)
|
||||
|
||||
When attempting to load resources, recall that the default value for the `url` option is `"about:blank"`, which means that any resources included via relative URLs will fail to load. (The result of trying to parse the URL `/something` against the URL `about:blank` is an error.) So, you'll likely want to set a non-default value for the `url` option in those cases, or use one of the [convenience APIs](#convenience-apis) that do so automatically.
|
||||
|
||||
#### Advanced configuration
|
||||
|
||||
To more fully customize jsdom's resource-loading behavior, including the initial load made by [`JSDOM.fromURL()`](#fromurl) or any loads made with `dom.window.XMLHttpRequest` or `dom.window.WebSocket`, you can pass an options object as the `resources` option value. Doing so will opt you in to the above-described `resources: "usable"` behavior as the baseline, on top of which your customizations can be layered.
|
||||
|
||||
The available options are:
|
||||
|
||||
- `userAgent` affects the `User-Agent` header sent, and thus the resulting value for `navigator.userAgent`. It defaults to <code>\`Mozilla/5.0 (${process.platform || "unknown OS"}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}\`</code>.
|
||||
|
||||
- `dispatcher` can be set to a custom [undici `Dispatcher`](https://undici.nodejs.org/#/docs/api/Dispatcher) for advanced use cases such as configuring a proxy or custom TLS settings. For example, to use a proxy, you can use undici's `ProxyAgent`.
|
||||
|
||||
- `interceptors` can be set to an array of [`undici` interceptor functions](https://undici.nodejs.org/#/docs/api/Dispatcher?id=parameter-interceptor). Interceptors can be used to modify requests or responses without writing an entirely new `Dispatcher`.
|
||||
|
||||
For the simple case of inspecting an incoming request or returning a synthetic response, you can use jsdom's `requestInterceptor()` helper, which receives a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object and context, and can return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response):
|
||||
|
||||
```js
|
||||
const { JSDOM, requestInterceptor } = require("jsdom");
|
||||
|
||||
const dom = new JSDOM(`<script src="https://example.com/some-specific-script.js"></script>`, {
|
||||
url: "https://example.com/",
|
||||
runScripts: "dangerously",
|
||||
resources: {
|
||||
userAgent: "Mellblomenator/9000",
|
||||
dispatcher: new ProxyAgent("http://127.0.0.1:9001"),
|
||||
interceptors: [
|
||||
requestInterceptor((request, context) => {
|
||||
// Override the contents of this script to do something unusual.
|
||||
if (request.url === "https://example.com/some-specific-script.js") {
|
||||
return new Response("window.someGlobal = 5;", {
|
||||
headers: { "Content-Type": "application/javascript" }
|
||||
});
|
||||
}
|
||||
// Return undefined to let the request proceed normally
|
||||
})
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The context object passed to the interceptor includes `element` (the DOM element that initiated the request, or `null` for requests that are not from DOM elements). For example:
|
||||
|
||||
```js
|
||||
requestInterceptor((request, { element }) => {
|
||||
if (element) {
|
||||
console.log(`Element ${element.localName} is requesting ${request.url}`);
|
||||
}
|
||||
// Return undefined to let the request proceed normally
|
||||
})
|
||||
```
|
||||
|
||||
To be clear on the flow: when something in your jsdom fetches resources, first the request is set up by jsdom, then it is passed through any `interceptors` in the order provided, then it reaches any provided `dispatcher` (defaulting to [`undici`'s global dispatcher](https://undici.nodejs.org/#/?id=undicigetglobaldispatcher)). If you use jsdom's `requestInterceptor()`, returning promise fulfilled with a `Response` will prevent any further interceptors from running, or the base dispatcher from being reached.
|
||||
|
||||
> [!WARNING]
|
||||
> All resource loading customization is ignored when scripts inside the jsdom use synchronous `XMLHttpRequest`. This is a technical limitation as we cannot transfer dispatchers or interceptors across a process boundary.
|
||||
|
||||
### Virtual consoles
|
||||
|
||||
Like web browsers, jsdom has the concept of a "console". This records both information directly sent from the page, via scripts executing inside the document using the `window.console` API, as well as information from the jsdom implementation itself. We call the user-controllable console a "virtual console", to distinguish it from the Node.js `console` API and from the inside-the-page `window.console` API.
|
||||
|
||||
By default, the `JSDOM` constructor will return an instance with a virtual console that forwards all its output to the Node.js console. This includes both jsdom output (such as not-implemented warnings or CSS parsing errors) and in-page `window.console` calls.
|
||||
|
||||
To create your own virtual console and pass it to jsdom, you can override this default by doing
|
||||
|
||||
```js
|
||||
const virtualConsole = new jsdom.VirtualConsole();
|
||||
const dom = new JSDOM(``, { virtualConsole });
|
||||
```
|
||||
|
||||
Code like this will create a virtual console with no behavior. You can give it behavior by adding event listeners for all the possible console methods:
|
||||
|
||||
```js
|
||||
virtualConsole.on("error", () => { ... });
|
||||
virtualConsole.on("warn", () => { ... });
|
||||
virtualConsole.on("info", () => { ... });
|
||||
virtualConsole.on("dir", () => { ... });
|
||||
// ... etc. See https://console.spec.whatwg.org/#logging
|
||||
```
|
||||
|
||||
(Note that it is probably best to set up these event listeners _before_ calling `new JSDOM()`, since errors or console-invoking script might occur during parsing.)
|
||||
|
||||
If you simply want to redirect the virtual console output to another console, like the default Node.js one, you can do
|
||||
|
||||
```js
|
||||
virtualConsole.forwardTo(console);
|
||||
```
|
||||
|
||||
There is also a special event, `"jsdomError"`, which will fire with error objects to report errors from jsdom itself. This is similar to how error messages often show up in web browser consoles, even if they are not initiated by `console.error`.
|
||||
|
||||
As mentioned above, the default behavior for jsdom is to send these to the Node.js console. This done via `console.error(jsdomError.message)`, or in the case of `"unhandled-exception"`-type jsdom errors that occur from scripts running in the jsdom, via `console.error(jsdomError.cause.stack)`. Using `forwardTo()` will give the same behavior. If you want a non-default behavior, you can customize it in the following ways:
|
||||
|
||||
```js
|
||||
// Do not send any jsdom errors to the Node.js console:
|
||||
virtualConsole.forwardTo(console, { jsdomErrors: "none" });
|
||||
|
||||
// Send only certain jsdom errors to the Node.js console, ignoring others:
|
||||
virtualConsole.forwardTo(console, { jsdomErrors: ["unhandled-exception", "not-implemented"]});
|
||||
|
||||
// Customize the handling of all jsdom errors:
|
||||
virtualConsole.forwardTo(console, { jsdomErrors: "none" });
|
||||
virtualConsole.on("jsdomError", err => {
|
||||
switch (err.type) {
|
||||
case "unhandled-exception": {
|
||||
// ... process ...
|
||||
break;
|
||||
}
|
||||
case "css-parsing": {
|
||||
// ... process in some other way ...
|
||||
break;
|
||||
}
|
||||
// ... etc. ...
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The details for each type of jsdom error, listed by their `type` property, are:
|
||||
|
||||
- `"css-parsing"`: an error parsing CSS stylesheets
|
||||
- `cause`: the exception object from our CSS parser library, [`@acemir/cssom`](https://github.com/acemir/CSSOM)
|
||||
- `sheetText`: the full text of the stylesheet that we attempted to parse
|
||||
- `"not-implemented"`: an error emitted when certain stub methods from [unimplemented parts of the web platform](#unimplemented-parts-of-the-web-platform) are called
|
||||
- `"resource-loading"`: an error [loading resources](#loading-subresources), e.g. due to a network error or a bad response code from the server
|
||||
- `cause` property: the exception object from the internal Node.js network calls jsdom made when retrieving the resource, or from the developer's custom resource loader
|
||||
- `url` property: the URL of the resource that was attempted to be fetched
|
||||
- `"unhandled-exception"`: a [script execution](#executing-scripts) error that was not handled by a `Window` `"error"` event listener
|
||||
- `cause` property: contains the original exception object
|
||||
|
||||
### Cookie jars
|
||||
|
||||
Like web browsers, jsdom has the concept of a cookie jar, storing HTTP cookies. Cookies that have a URL on the same domain as the document, and are not marked HTTP-only, are accessible via the `document.cookie` API. Additionally, all cookies in the cookie jar will impact the fetching of subresources.
|
||||
|
||||
By default, the `JSDOM` constructor will return an instance with an empty cookie jar. To create your own cookie jar and pass it to jsdom, you can override this default by doing
|
||||
|
||||
```js
|
||||
const cookieJar = new jsdom.CookieJar(store, options);
|
||||
const dom = new JSDOM(``, { cookieJar });
|
||||
```
|
||||
|
||||
This is mostly useful if you want to share the same cookie jar among multiple jsdoms, or prime the cookie jar with certain values ahead of time.
|
||||
|
||||
Cookie jars are provided by the [tough-cookie](https://www.npmjs.com/package/tough-cookie) package. The `jsdom.CookieJar` constructor is a subclass of the tough-cookie cookie jar which by default sets the `looseMode: true` option, since that [matches better how browsers behave](https://github.com/whatwg/html/issues/804). If you want to use tough-cookie's utilities and classes yourself, you can use the `jsdom.toughCookie` module export to get access to the tough-cookie module instance packaged with jsdom.
|
||||
|
||||
### Intervening before parsing
|
||||
|
||||
jsdom allows you to intervene in the creation of a jsdom very early: after the `Window` and `Document` objects are created, but before any HTML is parsed to populate the document with nodes:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<p>Hello</p>`, {
|
||||
beforeParse(window) {
|
||||
window.document.childNodes.length === 0;
|
||||
window.someCoolAPI = () => { /* ... */ };
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This is especially useful if you are wanting to modify the environment in some way, for example adding shims for web platform APIs jsdom does not support.
|
||||
|
||||
## `JSDOM` object API
|
||||
|
||||
Once you have constructed a `JSDOM` object, it will have the following useful capabilities:
|
||||
|
||||
### Properties
|
||||
|
||||
The property `window` retrieves the `Window` object that was created for you.
|
||||
|
||||
The properties `virtualConsole` and `cookieJar` reflect the options you pass in, or the defaults created for you if nothing was passed in for those options.
|
||||
|
||||
### Serializing the document with `serialize()`
|
||||
|
||||
The `serialize()` method will return the [HTML serialization](https://html.spec.whatwg.org/#html-fragment-serialisation-algorithm) of the document, including the doctype:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<!DOCTYPE html>hello`);
|
||||
|
||||
dom.serialize() === "<!DOCTYPE html><html><head></head><body>hello</body></html>";
|
||||
|
||||
// Contrast with:
|
||||
dom.window.document.documentElement.outerHTML === "<html><head></head><body>hello</body></html>";
|
||||
```
|
||||
|
||||
### Getting the source location of a node with `nodeLocation(node)`
|
||||
|
||||
The `nodeLocation()` method will find where a DOM node is within the source document, returning the [parse5 location info](https://www.npmjs.com/package/parse5#options-locationinfo) for the node:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(
|
||||
`<p>Hello
|
||||
<img src="foo.jpg">
|
||||
</p>`,
|
||||
{ includeNodeLocations: true }
|
||||
);
|
||||
|
||||
const document = dom.window.document;
|
||||
const bodyEl = document.body; // implicitly created
|
||||
const pEl = document.querySelector("p");
|
||||
const textNode = pEl.firstChild;
|
||||
const imgEl = document.querySelector("img");
|
||||
|
||||
console.log(dom.nodeLocation(bodyEl)); // null; it's not in the source
|
||||
console.log(dom.nodeLocation(pEl)); // { startOffset: 0, endOffset: 39, startTag: ..., endTag: ... }
|
||||
console.log(dom.nodeLocation(textNode)); // { startOffset: 3, endOffset: 13 }
|
||||
console.log(dom.nodeLocation(imgEl)); // { startOffset: 13, endOffset: 32 }
|
||||
```
|
||||
|
||||
Note that this feature only works if you have set the `includeNodeLocations` option; node locations are off by default for performance reasons.
|
||||
|
||||
### Interfacing with the Node.js `vm` module using `getInternalVMContext()`
|
||||
|
||||
The built-in [`vm`](https://nodejs.org/api/vm.html) module of Node.js is what underpins jsdom's script-running magic. Some advanced use cases, like pre-compiling a script and then running it multiple times, benefit from using the `vm` module directly with a jsdom-created `Window`.
|
||||
|
||||
To get access to the [contextified global object](https://nodejs.org/api/vm.html#vm_what_does_it_mean_to_contextify_an_object), suitable for use with the `vm` APIs, you can use the `getInternalVMContext()` method:
|
||||
|
||||
```js
|
||||
const { Script } = require("vm");
|
||||
|
||||
const dom = new JSDOM(``, { runScripts: "outside-only" });
|
||||
const script = new Script(`
|
||||
if (!this.ran) {
|
||||
this.ran = 0;
|
||||
}
|
||||
|
||||
++this.ran;
|
||||
`);
|
||||
|
||||
const vmContext = dom.getInternalVMContext();
|
||||
|
||||
script.runInContext(vmContext);
|
||||
script.runInContext(vmContext);
|
||||
script.runInContext(vmContext);
|
||||
|
||||
console.assert(dom.window.ran === 3);
|
||||
```
|
||||
|
||||
This is somewhat-advanced functionality, and we advise sticking to normal DOM APIs (such as `window.eval()` or `document.createElement("script")`) unless you have very specific needs.
|
||||
|
||||
Note that this method will throw an exception if the `JSDOM` instance was created without `runScripts` set.
|
||||
|
||||
### Reconfiguring the jsdom with `reconfigure(settings)`
|
||||
|
||||
The `top` property on `window` is marked `[Unforgeable]` in the spec, meaning it is a non-configurable own property and thus cannot be overridden or shadowed by normal code running inside the jsdom, even using `Object.defineProperty`.
|
||||
|
||||
Similarly, at present jsdom does not handle navigation (such as setting `window.location.href = "https://example.com/"`); doing so will cause the virtual console to emit a `"jsdomError"` explaining that this feature is not implemented, and nothing will change: there will be no new `Window` or `Document` object, and the existing `window`'s `location` object will still have all the same property values.
|
||||
|
||||
However, if you're acting from outside the window, e.g. in some test framework that creates jsdoms, you can override one or both of these using the special `reconfigure()` method:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM();
|
||||
|
||||
dom.window.top === dom.window;
|
||||
dom.window.location.href === "about:blank";
|
||||
|
||||
dom.reconfigure({ windowTop: myFakeTopForTesting, url: "https://example.com/" });
|
||||
|
||||
dom.window.top === myFakeTopForTesting;
|
||||
dom.window.location.href === "https://example.com/";
|
||||
```
|
||||
|
||||
Note that changing the jsdom's URL will impact all APIs that return the current document URL, such as `window.location`, `document.URL`, and `document.documentURI`, as well as the resolution of relative URLs within the document, and the same-origin checks and referrer used while fetching subresources. It will not, however, perform navigation to the contents of that URL; the contents of the DOM will remain unchanged, and no new instances of `Window`, `Document`, etc. will be created.
|
||||
|
||||
## Convenience APIs
|
||||
|
||||
### `fromURL()`
|
||||
|
||||
In addition to the `JSDOM` constructor itself, jsdom provides a promise-returning factory method for constructing a jsdom from a URL:
|
||||
|
||||
```js
|
||||
JSDOM.fromURL("https://example.com/", options).then(dom => {
|
||||
console.log(dom.serialize());
|
||||
});
|
||||
```
|
||||
|
||||
The returned promise will fulfill with a `JSDOM` instance if the URL is valid and the request is successful. Any redirects will be followed to their ultimate destination.
|
||||
|
||||
The options provided to `fromURL()` are similar to those provided to the `JSDOM` constructor, with the following additional restrictions and consequences:
|
||||
|
||||
- The `url` and `contentType` options cannot be provided.
|
||||
- The `referrer` option is used as the HTTP `Referer` request header of the initial request.
|
||||
- The `resources` option also affects the initial request; this is useful if you want to, for example, configure a proxy (see above).
|
||||
- The resulting jsdom's URL, content type, and referrer are determined from the response.
|
||||
- Any cookies set via HTTP `Set-Cookie` response headers are stored in the jsdom's cookie jar. Similarly, any cookies already in a supplied cookie jar are sent as HTTP `Cookie` request headers.
|
||||
|
||||
### `fromFile()`
|
||||
|
||||
Similar to `fromURL()`, jsdom also provides a `fromFile()` factory method for constructing a jsdom from a filename:
|
||||
|
||||
```js
|
||||
JSDOM.fromFile("stuff.html", options).then(dom => {
|
||||
console.log(dom.serialize());
|
||||
});
|
||||
```
|
||||
|
||||
The returned promise will fulfill with a `JSDOM` instance if the given file can be opened. As usual in Node.js APIs, the filename is given relative to the current working directory.
|
||||
|
||||
The options provided to `fromFile()` are similar to those provided to the `JSDOM` constructor, with the following additional defaults:
|
||||
|
||||
- The `url` option will default to a file URL corresponding to the given filename, instead of to `"about:blank"`.
|
||||
- The `contentType` option will default to `"application/xhtml+xml"` if the given filename ends in `.xht`, `.xhtml`, or `.xml`; otherwise it will continue to default to `"text/html"`.
|
||||
|
||||
### `fragment()`
|
||||
|
||||
For the very simplest of cases, you might not need a whole `JSDOM` instance with all its associated power. You might not even need a `Window` or `Document`! Instead, you just need to parse some HTML, and get a DOM object you can manipulate. For that, we have `fragment()`, which creates a `DocumentFragment` from a given string:
|
||||
|
||||
```js
|
||||
const frag = JSDOM.fragment(`<p>Hello</p><p><strong>Hi!</strong>`);
|
||||
|
||||
frag.childNodes.length === 2;
|
||||
frag.querySelector("strong").textContent === "Hi!";
|
||||
// etc.
|
||||
```
|
||||
|
||||
Here `frag` is a [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) instance, whose contents are created by parsing the provided string. The parsing is done using a `<template>` element, so you can include any element there (including ones with weird parsing rules like `<td>`). It's also important to note that the resulting `DocumentFragment` will not have [an associated browsing context](https://html.spec.whatwg.org/multipage/#concept-document-bc): that is, elements' `ownerDocument` will have a null `defaultView` property, resources will not load, etc.
|
||||
|
||||
All invocations of the `fragment()` factory result in `DocumentFragment`s that share the same template owner `Document`. This allows many calls to `fragment()` with no extra overhead. But it also means that calls to `fragment()` cannot be customized with any options.
|
||||
|
||||
Note that serialization is not as easy with `DocumentFragment`s as it is with full `JSDOM` objects. If you need to serialize your DOM, you should probably use the `JSDOM` constructor more directly. But for the special case of a fragment containing a single element, it's pretty easy to do through normal means:
|
||||
|
||||
```js
|
||||
const frag = JSDOM.fragment(`<p>Hello</p>`);
|
||||
console.log(frag.firstChild.outerHTML); // logs "<p>Hello</p>"
|
||||
```
|
||||
|
||||
## Other noteworthy features
|
||||
|
||||
### Canvas support
|
||||
|
||||
jsdom includes support for using the [`canvas`](https://www.npmjs.com/package/canvas) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include `canvas` as a dependency in your project, as a peer of `jsdom`. If jsdom can find version 3.x of the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s.
|
||||
|
||||
### Encoding sniffing
|
||||
|
||||
In addition to supplying a string, the `JSDOM` constructor can also be supplied binary data, in the form of a standard JavaScript binary data type like `ArrayBuffer`, `Uint8Array`, `DataView`, etc. When this is done, jsdom will [sniff the encoding](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm) from the supplied bytes, scanning for `<meta charset>` tags just like a browser does.
|
||||
|
||||
If the supplied `contentType` option contains a `charset` parameter, that encoding will override the sniffed encoding—unless a UTF-8 or UTF-16 BOM is present, in which case those take precedence. (Again, this is just like a browser.)
|
||||
|
||||
This encoding sniffing also applies to `JSDOM.fromFile()` and `JSDOM.fromURL()`. In the latter case, any `Content-Type` headers sent with the response will take priority, in the same fashion as the constructor's `contentType` option.
|
||||
|
||||
Note that in many cases supplying bytes in this fashion can be better than supplying a string. For example, if you attempt to use Node.js's `buffer.toString("utf-8")` API, Node.js will not strip any leading BOMs. If you then give this string to jsdom, it will interpret it verbatim, leaving the BOM intact. But jsdom's binary data decoding code will strip leading BOMs, just like a browser; in such cases, supplying `buffer` directly will give the desired result.
|
||||
|
||||
### Closing down a jsdom
|
||||
|
||||
Timers in the jsdom (set by `window.setTimeout()` or `window.setInterval()`) will, by definition, execute code in the future in the context of the window. Since there is no way to execute code in the future without keeping the process alive, outstanding jsdom timers will keep your Node.js process alive. Similarly, since there is no way to execute code in the context of an object without keeping that object alive, outstanding jsdom timers will prevent garbage collection of the window on which they are scheduled.
|
||||
|
||||
If you want to be sure to shut down a jsdom window, use `window.close()`, which will terminate all running timers (and also remove any event listeners on the window and document).
|
||||
|
||||
### Debugging the DOM using Chrome DevTools
|
||||
|
||||
In Node.js you can debug programs using Chrome DevTools. See the [official documentation](https://nodejs.org/en/docs/inspector/) for how to get started.
|
||||
|
||||
By default jsdom elements are formatted as plain old JS objects in the console. To make it easier to debug, you can use [jsdom-devtools-formatter](https://github.com/jsdom/jsdom-devtools-formatter), which lets you inspect them like real DOM elements.
|
||||
|
||||
## Caveats
|
||||
|
||||
### Asynchronous script loading
|
||||
|
||||
People often have trouble with asynchronous script loading when using jsdom. Many pages load scripts asynchronously, but there is no way to tell when they're done doing so, and thus when it's a good time to run your code and inspect the resulting DOM structure. This is a fundamental limitation; we cannot predict what scripts on the web page will do, and so cannot tell you when they are done loading more scripts.
|
||||
|
||||
This can be worked around in a few ways. The best way, if you control the page in question, is to use whatever mechanisms are given by the script loader to detect when loading is done. For example, if you're using a module loader like RequireJS, the code could look like:
|
||||
|
||||
```js
|
||||
// On the Node.js side:
|
||||
const window = (new JSDOM(...)).window;
|
||||
window.onModulesLoaded = () => {
|
||||
console.log("ready to roll!");
|
||||
};
|
||||
```
|
||||
|
||||
```html
|
||||
<!-- Inside the HTML you supply to jsdom -->
|
||||
<script>
|
||||
requirejs(["entry-module"], () => {
|
||||
window.onModulesLoaded();
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
If you do not control the page, you could try workarounds such as polling for the presence of a specific element.
|
||||
|
||||
For more details, see the discussion in [#640](https://github.com/jsdom/jsdom/issues/640), especially [@matthewkastor](https://github.com/matthewkastor)'s [insightful comment](https://github.com/jsdom/jsdom/issues/640#issuecomment-22216965).
|
||||
|
||||
### Unimplemented parts of the web platform
|
||||
|
||||
Although we enjoy adding new features to jsdom and keeping it up to date with the latest web specs, it has many missing APIs. Please feel free to file an issue for anything missing, but we're a small and busy team, so a pull request might work even better.
|
||||
|
||||
Some features of jsdom are provided by our dependencies. Notable documentation in that regard includes the list of [supported CSS selectors](https://github.com/dperini/nwsapi/wiki/CSS-supported-selectors) for our CSS selector engine, [`nwsapi`](https://github.com/dperini/nwsapi).
|
||||
|
||||
Beyond just features that we haven't gotten to yet, there are two major features that are currently outside the scope of jsdom. These are:
|
||||
|
||||
- **Navigation**: the ability to change the global object, and all other objects, when clicking a link or assigning `location.href` or similar.
|
||||
- **Layout**: the ability to calculate where elements will be visually laid out as a result of CSS, which impacts methods like `getBoundingClientRects()` or properties like `offsetTop`.
|
||||
|
||||
Currently jsdom has dummy behaviors for some aspects of these features, such as sending a "not implemented" `"jsdomError"` to the virtual console for navigation, or returning zeros for many layout-related properties. Often you can work around these limitations in your code, e.g. by creating new `JSDOM` instances for each page you "navigate" to during a crawl, or using `Object.defineProperty()` to change what various layout-related getters and methods return.
|
||||
|
||||
Note that other tools in the same space, such as PhantomJS, do support these features. On the wiki, we have a more complete writeup about [jsdom vs. PhantomJS](https://github.com/jsdom/jsdom/wiki/jsdom-vs.-PhantomJS).
|
||||
|
||||
## Supporting jsdom
|
||||
|
||||
jsdom is a community-driven project maintained by a team of [volunteers](https://github.com/orgs/jsdom/people). You could support jsdom by:
|
||||
|
||||
- [Getting professional support for jsdom](https://tidelift.com/subscription/pkg/npm-jsdom?utm_source=npm-jsdom&utm_medium=referral&utm_campaign=readme) as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security.
|
||||
- [Contributing](https://github.com/jsdom/jsdom/blob/main/Contributing.md) directly to the project.
|
||||
|
||||
## Getting help
|
||||
|
||||
If you need help with jsdom, please feel free to use any of the following venues:
|
||||
|
||||
- The [mailing list](https://groups.google.com/group/jsdom) (best for "how do I" questions)
|
||||
- The [issue tracker](https://github.com/jsdom/jsdom/issues) (best for bug reports)
|
||||
- The Matrix room: [#jsdom:matrix.org](https://matrix.to/#/#jsdom:matrix.org)
|
||||
+373
@@ -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;
|
||||
Generated
Vendored
+16021
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+1686
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+7698
File diff suppressed because it is too large
Load Diff
+115
@@ -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"
|
||||
]);
|
||||
Generated
Vendored
+143
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+53
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+28
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+139
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+42
@@ -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
@@ -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");
|
||||
Generated
Vendored
+122
@@ -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");
|
||||
Generated
Vendored
+135
@@ -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");
|
||||
Generated
Vendored
+439
@@ -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");
|
||||
Generated
Vendored
+140
@@ -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");
|
||||
Generated
Vendored
+188
@@ -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
@@ -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");
|
||||
Generated
Vendored
+170
@@ -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");
|
||||
Generated
Vendored
+404
@@ -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");
|
||||
Generated
Vendored
+122
@@ -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");
|
||||
Generated
Vendored
+122
@@ -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
@@ -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");
|
||||
Generated
Vendored
+135
@@ -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");
|
||||
Generated
Vendored
+140
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+497
@@ -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");
|
||||
Generated
Vendored
+66822
File diff suppressed because it is too large
Load Diff
+170
@@ -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
@@ -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");
|
||||
Generated
Vendored
+66
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+122
@@ -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");
|
||||
Generated
Vendored
+12
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+219
@@ -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");
|
||||
Generated
Vendored
+32
@@ -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
@@ -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");
|
||||
Generated
Vendored
+34
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+269
@@ -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
@@ -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");
|
||||
Generated
Vendored
+32
@@ -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
@@ -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");
|
||||
Generated
Vendored
+237
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+285
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+183
@@ -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");
|
||||
Generated
Vendored
+145
@@ -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");
|
||||
Generated
Vendored
+61
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+70
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+145
@@ -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");
|
||||
Generated
Vendored
+61
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+183
@@ -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");
|
||||
Generated
Vendored
+80
@@ -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
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+336
@@ -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");
|
||||
Generated
Vendored
+12
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+26
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+29
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+2152
File diff suppressed because it is too large
Load Diff
+12
@@ -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
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+36
@@ -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
@@ -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
@@ -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) => {};
|
||||
Generated
Vendored
+28
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+221
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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");
|
||||
Generated
Vendored
+33
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user