Implement QuotaExceededError as a DOMException-derived interface per the WebIDL specification update. QuotaExceededError is now a proper constructor exposed as a global [Exposed=*] interface that extends DOMException with optional `quota` and `requested` attributes (both nullable doubles, defaulting to null). The constructor validates that quota and requested are finite, non-negative, and that requested is not less than quota when both are provided. QuotaExceededError is [Serializable] and supports structuredClone, preserving the quota and requested values across the serialization boundary. Callers updated: - crypto.getRandomValues() now throws a QuotaExceededError instance - WebStorage (C++) now constructs QuotaExceededError directly Refs: https://redirect.github.com/whatwg/webidl/pull/1465 Fixes: https://github.com/nodejs/node/issues/58987 PR-URL: https://github.com/nodejs/node/pull/62293 Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
110 lines
3.2 KiB
JavaScript
110 lines
3.2 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* This file exposes web interfaces that is defined with the WebIDL
|
|
* [Exposed=*] extended attribute.
|
|
* See more details at https://webidl.spec.whatwg.org/#Exposed.
|
|
*/
|
|
|
|
const {
|
|
globalThis,
|
|
} = primordials;
|
|
|
|
const {
|
|
exposeInterface,
|
|
exposeLazyInterfaces,
|
|
exposeNamespace,
|
|
} = require('internal/util');
|
|
const config = internalBinding('config');
|
|
const { exposeLazyDOMExceptionProperty } = internalBinding('messaging');
|
|
|
|
// https://console.spec.whatwg.org/#console-namespace
|
|
exposeNamespace(globalThis, 'console',
|
|
createGlobalConsole());
|
|
|
|
const { URL, URLSearchParams } = require('internal/url');
|
|
// https://url.spec.whatwg.org/#url
|
|
exposeInterface(globalThis, 'URL', URL);
|
|
// https://url.spec.whatwg.org/#urlsearchparams
|
|
exposeInterface(globalThis, 'URLSearchParams', URLSearchParams);
|
|
exposeLazyDOMExceptionProperty(globalThis);
|
|
|
|
// https://webidl.spec.whatwg.org/#quotaexceedederror
|
|
exposeLazyInterfaces(globalThis, 'internal/worker/clone_dom_exception', [
|
|
'QuotaExceededError',
|
|
]);
|
|
|
|
// https://dom.spec.whatwg.org/#interface-abortcontroller
|
|
// Lazy ones.
|
|
exposeLazyInterfaces(globalThis, 'internal/abort_controller', [
|
|
'AbortController', 'AbortSignal',
|
|
]);
|
|
// https://dom.spec.whatwg.org/#interface-eventtarget
|
|
const {
|
|
EventTarget, Event,
|
|
} = require('internal/event_target');
|
|
exposeInterface(globalThis, 'Event', Event);
|
|
exposeInterface(globalThis, 'EventTarget', EventTarget);
|
|
exposeLazyInterfaces(globalThis, 'internal/event_target', ['CustomEvent']);
|
|
|
|
// https://encoding.spec.whatwg.org/#textencoder
|
|
// https://encoding.spec.whatwg.org/#textdecoder
|
|
exposeLazyInterfaces(globalThis,
|
|
'internal/encoding',
|
|
['TextEncoder', 'TextDecoder']);
|
|
|
|
function createGlobalConsole() {
|
|
const consoleFromNode =
|
|
require('internal/console/global');
|
|
if (config.hasInspector) {
|
|
const inspector = require('internal/util/inspector');
|
|
// TODO(joyeecheung): postpone this until the first time inspector
|
|
// is activated.
|
|
inspector.wrapConsole(consoleFromNode);
|
|
const { setConsoleExtensionInstaller } = internalBinding('inspector');
|
|
// Setup inspector command line API.
|
|
setConsoleExtensionInstaller(inspector.installConsoleExtensions);
|
|
}
|
|
return consoleFromNode;
|
|
}
|
|
|
|
// Web Streams API
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/transformstream',
|
|
['TransformStream', 'TransformStreamDefaultController']);
|
|
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/writablestream',
|
|
['WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter']);
|
|
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/readablestream',
|
|
[
|
|
'ReadableStream', 'ReadableStreamDefaultReader',
|
|
'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest',
|
|
'ReadableByteStreamController', 'ReadableStreamDefaultController',
|
|
]);
|
|
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/queuingstrategies',
|
|
[
|
|
'ByteLengthQueuingStrategy', 'CountQueuingStrategy',
|
|
]);
|
|
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/encoding',
|
|
[
|
|
'TextEncoderStream', 'TextDecoderStream',
|
|
]);
|
|
|
|
exposeLazyInterfaces(
|
|
globalThis,
|
|
'internal/webstreams/compression',
|
|
[
|
|
'CompressionStream', 'DecompressionStream',
|
|
]);
|