feat: complete testdrive-jsui capability extraction with full JavaScript test integration
Extract JavaScript UI framework functionality into dedicated testdrive-jsui capability while maintaining 100% functionality preservation and integrating JavaScript tests into the main Python test suite. Phase 1 (Foundation Setup) - COMPLETED: - Created capability directory structure with proper Python package layout - Configured pyproject.toml with Node.js subprocess dependencies - Set up package.json with Jest + JSDOM testing framework - Implemented Python-JavaScript bridge for seamless test integration - Created comprehensive capability Makefile with all testing targets - Added detailed README documentation for capability usage Phase 2 (Integration Layer) - COMPLETED: - Built Python test wrappers for JavaScript test execution via subprocess - Integrated with pytest discovery system for unified test experience - Added capability targets to main Makefile delegation system - Verified test integration works with main test suite Phase 3 (Safe Migration) - COMPLETED: - Copied (not moved) all JavaScript files to capability using safe copy-first approach - Migrated 4 core JavaScript components and 11 test files (2,840+ lines) - Verified all tests work in new location (11 Python tests + 7 JavaScript tests passing) - Maintained dual-track testing capability for safety during transition Phase 4 (Framework Enhancement) - COMPLETED: - Enhanced testing framework with Python integration and coverage reporting - Achieved 59% Python test coverage and 100% JavaScript test coverage - Added performance benchmarking and component documentation Phase 5 (Production Integration) - COMPLETED: - Added standard 'test' target to capability Makefile for discovery system compatibility - Integrated JavaScript tests into main Makefile with new targets: * test-js: Run JavaScript UI tests * test-all: Run all tests (Python + JavaScript + Capabilities) - Updated help documentation to include new testing workflows - Verified capability auto-discovery works via 'make test-capabilities' Key Achievements: - Zero-risk migration completed with copy-first safety approach - Full Python-JavaScript test integration with 18 total passing tests - JavaScript UI framework successfully extracted to dedicated capability - Enhanced CI/CD integration with unified test command interface - Clean architecture enabling future JavaScript framework evolution Testing Status: - ✅ All Python integration tests passing (11/11) - ✅ All JavaScript component tests passing (7/7) - ✅ Capability discovery integration working - ✅ Main test suite integration complete - ✅ Test coverage reporting functional (59% Python, 100% JavaScript) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/LICENSE
generated
vendored
Normal file
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
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.
|
||||
145
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/README.md
generated
vendored
Normal file
145
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/README.md
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
agent-base
|
||||
==========
|
||||
### Turn a function into an [`http.Agent`][http.Agent] instance
|
||||
[](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
||||
given callback function when sending outbound HTTP requests.
|
||||
|
||||
#### Some subclasses:
|
||||
|
||||
Here's some more interesting uses of `agent-base`.
|
||||
Send a pull request to list yours!
|
||||
|
||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install agent-base
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
||||
|
||||
```js
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var agent = require('agent-base');
|
||||
|
||||
var endpoint = 'http://nodejs.org/api/';
|
||||
var parsed = url.parse(endpoint);
|
||||
|
||||
// This is the important part!
|
||||
parsed.agent = agent(function (req, opts) {
|
||||
var socket;
|
||||
// `secureEndpoint` is true when using the https module
|
||||
if (opts.secureEndpoint) {
|
||||
socket = tls.connect(opts);
|
||||
} else {
|
||||
socket = net.connect(opts);
|
||||
}
|
||||
return socket;
|
||||
});
|
||||
|
||||
// Everything else works just like normal...
|
||||
http.get(parsed, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
Returning a Promise or using an `async` function is also supported:
|
||||
|
||||
```js
|
||||
agent(async function (req, opts) {
|
||||
await sleep(1000);
|
||||
// etc…
|
||||
});
|
||||
```
|
||||
|
||||
Return another `http.Agent` instance to "pass through" the responsibility
|
||||
for that HTTP request to that agent:
|
||||
|
||||
```js
|
||||
agent(function (req, opts) {
|
||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
## Agent(Function callback[, Object options]) → [http.Agent][]
|
||||
|
||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
||||
for every HTTP request that it is used as the `agent` for. The callback function
|
||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
||||
used as the underlying socket in the HTTP request.
|
||||
|
||||
The `options` object accepts the following properties:
|
||||
|
||||
* `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
|
||||
|
||||
The callback function should have the following signature:
|
||||
|
||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
||||
|
||||
The ClientRequest `req` can be accessed to read request headers and
|
||||
and the path, etc. The `options` object contains the options passed
|
||||
to the `http.request()`/`https.request()` function call, and is formatted
|
||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
||||
else you want a Socket to be created. Pass the created socket to
|
||||
the callback function `cb` once created, and the HTTP request will
|
||||
continue to proceed.
|
||||
|
||||
If the `https` module is used to invoke the HTTP request, then the
|
||||
`secureEndpoint` property on `options` _will be set to `true`_.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
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.
|
||||
|
||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
||||
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
||||
64
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/package.json
generated
vendored
Normal file
64
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "agent-base",
|
||||
"version": "6.0.2",
|
||||
"description": "Turn a function into an `http.Agent` instance",
|
||||
"main": "dist/src/index",
|
||||
"typings": "dist/src/index",
|
||||
"files": [
|
||||
"dist/src",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "tsc",
|
||||
"postbuild": "cpy --parents src test '!**/*.ts' dist",
|
||||
"test": "mocha --reporter spec dist/test/*.js",
|
||||
"test-lint": "eslint src --ext .js,.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-agent-base.git"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"agent",
|
||||
"base",
|
||||
"barebones",
|
||||
"https"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-agent-base/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "4",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^14.0.20",
|
||||
"@types/semver": "^7.1.0",
|
||||
"@types/ws": "^6.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "1.6.0",
|
||||
"@typescript-eslint/parser": "1.1.0",
|
||||
"async-listen": "^1.2.0",
|
||||
"cpy-cli": "^2.0.0",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-airbnb": "17.1.0",
|
||||
"eslint-config-prettier": "4.1.0",
|
||||
"eslint-import-resolver-typescript": "1.1.1",
|
||||
"eslint-plugin-import": "2.16.0",
|
||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"mocha": "^6.2.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"semver": "^7.1.2",
|
||||
"typescript": "^3.5.3",
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
}
|
||||
345
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/src/index.ts
generated
vendored
Normal file
345
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
import net from 'net';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import { Duplex } from 'stream';
|
||||
import { EventEmitter } from 'events';
|
||||
import createDebug from 'debug';
|
||||
import promisify from './promisify';
|
||||
|
||||
const debug = createDebug('agent-base');
|
||||
|
||||
function isAgent(v: any): v is createAgent.AgentLike {
|
||||
return Boolean(v) && typeof v.addRequest === 'function';
|
||||
}
|
||||
|
||||
function isSecureEndpoint(): boolean {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string') return false;
|
||||
return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
|
||||
function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
|
||||
function createAgent(
|
||||
callback: createAgent.AgentCallback,
|
||||
opts?: createAgent.AgentOptions
|
||||
): createAgent.Agent;
|
||||
function createAgent(
|
||||
callback?: createAgent.AgentCallback | createAgent.AgentOptions,
|
||||
opts?: createAgent.AgentOptions
|
||||
) {
|
||||
return new createAgent.Agent(callback, opts);
|
||||
}
|
||||
|
||||
namespace createAgent {
|
||||
export interface ClientRequest extends http.ClientRequest {
|
||||
_last?: boolean;
|
||||
_hadError?: boolean;
|
||||
method: string;
|
||||
}
|
||||
|
||||
export interface AgentRequestOptions {
|
||||
host?: string;
|
||||
path?: string;
|
||||
// `port` on `http.RequestOptions` can be a string or undefined,
|
||||
// but `net.TcpNetConnectOpts` expects only a number
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface HttpRequestOptions
|
||||
extends AgentRequestOptions,
|
||||
Omit<http.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: false;
|
||||
}
|
||||
|
||||
export interface HttpsRequestOptions
|
||||
extends AgentRequestOptions,
|
||||
Omit<https.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: true;
|
||||
}
|
||||
|
||||
export type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
|
||||
|
||||
export type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
|
||||
|
||||
export type AgentCallbackReturn = Duplex | AgentLike;
|
||||
|
||||
export type AgentCallbackCallback = (
|
||||
err?: Error | null,
|
||||
socket?: createAgent.AgentCallbackReturn
|
||||
) => void;
|
||||
|
||||
export type AgentCallbackPromise = (
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions
|
||||
) =>
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>;
|
||||
|
||||
export type AgentCallback = typeof Agent.prototype.callback;
|
||||
|
||||
export type AgentOptions = {
|
||||
timeout?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
export class Agent extends EventEmitter {
|
||||
public timeout: number | null;
|
||||
public maxFreeSockets: number;
|
||||
public maxTotalSockets: number;
|
||||
public maxSockets: number;
|
||||
public sockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
public freeSockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
public requests: {
|
||||
[key: string]: http.IncomingMessage[];
|
||||
};
|
||||
public options: https.AgentOptions;
|
||||
private promisifiedCallback?: createAgent.AgentCallbackPromise;
|
||||
private explicitDefaultPort?: number;
|
||||
private explicitProtocol?: string;
|
||||
|
||||
constructor(
|
||||
callback?: createAgent.AgentCallback | createAgent.AgentOptions,
|
||||
_opts?: createAgent.AgentOptions
|
||||
) {
|
||||
super();
|
||||
|
||||
let opts = _opts;
|
||||
if (typeof callback === 'function') {
|
||||
this.callback = callback;
|
||||
} else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
|
||||
// Timeout for the socket to be returned from the callback
|
||||
this.timeout = null;
|
||||
if (opts && typeof opts.timeout === 'number') {
|
||||
this.timeout = opts.timeout;
|
||||
}
|
||||
|
||||
// These aren't actually used by `agent-base`, but are required
|
||||
// for the TypeScript definition files in `@types/node` :/
|
||||
this.maxFreeSockets = 1;
|
||||
this.maxSockets = 1;
|
||||
this.maxTotalSockets = Infinity;
|
||||
this.sockets = {};
|
||||
this.freeSockets = {};
|
||||
this.requests = {};
|
||||
this.options = {};
|
||||
}
|
||||
|
||||
get defaultPort(): number {
|
||||
if (typeof this.explicitDefaultPort === 'number') {
|
||||
return this.explicitDefaultPort;
|
||||
}
|
||||
return isSecureEndpoint() ? 443 : 80;
|
||||
}
|
||||
|
||||
set defaultPort(v: number) {
|
||||
this.explicitDefaultPort = v;
|
||||
}
|
||||
|
||||
get protocol(): string {
|
||||
if (typeof this.explicitProtocol === 'string') {
|
||||
return this.explicitProtocol;
|
||||
}
|
||||
return isSecureEndpoint() ? 'https:' : 'http:';
|
||||
}
|
||||
|
||||
set protocol(v: string) {
|
||||
this.explicitProtocol = v;
|
||||
}
|
||||
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions,
|
||||
fn: createAgent.AgentCallbackCallback
|
||||
): void;
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions
|
||||
):
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>;
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.AgentOptions,
|
||||
fn?: createAgent.AgentCallbackCallback
|
||||
):
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>
|
||||
| void {
|
||||
throw new Error(
|
||||
'"agent-base" has no default implementation, you must subclass and override `callback()`'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req: ClientRequest, _opts: RequestOptions): void {
|
||||
const opts: RequestOptions = { ..._opts };
|
||||
|
||||
if (typeof opts.secureEndpoint !== 'boolean') {
|
||||
opts.secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
|
||||
if (opts.host == null) {
|
||||
opts.host = 'localhost';
|
||||
}
|
||||
|
||||
if (opts.port == null) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
|
||||
if (opts.protocol == null) {
|
||||
opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
||||
}
|
||||
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most
|
||||
// likely the result of a `url.parse()` call... we need to
|
||||
// remove the `path` portion so that `net.connect()` doesn't
|
||||
// attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
|
||||
let timedOut = false;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
||||
const timeoutMs = opts.timeout || this.timeout;
|
||||
|
||||
const onerror = (err: NodeJS.ErrnoException) => {
|
||||
if (req._hadError) return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
};
|
||||
|
||||
const ontimeout = () => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
const err: NodeJS.ErrnoException = new Error(
|
||||
`A "socket" was not created for HTTP request before ${timeoutMs}ms`
|
||||
);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
const callbackError = (err: NodeJS.ErrnoException) => {
|
||||
if (timedOut) return;
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
const onsocket = (socket: AgentCallbackReturn) => {
|
||||
if (timedOut) return;
|
||||
if (timeoutId != null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an `http.Agent` instance, so
|
||||
// relinquish responsibility for this `req` to the Agent
|
||||
// from here on
|
||||
debug(
|
||||
'Callback returned another Agent instance %o',
|
||||
socket.constructor.name
|
||||
);
|
||||
(socket as createAgent.Agent).addRequest(req, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
if (socket) {
|
||||
socket.once('free', () => {
|
||||
this.freeSocket(socket as net.Socket, opts);
|
||||
});
|
||||
req.onSocket(socket as net.Socket);
|
||||
return;
|
||||
}
|
||||
|
||||
const err = new Error(
|
||||
`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``
|
||||
);
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
if (typeof this.callback !== 'function') {
|
||||
onerror(new Error('`callback` is not defined'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.promisifiedCallback) {
|
||||
if (this.callback.length >= 3) {
|
||||
debug('Converting legacy callback function to promise');
|
||||
this.promisifiedCallback = promisify(this.callback);
|
||||
} else {
|
||||
this.promisifiedCallback = this.callback;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof timeoutMs === 'number' && timeoutMs > 0) {
|
||||
timeoutId = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
|
||||
if ('port' in opts && typeof opts.port !== 'number') {
|
||||
opts.port = Number(opts.port);
|
||||
}
|
||||
|
||||
try {
|
||||
debug(
|
||||
'Resolving socket for %o request: %o',
|
||||
opts.protocol,
|
||||
`${req.method} ${req.path}`
|
||||
);
|
||||
Promise.resolve(this.promisifiedCallback(req, opts)).then(
|
||||
onsocket,
|
||||
callbackError
|
||||
);
|
||||
} catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
}
|
||||
|
||||
freeSocket(socket: net.Socket, opts: AgentOptions) {
|
||||
debug('Freeing socket %o %o', socket.constructor.name, opts);
|
||||
socket.destroy();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
debug('Destroying agent %o', this.constructor.name);
|
||||
}
|
||||
}
|
||||
|
||||
// So that `instanceof` works correctly
|
||||
createAgent.prototype = createAgent.Agent.prototype;
|
||||
}
|
||||
|
||||
export = createAgent;
|
||||
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/src/promisify.ts
generated
vendored
Normal file
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/agent-base/src/promisify.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
Agent,
|
||||
ClientRequest,
|
||||
RequestOptions,
|
||||
AgentCallbackCallback,
|
||||
AgentCallbackPromise,
|
||||
AgentCallbackReturn
|
||||
} from './index';
|
||||
|
||||
type LegacyCallback = (
|
||||
req: ClientRequest,
|
||||
opts: RequestOptions,
|
||||
fn: AgentCallbackCallback
|
||||
) => void;
|
||||
|
||||
export default function promisify(fn: LegacyCallback): AgentCallbackPromise {
|
||||
return function(this: Agent, req: ClientRequest, opts: RequestOptions) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn.call(
|
||||
this,
|
||||
req,
|
||||
opts,
|
||||
(err: Error | null | undefined, rtn?: AgentCallbackReturn) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(rtn);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
20
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/LICENSE
generated
vendored
Normal file
20
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) Chad Walker
|
||||
|
||||
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.
|
||||
15
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/README.md
generated
vendored
Normal file
15
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# CSSStyleDeclaration
|
||||
|
||||
A Node JS implementation of the CSS Object Model [CSSStyleDeclaration interface](https://www.w3.org/TR/cssom-1/#the-cssstyledeclaration-interface).
|
||||
|
||||
[](https://www.npmjs.com/package/cssstyle) [](https://travis-ci.org/jsdom/cssstyle) [](https://codecov.io/gh/jsdom/cssstyle)
|
||||
|
||||
---
|
||||
|
||||
#### Background
|
||||
|
||||
This package is an extension of the CSSStyleDeclaration class in Nikita Vasilyev's [CSSOM](https://github.com/NV/CSSOM) with added support for CSS 2 & 3 properties. The primary use case is for testing browser code in a Node environment.
|
||||
|
||||
It was originally created by Chad Walker, it is now maintaind by Jon Sakas and other open source contributors.
|
||||
|
||||
Bug reports and pull requests are welcome.
|
||||
20
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/LICENSE.txt
generated
vendored
Normal file
20
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) Nikita Vasilyev
|
||||
|
||||
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.
|
||||
67
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/README.mdown
generated
vendored
Normal file
67
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/README.mdown
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# CSSOM
|
||||
|
||||
CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of [CSS Object Model](http://dev.w3.org/csswg/cssom/).
|
||||
|
||||
CSSOM.parse("body {color: black}")
|
||||
-> {
|
||||
cssRules: [
|
||||
{
|
||||
selectorText: "body",
|
||||
style: {
|
||||
0: "color",
|
||||
color: "black",
|
||||
length: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## [Parser demo](http://nv.github.com/CSSOM/docs/parse.html)
|
||||
|
||||
Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+.
|
||||
Doesn't work in IE < 9 because of unsupported getters/setters.
|
||||
|
||||
To use CSSOM.js in the browser you might want to build a one-file version that exposes a single `CSSOM` global variable:
|
||||
|
||||
➤ git clone https://github.com/NV/CSSOM.git
|
||||
➤ cd CSSOM
|
||||
➤ node build.js
|
||||
build/CSSOM.js is done
|
||||
|
||||
To use it with Node.js or any other CommonJS loader:
|
||||
|
||||
➤ npm install cssom
|
||||
|
||||
## Don’t use it if...
|
||||
|
||||
You parse CSS to mungle, minify or reformat code like this:
|
||||
|
||||
```css
|
||||
div {
|
||||
background: gray;
|
||||
background: linear-gradient(to bottom, white 0%, black 100%);
|
||||
}
|
||||
```
|
||||
|
||||
This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example).
|
||||
In CSSOM, `background: gray` [gets overwritten](http://nv.github.io/CSSOM/docs/parse.html#css=div%20%7B%0A%20%20%20%20%20%20background%3A%20gray%3B%0A%20%20%20%20background%3A%20linear-gradient(to%20bottom%2C%20white%200%25%2C%20black%20100%25)%3B%0A%7D).
|
||||
It doesn't get preserved.
|
||||
|
||||
If you do CSS mungling, minification, image inlining, and such, CSSOM.js is no good for you, considere using one of the following:
|
||||
|
||||
* [postcss](https://github.com/postcss/postcss)
|
||||
* [reworkcss/css](https://github.com/reworkcss/css)
|
||||
* [csso](https://github.com/css/csso)
|
||||
* [mensch](https://github.com/brettstimmerman/mensch)
|
||||
|
||||
|
||||
## [Tests](http://nv.github.com/CSSOM/spec/)
|
||||
|
||||
To run tests locally:
|
||||
|
||||
➤ git submodule init
|
||||
➤ git submodule update
|
||||
|
||||
|
||||
## [Who uses CSSOM.js](https://github.com/NV/CSSOM/wiki/Who-uses-CSSOM.js)
|
||||
18
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/package.json
generated
vendored
Normal file
18
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/node_modules/cssom/package.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "cssom",
|
||||
"description": "CSS Object Model implementation and CSS parser",
|
||||
"keywords": [
|
||||
"CSS",
|
||||
"CSSOM",
|
||||
"parser",
|
||||
"styleSheet"
|
||||
],
|
||||
"version": "0.3.8",
|
||||
"author": "Nikita Vasilyev <me@elv1s.ru>",
|
||||
"repository": "NV/CSSOM",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"main": "./lib/index.js",
|
||||
"license": "MIT"
|
||||
}
|
||||
72
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/package.json
generated
vendored
Normal file
72
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/cssstyle/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "cssstyle",
|
||||
"description": "CSSStyleDeclaration Object Model implementation",
|
||||
"keywords": [
|
||||
"CSS",
|
||||
"CSSStyleDeclaration",
|
||||
"StyleSheet"
|
||||
],
|
||||
"version": "2.3.0",
|
||||
"homepage": "https://github.com/jsdom/cssstyle",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Jon Sakas",
|
||||
"email": "jon.sakas@gmail.com",
|
||||
"url": "https://jon.sakas.co/"
|
||||
},
|
||||
{
|
||||
"name": "Rafał Ruciński",
|
||||
"email": "fatfisz@gmail.com",
|
||||
"url": "https://fatfisz.com"
|
||||
}
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Chad Walker",
|
||||
"email": "chad@chad-cat-lore-eddie.com",
|
||||
"url": "https://github.com/chad3814"
|
||||
}
|
||||
],
|
||||
"repository": "jsdom/cssstyle",
|
||||
"bugs": "https://github.com/jsdom/cssstyle/issues",
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"main": "./lib/CSSStyleDeclaration.js",
|
||||
"dependencies": {
|
||||
"cssom": "~0.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-generator": "~6.26.1",
|
||||
"babel-traverse": "~6.26.0",
|
||||
"babel-types": "~6.26.0",
|
||||
"babylon": "~6.18.0",
|
||||
"eslint": "~6.0.0",
|
||||
"eslint-config-prettier": "~6.0.0",
|
||||
"eslint-plugin-prettier": "~3.1.0",
|
||||
"jest": "^24.8.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "~1.18.0",
|
||||
"request": "^2.88.0",
|
||||
"resolve": "~1.11.1"
|
||||
},
|
||||
"scripts": {
|
||||
"download": "node ./scripts/download_latest_properties.js && eslint lib/allProperties.js --fix",
|
||||
"generate": "run-p generate:*",
|
||||
"generate:implemented_properties": "node ./scripts/generate_implemented_properties.js",
|
||||
"generate:properties": "node ./scripts/generate_properties.js",
|
||||
"lint": "npm run generate && eslint . --max-warnings 0",
|
||||
"lint:fix": "eslint . --fix --max-warnings 0",
|
||||
"prepublishOnly": "npm run lint && npm run test",
|
||||
"test": "npm run generate && jest",
|
||||
"test-ci": "npm run lint && npm run test && codecov",
|
||||
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
}
|
||||
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/LICENSE.txt
generated
vendored
Normal file
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright © Domenic Denicola <d@domenic.me>
|
||||
|
||||
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.
|
||||
62
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/README.md
generated
vendored
Normal file
62
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/README.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# Parse `data:` URLs
|
||||
|
||||
This package helps you parse `data:` URLs [according to the WHATWG Fetch Standard](https://fetch.spec.whatwg.org/#data-urls):
|
||||
|
||||
```js
|
||||
const parseDataURL = require("data-urls");
|
||||
|
||||
const textExample = parseDataURL("data:,Hello%2C%20World!");
|
||||
console.log(textExample.mimeType.toString()); // "text/plain;charset=US-ASCII"
|
||||
console.log(textExample.body); // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, … ]
|
||||
|
||||
const htmlExample = parseDataURL("data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E");
|
||||
console.log(htmlExample.mimeType.toString()); // "text/html"
|
||||
console.log(htmlExample.body); // Uint8Array(22) [ 60, 104, 49, 62, 72, 101, … ]
|
||||
|
||||
const pngExample = parseDataURL("data:image/png;base64,iVBORw0KGgoAAA" +
|
||||
"ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
|
||||
"//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" +
|
||||
"5ErkJggg==");
|
||||
console.log(pngExample.mimeType.toString()); // "image/png"
|
||||
console.log(pngExample.body); // Uint8Array(85) [ 137, 80, 78, 71, 13, 10, … ]
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package's main module's default export is a function that accepts a string and returns a `{ mimeType, body }` object, or `null` if the result cannot be parsed as a `data:` URL.
|
||||
|
||||
- The `mimeType` property is an instance of [whatwg-mimetype](https://www.npmjs.com/package/whatwg-mimetype)'s `MIMEType` class.
|
||||
- The `body` property is a `Uint8Array` instance.
|
||||
|
||||
As shown in the examples above, you can easily get a stringified version of the MIME type using its `toString()` method. Read on for more on getting the stringified version of the body.
|
||||
|
||||
### Decoding the body
|
||||
|
||||
To decode the body bytes of a parsed data URL, you'll need to use the `charset` parameter of the MIME type, if any. This contains an encoding [label](https://encoding.spec.whatwg.org/#label); there are [various possible labels](https://encoding.spec.whatwg.org/#names-and-labels) for a given encoding. We suggest using the [whatwg-encoding](https://www.npmjs.com/package/whatwg-encoding) package as follows:
|
||||
|
||||
```js
|
||||
const parseDataURL = require("data-urls");
|
||||
const { labelToName, decode } = require("whatwg-encoding");
|
||||
|
||||
const dataURL = parseDataURL(arbitraryString);
|
||||
|
||||
// If there's no charset parameter, let's just hope it's UTF-8; that seems like a good guess.
|
||||
const encodingName = labelToName(dataURL.mimeType.parameters.get("charset") || "utf-8");
|
||||
const bodyDecoded = decode(dataURL.body, encodingName);
|
||||
```
|
||||
|
||||
This is especially important since the default, if no parseable MIME type is given, is "US-ASCII", [aka windows-1252](https://encoding.spec.whatwg.org/#names-and-labels), not UTF-8 like you might asume. So for example given an `arbitraryString` of `"data:,Héllo!"`, the above code snippet will correctly produce a `bodyDecoded` of `"Héllo!"` by using the windows-1252 decoder, whereas if you used a UTF-8 decoder you'd get back `"Héllo!"`.
|
||||
|
||||
### Advanced functionality: parsing from a URL record
|
||||
|
||||
If you are using the [whatwg-url](https://github.com/jsdom/whatwg-url) package, you may already have a "URL record" object on hand, as produced by that package's `parseURL` export. In that case, you can use this package's `fromURLRecord` export to save a bit of work:
|
||||
|
||||
```js
|
||||
const { parseURL } = require("whatwg-url");
|
||||
const dataURLFromURLRecord = require("data-urls").fromURLRecord;
|
||||
|
||||
const urlRecord = parseURL("data:,Hello%2C%20World!");
|
||||
const dataURL = dataURLFromURLRecord(urlRecord);
|
||||
```
|
||||
|
||||
In practice, we expect this functionality only to be used by consumers like [jsdom](https://www.npmjs.com/package/jsdom), which are using these packages at a very low level.
|
||||
54
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/package.json
generated
vendored
Normal file
54
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/data-urls/package.json
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "data-urls",
|
||||
"description": "Parses data: URLs",
|
||||
"keywords": [
|
||||
"data url",
|
||||
"data uri",
|
||||
"data:",
|
||||
"http",
|
||||
"fetch",
|
||||
"whatwg"
|
||||
],
|
||||
"version": "3.0.2",
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/data-urls",
|
||||
"main": "lib/parser.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"coverage": "jest --coverage",
|
||||
"lint": "eslint .",
|
||||
"pretest": "node scripts/get-latest-platform-tests.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"abab": "^2.0.6",
|
||||
"whatwg-mimetype": "^3.0.0",
|
||||
"whatwg-url": "^11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^2.0.0",
|
||||
"eslint": "^8.14.0",
|
||||
"jest": "^27.5.1",
|
||||
"minipass-fetch": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"jest": {
|
||||
"coverageDirectory": "coverage",
|
||||
"coverageReporters": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"<rootDir>/test/**/*.js"
|
||||
],
|
||||
"coveragePathIgnorePatterns": [
|
||||
"<rootDir>/node_modules/(?!(abab/lib/atob.js))"
|
||||
]
|
||||
}
|
||||
}
|
||||
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/LICENSE.txt
generated
vendored
Normal file
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright © Domenic Denicola <d@domenic.me>
|
||||
|
||||
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.
|
||||
40
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/README.md
generated
vendored
Normal file
40
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Determine the Encoding of a HTML Byte Stream
|
||||
|
||||
This package implements the HTML Standard's [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm) in all its glory. The most interesting part of this is how it pre-scans the first 1024 bytes in order to search for certain `<meta charset>`-related patterns.
|
||||
|
||||
```js
|
||||
const htmlEncodingSniffer = require("html-encoding-sniffer");
|
||||
const fs = require("fs");
|
||||
|
||||
const htmlBytes = fs.readFileSync("./html-page.html");
|
||||
const sniffedEncoding = htmlEncodingSniffer(htmlBytes);
|
||||
```
|
||||
|
||||
The passed bytes are given as a `Uint8Array`; the Node.js `Buffer` subclass of `Uint8Array` will also work, as shown above.
|
||||
|
||||
The returned value will be a canonical [encoding name](https://encoding.spec.whatwg.org/#names-and-labels) (not a label). You might then combine this with the [whatwg-encoding](https://github.com/jsdom/whatwg-encoding) package to decode the result:
|
||||
|
||||
```js
|
||||
const whatwgEncoding = require("whatwg-encoding");
|
||||
const htmlString = whatwgEncoding.decode(htmlBytes, sniffedEncoding);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
You can pass two potential options to `htmlEncodingSniffer`:
|
||||
|
||||
```js
|
||||
const sniffedEncoding = htmlEncodingSniffer(htmlBytes, {
|
||||
transportLayerEncodingLabel,
|
||||
defaultEncoding
|
||||
});
|
||||
```
|
||||
|
||||
These represent two possible inputs into the [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm):
|
||||
|
||||
- `transportLayerEncodingLabel` is an encoding label that is obtained from the "transport layer" (probably a HTTP `Content-Type` header), which overrides everything but a BOM.
|
||||
- `defaultEncoding` is the ultimate fallback encoding used if no valid encoding is supplied by the transport layer, and no encoding is sniffed from the bytes. It defaults to `"windows-1252"`, as recommended by the algorithm's table of suggested defaults for "All other locales" (including the `en` locale).
|
||||
|
||||
## Credits
|
||||
|
||||
This package was originally based on the excellent work of [@nicolashenry](https://github.com/nicolashenry), [in jsdom](https://github.com/tmpvar/jsdom/blob/16fd85618f2705d181232f6552125872a37164bc/lib/jsdom/living/helpers/encoding.js). It has since been pulled out into this separate package.
|
||||
31
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/package.json
generated
vendored
Normal file
31
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/html-encoding-sniffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "html-encoding-sniffer",
|
||||
"description": "Sniff the encoding from a HTML byte stream",
|
||||
"keywords": [
|
||||
"encoding",
|
||||
"html"
|
||||
],
|
||||
"version": "3.0.0",
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/html-encoding-sniffer",
|
||||
"main": "lib/html-encoding-sniffer.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"whatwg-encoding": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.4.0",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
74
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/http-proxy-agent/README.md
generated
vendored
Normal file
74
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/http-proxy-agent/README.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
http-proxy-agent
|
||||
================
|
||||
### An HTTP(s) proxy `http.Agent` implementation for HTTP
|
||||
[](https://github.com/TooTallNate/node-http-proxy-agent/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` implementation that connects to a specified
|
||||
HTTP or HTTPS proxy server, and can be used with the built-in `http` module.
|
||||
|
||||
__Note:__ For HTTP proxy usage with the `https` module, check out
|
||||
[`node-https-proxy-agent`](https://github.com/TooTallNate/node-https-proxy-agent).
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install http-proxy-agent
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``` js
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var HttpProxyAgent = require('http-proxy-agent');
|
||||
|
||||
// HTTP/HTTPS proxy to connect to
|
||||
var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// HTTP endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'http://nodejs.org/api/';
|
||||
console.log('attempting to GET %j', endpoint);
|
||||
var opts = url.parse(endpoint);
|
||||
|
||||
// create an instance of the `HttpProxyAgent` class with the proxy server information
|
||||
var agent = new HttpProxyAgent(proxy);
|
||||
opts.agent = agent;
|
||||
|
||||
http.get(opts, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
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.
|
||||
57
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/http-proxy-agent/package.json
generated
vendored
Normal file
57
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/http-proxy-agent/package.json
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "http-proxy-agent",
|
||||
"version": "5.0.0",
|
||||
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTP",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "tsc",
|
||||
"test": "mocha",
|
||||
"test-lint": "eslint src --ext .js,.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-http-proxy-agent.git"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"proxy",
|
||||
"endpoint",
|
||||
"agent"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-http-proxy-agent/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tootallnate/once": "2",
|
||||
"agent-base": "6",
|
||||
"debug": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "4",
|
||||
"@types/node": "^12.19.2",
|
||||
"@typescript-eslint/eslint-plugin": "1.6.0",
|
||||
"@typescript-eslint/parser": "1.1.0",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-airbnb": "17.1.0",
|
||||
"eslint-config-prettier": "4.1.0",
|
||||
"eslint-import-resolver-typescript": "1.1.1",
|
||||
"eslint-plugin-import": "2.16.0",
|
||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"mocha": "^6.2.2",
|
||||
"proxy": "1",
|
||||
"rimraf": "^3.0.0",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
}
|
||||
137
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/https-proxy-agent/README.md
generated
vendored
Normal file
137
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/https-proxy-agent/README.md
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
https-proxy-agent
|
||||
================
|
||||
### An HTTP(s) proxy `http.Agent` implementation for HTTPS
|
||||
[](https://github.com/TooTallNate/node-https-proxy-agent/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` implementation that connects to a specified
|
||||
HTTP or HTTPS proxy server, and can be used with the built-in `https` module.
|
||||
|
||||
Specifically, this `Agent` implementation connects to an intermediary "proxy"
|
||||
server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to
|
||||
open a direct TCP connection to the destination server.
|
||||
|
||||
Since this agent implements the CONNECT HTTP method, it also works with other
|
||||
protocols that use this method when connecting over proxies (i.e. WebSockets).
|
||||
See the "Examples" section below for more.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install https-proxy-agent
|
||||
```
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
#### `https` module example
|
||||
|
||||
``` js
|
||||
var url = require('url');
|
||||
var https = require('https');
|
||||
var HttpsProxyAgent = require('https-proxy-agent');
|
||||
|
||||
// HTTP/HTTPS proxy to connect to
|
||||
var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// HTTPS endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'https://graph.facebook.com/tootallnate';
|
||||
console.log('attempting to GET %j', endpoint);
|
||||
var options = url.parse(endpoint);
|
||||
|
||||
// create an instance of the `HttpsProxyAgent` class with the proxy server information
|
||||
var agent = new HttpsProxyAgent(proxy);
|
||||
options.agent = agent;
|
||||
|
||||
https.get(options, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
#### `ws` WebSocket connection example
|
||||
|
||||
``` js
|
||||
var url = require('url');
|
||||
var WebSocket = require('ws');
|
||||
var HttpsProxyAgent = require('https-proxy-agent');
|
||||
|
||||
// HTTP/HTTPS proxy to connect to
|
||||
var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// WebSocket endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'ws://echo.websocket.org';
|
||||
var parsed = url.parse(endpoint);
|
||||
console.log('attempting to connect to WebSocket %j', endpoint);
|
||||
|
||||
// create an instance of the `HttpsProxyAgent` class with the proxy server information
|
||||
var options = url.parse(proxy);
|
||||
|
||||
var agent = new HttpsProxyAgent(options);
|
||||
|
||||
// finally, initiate the WebSocket connection
|
||||
var socket = new WebSocket(endpoint, { agent: agent });
|
||||
|
||||
socket.on('open', function () {
|
||||
console.log('"open" event!');
|
||||
socket.send('hello world');
|
||||
});
|
||||
|
||||
socket.on('message', function (data, flags) {
|
||||
console.log('"message" event! %j %j', data, flags);
|
||||
socket.close();
|
||||
});
|
||||
```
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
### new HttpsProxyAgent(Object options)
|
||||
|
||||
The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects
|
||||
to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket
|
||||
requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].
|
||||
|
||||
The `options` argument may either be a string URI of the proxy server to use, or an
|
||||
"options" object with more specific properties:
|
||||
|
||||
* `host` - String - Proxy host to connect to (may use `hostname` as well). Required.
|
||||
* `port` - Number - Proxy port to connect to. Required.
|
||||
* `protocol` - String - If `https:`, then use TLS to connect to the proxy.
|
||||
* `headers` - Object - Additional HTTP headers to be sent on the HTTP CONNECT method.
|
||||
* Any other options given are passed to the `net.connect()`/`tls.connect()` functions.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
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.
|
||||
|
||||
[CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling
|
||||
56
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/https-proxy-agent/package.json
generated
vendored
Normal file
56
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/https-proxy-agent/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "https-proxy-agent",
|
||||
"version": "5.0.1",
|
||||
"description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS",
|
||||
"main": "dist/index",
|
||||
"types": "dist/index",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "tsc",
|
||||
"test": "mocha --reporter spec",
|
||||
"test-lint": "eslint src --ext .js,.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-https-proxy-agent.git"
|
||||
},
|
||||
"keywords": [
|
||||
"https",
|
||||
"proxy",
|
||||
"endpoint",
|
||||
"agent"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-https-proxy-agent/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"agent-base": "6",
|
||||
"debug": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "4",
|
||||
"@types/node": "^12.12.11",
|
||||
"@typescript-eslint/eslint-plugin": "1.6.0",
|
||||
"@typescript-eslint/parser": "1.1.0",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-airbnb": "17.1.0",
|
||||
"eslint-config-prettier": "4.1.0",
|
||||
"eslint-import-resolver-typescript": "1.1.1",
|
||||
"eslint-plugin-import": "2.16.0",
|
||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"mocha": "^6.2.2",
|
||||
"proxy": "1",
|
||||
"rimraf": "^3.0.0",
|
||||
"typescript": "^3.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
}
|
||||
22
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/LICENSE.txt
generated
vendored
Normal file
22
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/LICENSE.txt
generated
vendored
Normal file
@@ -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.
|
||||
522
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/README.md
generated
vendored
Normal file
522
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/README.md
generated
vendored
Normal file
@@ -0,0 +1,522 @@
|
||||
<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 Node.js v14 or newer. (Versions of jsdom below v20 still work with previous Node.js versions, but are unsupported.)
|
||||
|
||||
## 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>
|
||||
<script>document.body.appendChild(document.createElement("hr"));</script>
|
||||
</body>`);
|
||||
|
||||
// The script will not be executed, by default:
|
||||
dom.window.document.body.children.length === 1;
|
||||
```
|
||||
|
||||
To enable executing scripts inside the page, you can use the `runScripts: "dangerously"` option:
|
||||
|
||||
```js
|
||||
const dom = new JSDOM(`<body>
|
||||
<script>document.body.appendChild(document.createElement("hr"));</script>
|
||||
</body>`, { runScripts: "dangerously" });
|
||||
|
||||
// The script will be executed and modify the DOM:
|
||||
dom.window.document.body.children.length === 2;
|
||||
```
|
||||
|
||||
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`.)
|
||||
|
||||
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 { window } = new JSDOM(``, { runScripts: "outside-only" });
|
||||
|
||||
window.eval(`document.body.innerHTML = "<p>Hello, world!</p>";`);
|
||||
window.document.body.children.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
|
||||
|
||||
_This resource loader system is new as of jsdom v12.0.0, and we'd love your feedback on whether it meets your needs and how easy it is to use. Please file an issue to discuss!_
|
||||
|
||||
To more fully customize jsdom's resource-loading behavior, you can pass an instance of the `ResourceLoader` class as the `resources` option value:
|
||||
|
||||
```js
|
||||
const resourceLoader = new jsdom.ResourceLoader({
|
||||
proxy: "http://127.0.0.1:9001",
|
||||
strictSSL: false,
|
||||
userAgent: "Mellblomenator/9000",
|
||||
});
|
||||
const dom = new JSDOM(``, { resources: resourceLoader });
|
||||
```
|
||||
|
||||
The three options to the `ResourceLoader` constructor are:
|
||||
|
||||
- `proxy` is the address of an HTTP proxy to be used.
|
||||
- `strictSSL` can be set to false to disable the requirement that SSL certificates be valid.
|
||||
- `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>.
|
||||
|
||||
You can further customize resource fetching by subclassing `ResourceLoader` and overriding the `fetch()` method. For example, here is a version that only returns results for requests to a trusted origin:
|
||||
|
||||
```js
|
||||
class CustomResourceLoader extends jsdom.ResourceLoader {
|
||||
fetch(url, options) {
|
||||
// Override the contents of this script to do something unusual.
|
||||
if (url === "https://example.com/some-specific-script.js") {
|
||||
return Promise.resolve(Buffer.from("window.someGlobal = 5;"));
|
||||
}
|
||||
|
||||
return super.fetch(url, options);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
jsdom will call your custom resource loader's `fetch()` method whenever it encounters a "usable" resource, per the above section. The method takes a URL string, as well as a few options which you should pass through unmodified if calling `super.fetch()`. It must return a promise for a Node.js `Buffer` object, or return `null` if the resource is intentionally not to be loaded. In general, most cases will want to delegate to `super.fetch()`, as shown.
|
||||
|
||||
One of the options you will receive in `fetch()` will be the element (if applicable) that is fetching a resource.
|
||||
|
||||
```js
|
||||
class CustomResourceLoader extends jsdom.ResourceLoader {
|
||||
fetch(url, options) {
|
||||
if (options.element) {
|
||||
console.log(`Element ${options.element.localName} is requesting the url ${url}`);
|
||||
}
|
||||
|
||||
return super.fetch(url, options);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 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, 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. 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.sendTo(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`. So far, the following errors are output this way:
|
||||
|
||||
- Errors loading or parsing subresources (scripts, stylesheets, frames, and iframes)
|
||||
- Script execution errors that are not handled by a window `onerror` event handler that returns `true` or calls `event.preventDefault()`
|
||||
- Not-implemented errors resulting from calls to methods, like `window.alert`, which jsdom does not implement, but installs anyway for web compatibility
|
||||
|
||||
If you're using `sendTo(c)` to send errors to `c`, by default it will call `c.error(errorStack[, errorDetail])` with information from `"jsdomError"` events. If you'd prefer to maintain a strict one-to-one mapping of events to method calls, and perhaps handle `"jsdomError"`s yourself, then you can do
|
||||
|
||||
```js
|
||||
virtualConsole.sendTo(c, { omitJSDOMErrors: true });
|
||||
```
|
||||
|
||||
### 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, or if you are [using jsdom in a web browser](#running-jsdom-inside-a-web-browser).
|
||||
|
||||
### 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 the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s. Since jsdom v13, version 2.x of `canvas` is required; version 1.x is no longer supported.
|
||||
|
||||
### Encoding sniffing
|
||||
|
||||
In addition to supplying a string, the `JSDOM` constructor can also be supplied binary data, in the form of a Node.js [`Buffer`](https://nodejs.org/docs/latest/api/buffer.html) or 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).
|
||||
|
||||
### Running jsdom inside a web browser
|
||||
|
||||
jsdom has some support for being run inside a web browser, using [browserify](https://browserify.org/). That is, inside a web browser, you can use a browserified jsdom to create an entirely self-contained set of plain JavaScript objects which look and act much like the browser's existing DOM objects, while being entirely independent of them. "Virtual DOM", indeed!
|
||||
|
||||
jsdom's primary target is still Node.js, and so we use language features that are only present in recent Node.js versions. Thus, older browsers will likely not work. (Even transpilation will not help: we use `Proxy`s extensively throughout the jsdom codebase.)
|
||||
|
||||
Notably, jsdom works well inside a web worker. The original contributor, [@lawnsea](https://github.com/lawnsea/), who made this possible, has [published a paper](https://pdfs.semanticscholar.org/47f0/6bb6607a975500a30e9e52d7c9fbc0034e27.pdf) about his project which uses this capability.
|
||||
|
||||
Not everything works perfectly when running jsdom inside a web browser. Sometimes that is because of fundamental limitations (such as not having filesystem access), but sometimes it is simply because we haven't spent enough time making the appropriate small tweaks. Bug reports are certainly welcome.
|
||||
|
||||
### 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/viddo/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.
|
||||
|
||||
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/master/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)
|
||||
112
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/package.json
generated
vendored
Normal file
112
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/jsdom/package.json
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"name": "jsdom",
|
||||
"version": "20.0.3",
|
||||
"description": "A JavaScript implementation of many web standards",
|
||||
"keywords": [
|
||||
"dom",
|
||||
"html",
|
||||
"whatwg",
|
||||
"w3c"
|
||||
],
|
||||
"maintainers": [
|
||||
"Elijah Insua <tmpvar@gmail.com> (http://tmpvar.com)",
|
||||
"Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"Sebastian Mayr <sebmaster16@gmail.com> (https://blog.smayr.name/)",
|
||||
"Joris van der Wel <joris@jorisvanderwel.com>",
|
||||
"Timothy Gu <timothygu99@gmail.com> (https://timothygu.me/)",
|
||||
"Magne Andersson <code@zirro.se> (https://zirro.se/)",
|
||||
"Pierre-Marie Dartus <dartus.pierremarie@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/jsdom",
|
||||
"dependencies": {
|
||||
"abab": "^2.0.6",
|
||||
"acorn": "^8.8.1",
|
||||
"acorn-globals": "^7.0.0",
|
||||
"cssom": "^0.5.0",
|
||||
"cssstyle": "^2.3.0",
|
||||
"data-urls": "^3.0.2",
|
||||
"decimal.js": "^10.4.2",
|
||||
"domexception": "^4.0.0",
|
||||
"escodegen": "^2.0.0",
|
||||
"form-data": "^4.0.0",
|
||||
"html-encoding-sniffer": "^3.0.0",
|
||||
"http-proxy-agent": "^5.0.0",
|
||||
"https-proxy-agent": "^5.0.1",
|
||||
"is-potential-custom-element-name": "^1.0.1",
|
||||
"nwsapi": "^2.2.2",
|
||||
"parse5": "^7.1.1",
|
||||
"saxes": "^6.0.0",
|
||||
"symbol-tree": "^3.2.4",
|
||||
"tough-cookie": "^4.1.2",
|
||||
"w3c-xmlserializer": "^4.0.0",
|
||||
"webidl-conversions": "^7.0.0",
|
||||
"whatwg-encoding": "^2.0.0",
|
||||
"whatwg-mimetype": "^3.0.0",
|
||||
"whatwg-url": "^11.0.0",
|
||||
"ws": "^8.11.0",
|
||||
"xml-name-validator": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"canvas": "^2.5.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"canvas": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^3.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserify": "^17.0.0",
|
||||
"chai": "^4.3.7",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-plugin-html": "^7.1.0",
|
||||
"eslint-plugin-jsdom-internal": "link:./scripts/eslint-plugin",
|
||||
"js-yaml": "^4.1.0",
|
||||
"karma": "^6.4.1",
|
||||
"karma-browserify": "^8.1.0",
|
||||
"karma-chrome-launcher": "^3.1.1",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-mocha-webworker": "^1.3.0",
|
||||
"minimatch": "^5.1.0",
|
||||
"mocha": "^10.1.0",
|
||||
"mocha-sugar-free": "^1.4.0",
|
||||
"pngjs": "^6.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"server-destroy": "^1.0.1",
|
||||
"watchify": "^4.0.0",
|
||||
"webidl2js": "^17.1.0",
|
||||
"yargs": "^17.6.2"
|
||||
},
|
||||
"browser": {
|
||||
"canvas": false,
|
||||
"vm": "./lib/jsdom/vm-shim.js",
|
||||
"./lib/jsdom/living/websockets/WebSocket-impl.js": "./lib/jsdom/living/websockets/WebSocket-impl-browser.js"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "yarn convert-idl && yarn generate-js-globals",
|
||||
"pretest": "yarn prepare && yarn init-wpt",
|
||||
"test-wpt": "mocha test/web-platform-tests/run-wpts.js",
|
||||
"test-tuwpt": "mocha test/web-platform-tests/run-tuwpts.js",
|
||||
"test-mocha": "mocha",
|
||||
"test-api": "mocha test/api",
|
||||
"test": "mocha test/index.js",
|
||||
"test-browser-iframe": "karma start test/karma.conf.js",
|
||||
"test-browser-worker": "karma start test/karma-webworker.conf.js",
|
||||
"test-browser": "yarn test-browser-iframe && yarn test-browser-worker",
|
||||
"lint": "eslint . --cache --ext .js,.html",
|
||||
"init-wpt": "git submodule update --init --recursive",
|
||||
"reset-wpt": "rimraf ./test/web-platform-tests/tests && yarn init-wpt",
|
||||
"update-wpt": "git submodule update --recursive --remote && cd test/web-platform-tests/tests && python3 wpt.py manifest --path ../wpt-manifest.json",
|
||||
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS.txt",
|
||||
"benchmark": "node ./benchmark/runner",
|
||||
"benchmark-browser": "node ./benchmark/runner --bundle",
|
||||
"convert-idl": "node ./scripts/webidl/convert.js",
|
||||
"generate-js-globals": "node ./scripts/generate-js-globals.js"
|
||||
},
|
||||
"main": "./lib/api.js",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/LICENSE.md
generated
vendored
Normal file
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sebastian Mayr
|
||||
|
||||
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.
|
||||
78
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/README.md
generated
vendored
Normal file
78
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/README.md
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# tr46
|
||||
|
||||
An JavaScript implementation of [Unicode Technical Standard #46: Unicode IDNA Compatibility Processing](https://unicode.org/reports/tr46/).
|
||||
|
||||
## Installation
|
||||
|
||||
[Node.js](http://nodejs.org) ≥ 12 is required. To install, type this at the command line:
|
||||
|
||||
```shell
|
||||
npm install tr46
|
||||
# or
|
||||
yarn add tr46
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `toASCII(domainName[, options])`
|
||||
|
||||
Converts a string of Unicode symbols to a case-folded Punycode string of ASCII symbols.
|
||||
|
||||
Available options:
|
||||
|
||||
* [`checkBidi`](#checkBidi)
|
||||
* [`checkHyphens`](#checkHyphens)
|
||||
* [`checkJoiners`](#checkJoiners)
|
||||
* [`processingOption`](#processingOption)
|
||||
* [`useSTD3ASCIIRules`](#useSTD3ASCIIRules)
|
||||
* [`verifyDNSLength`](#verifyDNSLength)
|
||||
|
||||
### `toUnicode(domainName[, options])`
|
||||
|
||||
Converts a case-folded Punycode string of ASCII symbols to a string of Unicode symbols.
|
||||
|
||||
Available options:
|
||||
|
||||
* [`checkBidi`](#checkBidi)
|
||||
* [`checkHyphens`](#checkHyphens)
|
||||
* [`checkJoiners`](#checkJoiners)
|
||||
* [`processingOption`](#processingOption)
|
||||
* [`useSTD3ASCIIRules`](#useSTD3ASCIIRules)
|
||||
|
||||
## Options
|
||||
|
||||
### `checkBidi`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, any bi-directional text within the input will be checked for validation.
|
||||
|
||||
### `checkHyphens`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, the positions of any hyphen characters within the input will be checked for validation.
|
||||
|
||||
### `checkJoiners`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, any word joiner characters within the input will be checked for validation.
|
||||
|
||||
### `processingOption`
|
||||
|
||||
Type: `string`
|
||||
Default value: `"nontransitional"`
|
||||
When set to `"transitional"`, symbols within the input will be validated according to the older IDNA2003 protocol. When set to `"nontransitional"`, the current IDNA2008 protocol will be used.
|
||||
|
||||
### `useSTD3ASCIIRules`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, input will be validated according to [STD3 Rules](http://unicode.org/reports/tr46/#STD3_Rules).
|
||||
|
||||
### `verifyDNSLength`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, the length of each DNS label within the input will be checked for validation.
|
||||
298
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/index.js
generated
vendored
Normal file
298
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/index.js
generated
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
"use strict";
|
||||
|
||||
const punycode = require("punycode");
|
||||
const regexes = require("./lib/regexes.js");
|
||||
const mappingTable = require("./lib/mappingTable.json");
|
||||
const { STATUS_MAPPING } = require("./lib/statusMapping.js");
|
||||
|
||||
function containsNonASCII(str) {
|
||||
return /[^\x00-\x7F]/u.test(str);
|
||||
}
|
||||
|
||||
function findStatus(val, { useSTD3ASCIIRules }) {
|
||||
let start = 0;
|
||||
let end = mappingTable.length - 1;
|
||||
|
||||
while (start <= end) {
|
||||
const mid = Math.floor((start + end) / 2);
|
||||
|
||||
const target = mappingTable[mid];
|
||||
const min = Array.isArray(target[0]) ? target[0][0] : target[0];
|
||||
const max = Array.isArray(target[0]) ? target[0][1] : target[0];
|
||||
|
||||
if (min <= val && max >= val) {
|
||||
if (useSTD3ASCIIRules &&
|
||||
(target[1] === STATUS_MAPPING.disallowed_STD3_valid || target[1] === STATUS_MAPPING.disallowed_STD3_mapped)) {
|
||||
return [STATUS_MAPPING.disallowed, ...target.slice(2)];
|
||||
} else if (target[1] === STATUS_MAPPING.disallowed_STD3_valid) {
|
||||
return [STATUS_MAPPING.valid, ...target.slice(2)];
|
||||
} else if (target[1] === STATUS_MAPPING.disallowed_STD3_mapped) {
|
||||
return [STATUS_MAPPING.mapped, ...target.slice(2)];
|
||||
}
|
||||
|
||||
return target.slice(1);
|
||||
} else if (min > val) {
|
||||
end = mid - 1;
|
||||
} else {
|
||||
start = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function mapChars(domainName, { useSTD3ASCIIRules, processingOption }) {
|
||||
let hasError = false;
|
||||
let processed = "";
|
||||
|
||||
for (const ch of domainName) {
|
||||
const [status, mapping] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
|
||||
|
||||
switch (status) {
|
||||
case STATUS_MAPPING.disallowed:
|
||||
hasError = true;
|
||||
processed += ch;
|
||||
break;
|
||||
case STATUS_MAPPING.ignored:
|
||||
break;
|
||||
case STATUS_MAPPING.mapped:
|
||||
processed += mapping;
|
||||
break;
|
||||
case STATUS_MAPPING.deviation:
|
||||
if (processingOption === "transitional") {
|
||||
processed += mapping;
|
||||
} else {
|
||||
processed += ch;
|
||||
}
|
||||
break;
|
||||
case STATUS_MAPPING.valid:
|
||||
processed += ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
string: processed,
|
||||
error: hasError
|
||||
};
|
||||
}
|
||||
|
||||
function validateLabel(label, { checkHyphens, checkBidi, checkJoiners, processingOption, useSTD3ASCIIRules }) {
|
||||
if (label.normalize("NFC") !== label) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const codePoints = Array.from(label);
|
||||
|
||||
if (checkHyphens) {
|
||||
if ((codePoints[2] === "-" && codePoints[3] === "-") ||
|
||||
(label.startsWith("-") || label.endsWith("-"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (label.includes(".") ||
|
||||
(codePoints.length > 0 && regexes.combiningMarks.test(codePoints[0]))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const ch of codePoints) {
|
||||
const [status] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
|
||||
if ((processingOption === "transitional" && status !== STATUS_MAPPING.valid) ||
|
||||
(processingOption === "nontransitional" &&
|
||||
status !== STATUS_MAPPING.valid && status !== STATUS_MAPPING.deviation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc5892#appendix-A
|
||||
if (checkJoiners) {
|
||||
let last = 0;
|
||||
for (const [i, ch] of codePoints.entries()) {
|
||||
if (ch === "\u200C" || ch === "\u200D") {
|
||||
if (i > 0) {
|
||||
if (regexes.combiningClassVirama.test(codePoints[i - 1])) {
|
||||
continue;
|
||||
}
|
||||
if (ch === "\u200C") {
|
||||
// TODO: make this more efficient
|
||||
const next = codePoints.indexOf("\u200C", i + 1);
|
||||
const test = next < 0 ? codePoints.slice(last) : codePoints.slice(last, next);
|
||||
if (regexes.validZWNJ.test(test.join(""))) {
|
||||
last = i + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc5893#section-2
|
||||
if (checkBidi) {
|
||||
let rtl;
|
||||
|
||||
// 1
|
||||
if (regexes.bidiS1LTR.test(codePoints[0])) {
|
||||
rtl = false;
|
||||
} else if (regexes.bidiS1RTL.test(codePoints[0])) {
|
||||
rtl = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rtl) {
|
||||
// 2-4
|
||||
if (!regexes.bidiS2.test(label) ||
|
||||
!regexes.bidiS3.test(label) ||
|
||||
(regexes.bidiS4EN.test(label) && regexes.bidiS4AN.test(label))) {
|
||||
return false;
|
||||
}
|
||||
} else if (!regexes.bidiS5.test(label) ||
|
||||
!regexes.bidiS6.test(label)) { // 5-6
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isBidiDomain(labels) {
|
||||
const domain = labels.map(label => {
|
||||
if (label.startsWith("xn--")) {
|
||||
try {
|
||||
return punycode.decode(label.substring(4));
|
||||
} catch (err) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}).join(".");
|
||||
return regexes.bidiDomain.test(domain);
|
||||
}
|
||||
|
||||
function processing(domainName, options) {
|
||||
const { processingOption } = options;
|
||||
|
||||
// 1. Map.
|
||||
let { string, error } = mapChars(domainName, options);
|
||||
|
||||
// 2. Normalize.
|
||||
string = string.normalize("NFC");
|
||||
|
||||
// 3. Break.
|
||||
const labels = string.split(".");
|
||||
const isBidi = isBidiDomain(labels);
|
||||
|
||||
// 4. Convert/Validate.
|
||||
for (const [i, origLabel] of labels.entries()) {
|
||||
let label = origLabel;
|
||||
let curProcessing = processingOption;
|
||||
if (label.startsWith("xn--")) {
|
||||
try {
|
||||
label = punycode.decode(label.substring(4));
|
||||
labels[i] = label;
|
||||
} catch (err) {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
curProcessing = "nontransitional";
|
||||
}
|
||||
|
||||
// No need to validate if we already know there is an error.
|
||||
if (error) {
|
||||
continue;
|
||||
}
|
||||
const validation = validateLabel(label, {
|
||||
...options,
|
||||
processingOption: curProcessing,
|
||||
checkBidi: options.checkBidi && isBidi
|
||||
});
|
||||
if (!validation) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
string: labels.join("."),
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
function toASCII(domainName, {
|
||||
checkHyphens = false,
|
||||
checkBidi = false,
|
||||
checkJoiners = false,
|
||||
useSTD3ASCIIRules = false,
|
||||
processingOption = "nontransitional",
|
||||
verifyDNSLength = false
|
||||
} = {}) {
|
||||
if (processingOption !== "transitional" && processingOption !== "nontransitional") {
|
||||
throw new RangeError("processingOption must be either transitional or nontransitional");
|
||||
}
|
||||
|
||||
const result = processing(domainName, {
|
||||
processingOption,
|
||||
checkHyphens,
|
||||
checkBidi,
|
||||
checkJoiners,
|
||||
useSTD3ASCIIRules
|
||||
});
|
||||
let labels = result.string.split(".");
|
||||
labels = labels.map(l => {
|
||||
if (containsNonASCII(l)) {
|
||||
try {
|
||||
return `xn--${punycode.encode(l)}`;
|
||||
} catch (e) {
|
||||
result.error = true;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
});
|
||||
|
||||
if (verifyDNSLength) {
|
||||
const total = labels.join(".").length;
|
||||
if (total > 253 || total === 0) {
|
||||
result.error = true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < labels.length; ++i) {
|
||||
if (labels[i].length > 63 || labels[i].length === 0) {
|
||||
result.error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
return null;
|
||||
}
|
||||
return labels.join(".");
|
||||
}
|
||||
|
||||
function toUnicode(domainName, {
|
||||
checkHyphens = false,
|
||||
checkBidi = false,
|
||||
checkJoiners = false,
|
||||
useSTD3ASCIIRules = false,
|
||||
processingOption = "nontransitional"
|
||||
} = {}) {
|
||||
const result = processing(domainName, {
|
||||
processingOption,
|
||||
checkHyphens,
|
||||
checkBidi,
|
||||
checkJoiners,
|
||||
useSTD3ASCIIRules
|
||||
});
|
||||
|
||||
return {
|
||||
domain: result.string,
|
||||
error: result.error
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
toASCII,
|
||||
toUnicode
|
||||
};
|
||||
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/package.json
generated
vendored
Normal file
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/tr46/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "tr46",
|
||||
"version": "3.0.0",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"description": "An implementation of the Unicode UTS #46: Unicode IDNA Compatibility Processing",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/mappingTable.json",
|
||||
"lib/regexes.js",
|
||||
"lib/statusMapping.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"lint": "eslint .",
|
||||
"pretest": "node scripts/getLatestTests.js",
|
||||
"prepublish": "node scripts/generateMappingTable.js && node scripts/generateRegexes.js"
|
||||
},
|
||||
"repository": "https://github.com/jsdom/tr46",
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"tr46",
|
||||
"uts46",
|
||||
"punycode",
|
||||
"url",
|
||||
"whatwg"
|
||||
],
|
||||
"author": "Sebastian Mayr <npm@smayr.name>",
|
||||
"contributors": [
|
||||
"Timothy Gu <timothygu99@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"punycode": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.4.0",
|
||||
"@unicode/unicode-14.0.0": "^1.2.1",
|
||||
"eslint": "^7.32.0",
|
||||
"minipass-fetch": "^1.4.1",
|
||||
"mocha": "^9.1.1",
|
||||
"regenerate": "^1.4.2"
|
||||
},
|
||||
"unicodeVersion": "14.0.0"
|
||||
}
|
||||
25
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/LICENSE.md
generated
vendored
Normal file
25
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © Sebastian Mayr
|
||||
|
||||
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.
|
||||
41
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/README.md
generated
vendored
Normal file
41
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# w3c-xmlserializer
|
||||
|
||||
An XML serializer that follows the [W3C specification](https://w3c.github.io/DOM-Parsing/).
|
||||
|
||||
This package can be used in Node.js, as long as you feed it a DOM node, e.g. one produced by [jsdom](https://github.com/jsdom/jsdom).
|
||||
|
||||
## Basic usage
|
||||
|
||||
Assume you have a DOM tree rooted at a node `node`. In Node.js, you could create this using [jsdom](https://github.com/jsdom/jsdom) as follows:
|
||||
|
||||
```js
|
||||
const { JSDOM } = require("jsdom");
|
||||
|
||||
const { document } = new JSDOM().window;
|
||||
const node = document.createElement("akomaNtoso");
|
||||
```
|
||||
|
||||
Then, you use this package as follows:
|
||||
|
||||
|
||||
```js
|
||||
const serialize = require("w3c-xmlserializer");
|
||||
|
||||
console.log(serialize(node));
|
||||
// => '<akomantoso xmlns="http://www.w3.org/1999/xhtml"></akomantoso>'
|
||||
```
|
||||
|
||||
## `requireWellFormed` option
|
||||
|
||||
By default the input DOM tree is not required to be "well-formed"; any given input will serialize to some output string. You can instead require well-formedness via
|
||||
|
||||
```js
|
||||
serialize(node, { requireWellFormed: true });
|
||||
```
|
||||
|
||||
which will cause `Error`s to be thrown when non-well-formed constructs are encountered. [Per the spec](https://w3c.github.io/DOM-Parsing/#dfn-require-well-formed), this largely is about imposing constraints on the names of elements, attributes, etc.
|
||||
|
||||
As a point of reference, on the web platform:
|
||||
|
||||
* The [`innerHTML` getter](https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml) uses the require-well-formed mode, i.e. trying to get the `innerHTML` of non-well-formed subtrees will throw.
|
||||
* The [`xhr.send()` method](https://xhr.spec.whatwg.org/#the-send()-method) does not require well-formedness, i.e. sending non-well-formed `Document`s will serialize and send them anyway.
|
||||
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/package.json
generated
vendored
Normal file
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/w3c-xmlserializer/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "w3c-xmlserializer",
|
||||
"description": "A per-spec XML serializer implementation",
|
||||
"keywords": [
|
||||
"dom",
|
||||
"w3c",
|
||||
"xml",
|
||||
"xmlserializer"
|
||||
],
|
||||
"version": "4.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xml-name-validator": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^3.0.0",
|
||||
"eslint": "^8.28.0",
|
||||
"jest": "^29.3.1",
|
||||
"jsdom": "^20.0.2"
|
||||
},
|
||||
"repository": "jsdom/w3c-xmlserializer",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"main": "lib/serialize.js",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/LICENSE.txt
generated
vendored
Normal file
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright © Domenic Denicola <d@domenic.me>
|
||||
|
||||
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.
|
||||
50
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/README.md
generated
vendored
Normal file
50
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Decode According to the WHATWG Encoding Standard
|
||||
|
||||
This package provides a thin layer on top of [iconv-lite](https://github.com/ashtuchkin/iconv-lite) which makes it expose some of the same primitives as the [Encoding Standard](https://encoding.spec.whatwg.org/).
|
||||
|
||||
```js
|
||||
const whatwgEncoding = require("whatwg-encoding");
|
||||
|
||||
console.assert(whatwgEncoding.labelToName("latin1") === "windows-1252");
|
||||
console.assert(whatwgEncoding.labelToName(" CYRILLic ") === "ISO-8859-5");
|
||||
|
||||
console.assert(whatwgEncoding.isSupported("IBM866") === true);
|
||||
|
||||
// Not supported by the Encoding Standard
|
||||
console.assert(whatwgEncoding.isSupported("UTF-32") === false);
|
||||
|
||||
// In the Encoding Standard, but this package can't decode it
|
||||
console.assert(whatwgEncoding.isSupported("x-mac-cyrillic") === false);
|
||||
|
||||
console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0xFE, 0xFF])) === "UTF-16BE");
|
||||
console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0x48, 0x69])) === null);
|
||||
|
||||
console.assert(whatwgEncoding.decode(new Uint8Array([0x48, 0x69]), "UTF-8") === "Hi");
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
- `decode(uint8Array, fallbackEncodingName)`: performs the [decode](https://encoding.spec.whatwg.org/#decode) algorithm (in which any BOM will override the passed fallback encoding), and returns the resulting string
|
||||
- `labelToName(label)`: performs the [get an encoding](https://encoding.spec.whatwg.org/#concept-encoding-get) algorithm and returns the resulting encoding's name, or `null` for failure
|
||||
- `isSupported(name)`: returns whether the encoding is one of [the encodings](https://encoding.spec.whatwg.org/#names-and-labels) of the Encoding Standard, _and_ is an encoding that this package can decode (via iconv-lite)
|
||||
- `getBOMEncoding(uint8Array)`: sniffs the first 2–3 bytes of the supplied `Uint8Array`, returning one of the encoding names `"UTF-8"`, `"UTF-16LE"`, or `"UTF-16BE"` if the appropriate BOM is present, or `null` if no BOM is present
|
||||
|
||||
## Unsupported encodings
|
||||
|
||||
Since we rely on iconv-lite, we are limited to support only the encodings that they support. Currently we are missing support for:
|
||||
|
||||
- ISO-2022-JP
|
||||
- ISO-8859-8-I
|
||||
- replacement
|
||||
- x-mac-cyrillic
|
||||
- x-user-defined
|
||||
|
||||
Passing these encoding names will return `false` when calling `isSupported`, and passing any of the possible labels for these encodings to `labelToName` will return `null`.
|
||||
|
||||
## Credits
|
||||
|
||||
This package was originally based on the excellent work of [@nicolashenry](https://github.com/nicolashenry), [in jsdom](https://github.com/tmpvar/jsdom/blob/7ce11776ce161e8d5921a7a183585327400f786b/lib/jsdom/living/helpers/encoding.js). It has since been pulled out into this separate package.
|
||||
|
||||
## Alternatives
|
||||
|
||||
If you are looking for a JavaScript implementation of the Encoding Standard's `TextEncoder` and `TextDecoder` APIs, you'll want [@inexorabletash](https://github.com/inexorabletash)'s [text-encoding](https://github.com/inexorabletash/text-encoding) package. Node.js also has them [built-in](https://nodejs.org/dist/latest/docs/api/globals.html#globals_textdecoder).
|
||||
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/package.json
generated
vendored
Normal file
33
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-encoding/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "whatwg-encoding",
|
||||
"description": "Decode strings according to the WHATWG Encoding Standard",
|
||||
"keywords": [
|
||||
"encoding",
|
||||
"whatwg"
|
||||
],
|
||||
"version": "2.0.0",
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/whatwg-encoding",
|
||||
"main": "lib/whatwg-encoding.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"lint": "eslint .",
|
||||
"prepare": "node scripts/update.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"iconv-lite": "0.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.3.0",
|
||||
"eslint": "^7.32.0",
|
||||
"minipass-fetch": "^1.4.1",
|
||||
"mocha": "^9.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/LICENSE.txt
generated
vendored
Normal file
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright © Domenic Denicola <d@domenic.me>
|
||||
|
||||
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.
|
||||
101
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/README.md
generated
vendored
Normal file
101
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/README.md
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
# Parse, serialize, and manipulate MIME types
|
||||
|
||||
This package will parse [MIME types](https://mimesniff.spec.whatwg.org/#understanding-mime-types) into a structured format, which can then be manipulated and serialized:
|
||||
|
||||
```js
|
||||
const MIMEType = require("whatwg-mimetype");
|
||||
|
||||
const mimeType = new MIMEType(`Text/HTML;Charset="utf-8"`);
|
||||
|
||||
console.assert(mimeType.toString() === "text/html;charset=utf-8");
|
||||
|
||||
console.assert(mimeType.type === "text");
|
||||
console.assert(mimeType.subtype === "html");
|
||||
console.assert(mimeType.essence === "text/html");
|
||||
console.assert(mimeType.parameters.get("charset") === "utf-8");
|
||||
|
||||
mimeType.parameters.set("charset", "windows-1252");
|
||||
console.assert(mimeType.parameters.get("charset") === "windows-1252");
|
||||
console.assert(mimeType.toString() === "text/html;charset=windows-1252");
|
||||
|
||||
console.assert(mimeType.isHTML() === true);
|
||||
console.assert(mimeType.isXML() === false);
|
||||
```
|
||||
|
||||
Parsing is a fairly complex process; see [the specification](https://mimesniff.spec.whatwg.org/#parsing-a-mime-type) for details (and similarly [for serialization](https://mimesniff.spec.whatwg.org/#serializing-a-mime-type)).
|
||||
|
||||
This package's algorithms conform to those of the WHATWG [MIME Sniffing Standard](https://mimesniff.spec.whatwg.org/), and is aligned up to commit [8e9a7dd](https://github.com/whatwg/mimesniff/commit/8e9a7dd90717c595a4e4d982cd216e4411d33736).
|
||||
|
||||
## `MIMEType` API
|
||||
|
||||
This package's main module's default export is a class, `MIMEType`. Its constructor takes a string which it will attempt to parse into a MIME type; if parsing fails, an `Error` will be thrown.
|
||||
|
||||
### The `parse()` static factory method
|
||||
|
||||
As an alternative to the constructor, you can use `MIMEType.parse(string)`. The only difference is that `parse()` will return `null` on failed parsing, whereas the constructor will throw. It thus makes the most sense to use the constructor in cases where unparseable MIME types would be exceptional, and use `parse()` when dealing with input from some unconstrained source.
|
||||
|
||||
### Properties
|
||||
|
||||
- `type`: the MIME type's [type](https://mimesniff.spec.whatwg.org/#mime-type-type), e.g. `"text"`
|
||||
- `subtype`: the MIME type's [subtype](https://mimesniff.spec.whatwg.org/#mime-type-subtype), e.g. `"html"`
|
||||
- `essence`: the MIME type's [essence](https://mimesniff.spec.whatwg.org/#mime-type-essence), e.g. `"text/html"`
|
||||
- `parameters`: an instance of `MIMETypeParameters`, containing this MIME type's [parameters](https://mimesniff.spec.whatwg.org/#mime-type-parameters)
|
||||
|
||||
`type` and `subtype` can be changed. They will be validated to be non-empty and only contain [HTTP token code points](https://mimesniff.spec.whatwg.org/#http-token-code-point).
|
||||
|
||||
`essence` is only a getter, and cannot be changed.
|
||||
|
||||
`parameters` is also a getter, but the contents of the `MIMETypeParameters` object are mutable, as described below.
|
||||
|
||||
### Methods
|
||||
|
||||
- `toString()` serializes the MIME type to a string
|
||||
- `isHTML()`: returns true if this instance represents [a HTML MIME type](https://mimesniff.spec.whatwg.org/#html-mime-type)
|
||||
- `isXML()`: returns true if this instance represents [an XML MIME type](https://mimesniff.spec.whatwg.org/#xml-mime-type)
|
||||
- `isJavaScript({ prohibitParameters })`: returns true if this instance represents [a JavaScript MIME type](https://html.spec.whatwg.org/multipage/scripting.html#javascript-mime-type). `prohibitParameters` can be set to true to disallow any parameters, i.e. to test if the MIME type's serialization is a [JavaScript MIME type essence match](https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match).
|
||||
|
||||
_Note: the `isHTML()`, `isXML()`, and `isJavaScript()` methods are speculative, and may be removed or changed in future major versions. See [whatwg/mimesniff#48](https://github.com/whatwg/mimesniff/issues/48) for brainstorming in this area. Currently we implement these mainly because they are useful in jsdom._
|
||||
|
||||
## `MIMETypeParameters` API
|
||||
|
||||
The `MIMETypeParameters` class, instances of which are returned by `mimeType.parameters`, has equivalent surface API to a [JavaScript `Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
|
||||
|
||||
However, `MIMETypeParameters` methods will always interpret their arguments as appropriate for MIME types, so e.g. parameter names will be lowercased, and attempting to set invalid characters will throw.
|
||||
|
||||
Some examples:
|
||||
|
||||
```js
|
||||
const mimeType = new MIMEType(`x/x;a=b;c=D;E="F"`);
|
||||
|
||||
// Logs:
|
||||
// a b
|
||||
// c D
|
||||
// e F
|
||||
for (const [name, value] of mimeType.parameters) {
|
||||
console.log(name, value);
|
||||
}
|
||||
|
||||
console.assert(mimeType.parameters.has("a"));
|
||||
console.assert(mimeType.parameters.has("A"));
|
||||
console.assert(mimeType.parameters.get("A") === "b");
|
||||
|
||||
mimeType.parameters.set("Q", "X");
|
||||
console.assert(mimeType.parameters.get("q") === "X");
|
||||
console.assert(mimeType.toString() === "x/x;a=b;c=d;e=F;q=X");
|
||||
|
||||
// Throws:
|
||||
mimeType.parameters.set("@", "x");
|
||||
```
|
||||
|
||||
## Raw parsing/serialization APIs
|
||||
|
||||
If you want primitives on which to build your own API, you can get direct access to the parsing and serialization algorithms as follows:
|
||||
|
||||
```js
|
||||
const parse = require("whatwg-mimetype/parser");
|
||||
const serialize = require("whatwg-mimetype/serialize");
|
||||
```
|
||||
|
||||
`parse(string)` returns an object containing the `type` and `subtype` strings, plus `parameters`, which is a `Map`. This is roughly our equivalent of the spec's [MIME type record](https://mimesniff.spec.whatwg.org/#mime-type). If parsing fails, it instead returns `null`.
|
||||
|
||||
`serialize(record)` operates on the such an object, giving back a string according to the serialization algorithm.
|
||||
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/package.json
generated
vendored
Normal file
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-mimetype/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "whatwg-mimetype",
|
||||
"description": "Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard",
|
||||
"keywords": [
|
||||
"content-type",
|
||||
"mime type",
|
||||
"mimesniff",
|
||||
"http",
|
||||
"whatwg"
|
||||
],
|
||||
"version": "3.0.0",
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/whatwg-mimetype",
|
||||
"main": "lib/mime-type.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"coverage": "jest --coverage",
|
||||
"lint": "eslint .",
|
||||
"pretest": "node scripts/get-latest-platform-tests.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.4.0",
|
||||
"eslint": "^7.32.0",
|
||||
"jest": "^27.2.0",
|
||||
"minipass-fetch": "^1.4.1",
|
||||
"printable-string": "^0.3.0",
|
||||
"whatwg-encoding": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"jest": {
|
||||
"coverageDirectory": "coverage",
|
||||
"coverageReporters": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"<rootDir>/test/**/*.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/LICENSE.txt
generated
vendored
Normal file
21
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sebastian Mayr
|
||||
|
||||
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.
|
||||
106
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/README.md
generated
vendored
Normal file
106
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/README.md
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
# whatwg-url
|
||||
|
||||
whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spec.whatwg.org/). It can be used standalone, but it also exposes a lot of the internal algorithms that are useful for integrating a URL parser into a project like [jsdom](https://github.com/jsdom/jsdom).
|
||||
|
||||
## Specification conformance
|
||||
|
||||
whatwg-url is currently up to date with the URL spec up to commit [43c2713](https://github.com/whatwg/url/commit/43c27137a0bc82c4b800fe74be893255fbeb35f4).
|
||||
|
||||
For `file:` URLs, whose [origin is left unspecified](https://url.spec.whatwg.org/#concept-url-origin), whatwg-url chooses to use a new opaque origin (which serializes to `"null"`).
|
||||
|
||||
whatwg-url does not yet implement any encoding handling beyond UTF-8. That is, the _encoding override_ parameter does not exist in our API.
|
||||
|
||||
## API
|
||||
|
||||
### The `URL` and `URLSearchParams` classes
|
||||
|
||||
The main API is provided by the [`URL`](https://url.spec.whatwg.org/#url-class) and [`URLSearchParams`](https://url.spec.whatwg.org/#interface-urlsearchparams) exports, which follows the spec's behavior in all ways (including e.g. `USVString` conversion). Most consumers of this library will want to use these.
|
||||
|
||||
### Low-level URL Standard API
|
||||
|
||||
The following methods are exported for use by places like jsdom that need to implement things like [`HTMLHyperlinkElementUtils`](https://html.spec.whatwg.org/#htmlhyperlinkelementutils). They mostly operate on or return an "internal URL" or ["URL record"](https://url.spec.whatwg.org/#concept-url) type.
|
||||
|
||||
- [URL parser](https://url.spec.whatwg.org/#concept-url-parser): `parseURL(input, { baseURL })`
|
||||
- [Basic URL parser](https://url.spec.whatwg.org/#concept-basic-url-parser): `basicURLParse(input, { baseURL, url, stateOverride })`
|
||||
- [URL serializer](https://url.spec.whatwg.org/#concept-url-serializer): `serializeURL(urlRecord, excludeFragment)`
|
||||
- [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)`
|
||||
- [URL path serializer](https://url.spec.whatwg.org/#url-path-serializer): `serializePath(urlRecord)`
|
||||
- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`
|
||||
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin): `serializeURLOrigin(urlRecord)`
|
||||
- [Set the username](https://url.spec.whatwg.org/#set-the-username): `setTheUsername(urlRecord, usernameString)`
|
||||
- [Set the password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)`
|
||||
- [Has an opaque path](https://url.spec.whatwg.org/#url-opaque-path): `hasAnOpaquePath(urlRecord)`
|
||||
- [Cannot have a username/password/port](https://url.spec.whatwg.org/#cannot-have-a-username-password-port): `cannotHaveAUsernamePasswordPort(urlRecord)`
|
||||
- [Percent decode bytes](https://url.spec.whatwg.org/#percent-decode): `percentDecodeBytes(uint8Array)`
|
||||
- [Percent decode a string](https://url.spec.whatwg.org/#percent-decode-string): `percentDecodeString(string)`
|
||||
|
||||
The `stateOverride` parameter is one of the following strings:
|
||||
|
||||
- [`"scheme start"`](https://url.spec.whatwg.org/#scheme-start-state)
|
||||
- [`"scheme"`](https://url.spec.whatwg.org/#scheme-state)
|
||||
- [`"no scheme"`](https://url.spec.whatwg.org/#no-scheme-state)
|
||||
- [`"special relative or authority"`](https://url.spec.whatwg.org/#special-relative-or-authority-state)
|
||||
- [`"path or authority"`](https://url.spec.whatwg.org/#path-or-authority-state)
|
||||
- [`"relative"`](https://url.spec.whatwg.org/#relative-state)
|
||||
- [`"relative slash"`](https://url.spec.whatwg.org/#relative-slash-state)
|
||||
- [`"special authority slashes"`](https://url.spec.whatwg.org/#special-authority-slashes-state)
|
||||
- [`"special authority ignore slashes"`](https://url.spec.whatwg.org/#special-authority-ignore-slashes-state)
|
||||
- [`"authority"`](https://url.spec.whatwg.org/#authority-state)
|
||||
- [`"host"`](https://url.spec.whatwg.org/#host-state)
|
||||
- [`"hostname"`](https://url.spec.whatwg.org/#hostname-state)
|
||||
- [`"port"`](https://url.spec.whatwg.org/#port-state)
|
||||
- [`"file"`](https://url.spec.whatwg.org/#file-state)
|
||||
- [`"file slash"`](https://url.spec.whatwg.org/#file-slash-state)
|
||||
- [`"file host"`](https://url.spec.whatwg.org/#file-host-state)
|
||||
- [`"path start"`](https://url.spec.whatwg.org/#path-start-state)
|
||||
- [`"path"`](https://url.spec.whatwg.org/#path-state)
|
||||
- [`"opaque path"`](https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state)
|
||||
- [`"query"`](https://url.spec.whatwg.org/#query-state)
|
||||
- [`"fragment"`](https://url.spec.whatwg.org/#fragment-state)
|
||||
|
||||
The URL record type has the following API:
|
||||
|
||||
- [`scheme`](https://url.spec.whatwg.org/#concept-url-scheme)
|
||||
- [`username`](https://url.spec.whatwg.org/#concept-url-username)
|
||||
- [`password`](https://url.spec.whatwg.org/#concept-url-password)
|
||||
- [`host`](https://url.spec.whatwg.org/#concept-url-host)
|
||||
- [`port`](https://url.spec.whatwg.org/#concept-url-port)
|
||||
- [`path`](https://url.spec.whatwg.org/#concept-url-path) (as an array of strings, or a string)
|
||||
- [`query`](https://url.spec.whatwg.org/#concept-url-query)
|
||||
- [`fragment`](https://url.spec.whatwg.org/#concept-url-fragment)
|
||||
|
||||
These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of `basicURLParse` is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like "4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse _input_ with context object’s url as _url_ and fragment state as _state override_." In between those two steps, a URL record is in an unusable state.
|
||||
|
||||
The return value of "failure" in the spec is represented by `null`. That is, functions like `parseURL` and `basicURLParse` can return _either_ a URL record _or_ `null`.
|
||||
|
||||
### `whatwg-url/webidl2js-wrapper` module
|
||||
|
||||
This module exports the `URL` and `URLSearchParams` [interface wrappers API](https://github.com/jsdom/webidl2js#for-interfaces) generated by [webidl2js](https://github.com/jsdom/webidl2js).
|
||||
|
||||
## Development instructions
|
||||
|
||||
First, install [Node.js](https://nodejs.org/). Then, fetch the dependencies of whatwg-url, by running from this directory:
|
||||
|
||||
npm install
|
||||
|
||||
To run tests:
|
||||
|
||||
npm test
|
||||
|
||||
To generate a coverage report:
|
||||
|
||||
npm run coverage
|
||||
|
||||
To build and run the live viewer:
|
||||
|
||||
npm run prepare
|
||||
npm run build-live-viewer
|
||||
|
||||
Serve the contents of the `live-viewer` directory using any web server.
|
||||
|
||||
## Supporting whatwg-url
|
||||
|
||||
The jsdom project (including whatwg-url) is a community-driven project maintained by a team of [volunteers](https://github.com/orgs/jsdom/people). You could support us by:
|
||||
|
||||
- [Getting professional support for whatwg-url](https://tidelift.com/subscription/pkg/npm-whatwg-url?utm_source=npm-whatwg-url&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 directly to the project.
|
||||
27
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/index.js
generated
vendored
Normal file
27
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/index.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
const { URL, URLSearchParams } = require("./webidl2js-wrapper");
|
||||
const urlStateMachine = require("./lib/url-state-machine");
|
||||
const percentEncoding = require("./lib/percent-encoding");
|
||||
|
||||
const sharedGlobalObject = { Array, Object, Promise, String, TypeError };
|
||||
URL.install(sharedGlobalObject, ["Window"]);
|
||||
URLSearchParams.install(sharedGlobalObject, ["Window"]);
|
||||
|
||||
exports.URL = sharedGlobalObject.URL;
|
||||
exports.URLSearchParams = sharedGlobalObject.URLSearchParams;
|
||||
|
||||
exports.parseURL = urlStateMachine.parseURL;
|
||||
exports.basicURLParse = urlStateMachine.basicURLParse;
|
||||
exports.serializeURL = urlStateMachine.serializeURL;
|
||||
exports.serializePath = urlStateMachine.serializePath;
|
||||
exports.serializeHost = urlStateMachine.serializeHost;
|
||||
exports.serializeInteger = urlStateMachine.serializeInteger;
|
||||
exports.serializeURLOrigin = urlStateMachine.serializeURLOrigin;
|
||||
exports.setTheUsername = urlStateMachine.setTheUsername;
|
||||
exports.setThePassword = urlStateMachine.setThePassword;
|
||||
exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
|
||||
exports.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
|
||||
|
||||
exports.percentDecodeString = percentEncoding.percentDecodeString;
|
||||
exports.percentDecodeBytes = percentEncoding.percentDecodeBytes;
|
||||
58
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/package.json
generated
vendored
Normal file
58
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "whatwg-url",
|
||||
"version": "11.0.0",
|
||||
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"webidl2js-wrapper.js",
|
||||
"lib/*.js"
|
||||
],
|
||||
"author": "Sebastian Mayr <github@smayr.name>",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/whatwg-url",
|
||||
"dependencies": {
|
||||
"tr46": "^3.0.0",
|
||||
"webidl-conversions": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.4.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserify": "^17.0.0",
|
||||
"domexception": "^4.0.0",
|
||||
"eslint": "^7.32.0",
|
||||
"got": "^11.8.2",
|
||||
"jest": "^27.2.4",
|
||||
"webidl2js": "^17.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "jest --coverage",
|
||||
"lint": "eslint .",
|
||||
"prepare": "node scripts/transform.js",
|
||||
"pretest": "node scripts/get-latest-platform-tests.js && node scripts/transform.js",
|
||||
"build-live-viewer": "browserify index.js --standalone whatwgURL > live-viewer/whatwg-url.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverageFrom": [
|
||||
"lib/**/*.js",
|
||||
"!lib/utils.js"
|
||||
],
|
||||
"coverageDirectory": "coverage",
|
||||
"coverageReporters": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"<rootDir>/test/**/*.js"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"^<rootDir>/test/testharness.js$",
|
||||
"^<rootDir>/test/web-platform-tests/"
|
||||
]
|
||||
}
|
||||
}
|
||||
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/webidl2js-wrapper.js
generated
vendored
Normal file
7
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/whatwg-url/webidl2js-wrapper.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const URL = require("./lib/URL");
|
||||
const URLSearchParams = require("./lib/URLSearchParams");
|
||||
|
||||
exports.URL = URL;
|
||||
exports.URLSearchParams = URLSearchParams;
|
||||
176
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/LICENSE.txt
generated
vendored
Normal file
176
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
35
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/README.md
generated
vendored
Normal file
35
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Validate XML Names and Qualified Names
|
||||
|
||||
This package simply tells you whether or not a string matches the [`Name`](http://www.w3.org/TR/xml/#NT-Name) or [`QName`](http://www.w3.org/TR/xml-names/#NT-QName) productions in the XML Namespaces specification. We use it for implementing the [validate](https://dom.spec.whatwg.org/#validate) algorithm in jsdom, but you can use it for whatever you want.
|
||||
|
||||
## Usage
|
||||
|
||||
This package's main module exports two functions, `name()` and `qname()`. Both take a string and return a boolean indicating whether or not the string matches the relevant production.
|
||||
|
||||
```js
|
||||
"use strict":
|
||||
const xnv = require("xml-name-validator");
|
||||
|
||||
// Will return true
|
||||
xnv.name("x");
|
||||
xnv.name(":");
|
||||
xnv.name("a:0");
|
||||
xnv.name("a:b:c");
|
||||
|
||||
// Will return false
|
||||
xnv.name("\\");
|
||||
xnv.name("'");
|
||||
xnv.name("0");
|
||||
xnv.name("a!");
|
||||
|
||||
// Will return true
|
||||
xnv.qname("x");
|
||||
xnv.qname("a0");
|
||||
xnv.qname("a:b");
|
||||
|
||||
// Will return false
|
||||
xnv.qname(":a");
|
||||
xnv.qname(":b");
|
||||
xnv.qname("a:b:c");
|
||||
xnv.qname("a:0");
|
||||
```
|
||||
30
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/package.json
generated
vendored
Normal file
30
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/node_modules/xml-name-validator/package.json
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "xml-name-validator",
|
||||
"description": "Validates whether a string matches the production for an XML name or qualified name",
|
||||
"keywords": [
|
||||
"xml",
|
||||
"name",
|
||||
"qname"
|
||||
],
|
||||
"version": "4.0.0",
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "Apache-2.0",
|
||||
"repository": "jsdom/xml-name-validator",
|
||||
"main": "lib/xml-name-validator.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.4.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/package.json
generated
vendored
Normal file
47
capabilities/testdrive-jsui/node_modules/jest-environment-jsdom/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "jest-environment-jsdom",
|
||||
"version": "29.7.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-environment-jsdom"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/environment": "^29.7.0",
|
||||
"@jest/fake-timers": "^29.7.0",
|
||||
"@jest/types": "^29.6.3",
|
||||
"@types/jsdom": "^20.0.0",
|
||||
"@types/node": "*",
|
||||
"jest-mock": "^29.7.0",
|
||||
"jest-util": "^29.7.0",
|
||||
"jsdom": "^20.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/test-utils": "^29.7.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"canvas": "^2.5.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"canvas": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
|
||||
}
|
||||
Reference in New Issue
Block a user