mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 05:14:21 -05:00
refactor(ext/web): align error messages (#25871)
Aligns the error messages in the ext/web folder to be in-line with the Deno style guide.
This commit is contained in:
parent
c1dcf1b618
commit
b78c851a94
11 changed files with 86 additions and 80 deletions
|
@ -271,7 +271,7 @@ function addPaddingToBase64url(base64url) {
|
||||||
if (base64url.length % 4 === 2) return base64url + "==";
|
if (base64url.length % 4 === 2) return base64url + "==";
|
||||||
if (base64url.length % 4 === 3) return base64url + "=";
|
if (base64url.length % 4 === 3) return base64url + "=";
|
||||||
if (base64url.length % 4 === 1) {
|
if (base64url.length % 4 === 1) {
|
||||||
throw new TypeError("Illegal base64url string!");
|
throw new TypeError("Illegal base64url string");
|
||||||
}
|
}
|
||||||
return base64url;
|
return base64url;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ function assert(cond, msg = "Assertion failed.") {
|
||||||
function serializeJSValueToJSONString(value) {
|
function serializeJSValueToJSONString(value) {
|
||||||
const result = JSONStringify(value);
|
const result = JSONStringify(value);
|
||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
throw new TypeError("Value is not JSON serializable.");
|
throw new TypeError("Value is not JSON serializable");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ function pathFromURLWin32(url) {
|
||||||
*/
|
*/
|
||||||
function pathFromURLPosix(url) {
|
function pathFromURLPosix(url) {
|
||||||
if (url.hostname !== "") {
|
if (url.hostname !== "") {
|
||||||
throw new TypeError(`Host must be empty.`);
|
throw new TypeError("Host must be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
return decodeURIComponent(
|
return decodeURIComponent(
|
||||||
|
@ -444,7 +444,7 @@ function pathFromURLPosix(url) {
|
||||||
function pathFromURL(pathOrUrl) {
|
function pathFromURL(pathOrUrl) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(URLPrototype, pathOrUrl)) {
|
if (ObjectPrototypeIsPrototypeOf(URLPrototype, pathOrUrl)) {
|
||||||
if (pathOrUrl.protocol != "file:") {
|
if (pathOrUrl.protocol != "file:") {
|
||||||
throw new TypeError("Must be a file URL.");
|
throw new TypeError("Must be a file URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
return core.build.os == "windows"
|
return core.build.os == "windows"
|
||||||
|
|
|
@ -1031,11 +1031,11 @@ class EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDispatched(event)) {
|
if (getDispatched(event)) {
|
||||||
throw new DOMException("Invalid event state.", "InvalidStateError");
|
throw new DOMException("Invalid event state", "InvalidStateError");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.eventPhase !== Event.NONE) {
|
if (event.eventPhase !== Event.NONE) {
|
||||||
throw new DOMException("Invalid event state.", "InvalidStateError");
|
throw new DOMException("Invalid event state", "InvalidStateError");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dispatch(self, event);
|
return dispatch(self, event);
|
||||||
|
|
|
@ -196,7 +196,7 @@ class AbortSignal extends EventTarget {
|
||||||
|
|
||||||
constructor(key = null) {
|
constructor(key = null) {
|
||||||
if (key !== illegalConstructorKey) {
|
if (key !== illegalConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ const illegalConstructorKey = Symbol("illegalConstructorKey");
|
||||||
class Window extends EventTarget {
|
class Window extends EventTarget {
|
||||||
constructor(key = null) {
|
constructor(key = null) {
|
||||||
if (key !== illegalConstructorKey) {
|
if (key !== illegalConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class Window extends EventTarget {
|
||||||
class WorkerGlobalScope extends EventTarget {
|
class WorkerGlobalScope extends EventTarget {
|
||||||
constructor(key = null) {
|
constructor(key = null) {
|
||||||
if (key != illegalConstructorKey) {
|
if (key != illegalConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class WorkerGlobalScope extends EventTarget {
|
||||||
class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
||||||
constructor(key = null) {
|
constructor(key = null) {
|
||||||
if (key != illegalConstructorKey) {
|
if (key != illegalConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ function btoa(data) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"The string to be encoded contains characters outside of the Latin1 range.",
|
"Cannot encode string: string contains characters outside of the Latin1 range",
|
||||||
"InvalidCharacterError",
|
"InvalidCharacterError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,10 +523,14 @@ function dequeueValue(container) {
|
||||||
function enqueueValueWithSize(container, value, size) {
|
function enqueueValueWithSize(container, value, size) {
|
||||||
assert(container[_queue] && typeof container[_queueTotalSize] === "number");
|
assert(container[_queue] && typeof container[_queueTotalSize] === "number");
|
||||||
if (isNonNegativeNumber(size) === false) {
|
if (isNonNegativeNumber(size) === false) {
|
||||||
throw new RangeError("chunk size isn't a positive number");
|
throw new RangeError(
|
||||||
|
"Cannot enqueue value with size: chunk size must be a positive number",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (size === Infinity) {
|
if (size === Infinity) {
|
||||||
throw new RangeError("chunk size is invalid");
|
throw new RangeError(
|
||||||
|
"Cannot enqueue value with size: chunk size is invalid",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
container[_queue].enqueue({ value, size });
|
container[_queue].enqueue({ value, size });
|
||||||
container[_queueTotalSize] += size;
|
container[_queueTotalSize] += size;
|
||||||
|
@ -1097,7 +1101,7 @@ async function readableStreamCollectIntoUint8Array(stream) {
|
||||||
|
|
||||||
if (TypedArrayPrototypeGetSymbolToStringTag(chunk) !== "Uint8Array") {
|
if (TypedArrayPrototypeGetSymbolToStringTag(chunk) !== "Uint8Array") {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"Can't convert value to Uint8Array while consuming the stream",
|
"Cannot convert value to Uint8Array while consuming the stream",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,7 +1351,7 @@ function readableByteStreamControllerEnqueue(controller, chunk) {
|
||||||
|
|
||||||
if (isDetachedBuffer(buffer)) {
|
if (isDetachedBuffer(buffer)) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"chunk's buffer is detached and so cannot be enqueued",
|
"Chunk's buffer is detached and so cannot be enqueued",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const transferredBuffer = ArrayBufferPrototypeTransferToFixedLength(buffer);
|
const transferredBuffer = ArrayBufferPrototypeTransferToFixedLength(buffer);
|
||||||
|
@ -2095,14 +2099,14 @@ function readableByteStreamControllerRespond(controller, bytesWritten) {
|
||||||
if (state === "closed") {
|
if (state === "closed") {
|
||||||
if (bytesWritten !== 0) {
|
if (bytesWritten !== 0) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"bytesWritten must be 0 when calling respond() on a closed stream",
|
`"bytesWritten" must be 0 when calling respond() on a closed stream: received ${bytesWritten}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(state === "readable");
|
assert(state === "readable");
|
||||||
if (bytesWritten === 0) {
|
if (bytesWritten === 0) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"bytesWritten must be greater than 0 when calling respond() on a readable stream",
|
'"bytesWritten" must be greater than 0 when calling respond() on a readable stream',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -2110,7 +2114,7 @@ function readableByteStreamControllerRespond(controller, bytesWritten) {
|
||||||
// deno-lint-ignore prefer-primordials
|
// deno-lint-ignore prefer-primordials
|
||||||
firstDescriptor.byteLength
|
firstDescriptor.byteLength
|
||||||
) {
|
) {
|
||||||
throw new RangeError("bytesWritten out of range");
|
throw new RangeError('"bytesWritten" out of range');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
firstDescriptor.buffer = ArrayBufferPrototypeTransferToFixedLength(
|
firstDescriptor.buffer = ArrayBufferPrototypeTransferToFixedLength(
|
||||||
|
@ -2305,7 +2309,7 @@ function readableByteStreamControllerRespondWithNewView(controller, view) {
|
||||||
if (state === "closed") {
|
if (state === "closed") {
|
||||||
if (byteLength !== 0) {
|
if (byteLength !== 0) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"The view's length must be 0 when calling respondWithNewView() on a closed stream",
|
`The view's length must be 0 when calling respondWithNewView() on a closed stream: received ${byteLength}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3577,7 +3581,7 @@ function setUpReadableByteStreamControllerFromUnderlyingSource(
|
||||||
}
|
}
|
||||||
const autoAllocateChunkSize = underlyingSourceDict["autoAllocateChunkSize"];
|
const autoAllocateChunkSize = underlyingSourceDict["autoAllocateChunkSize"];
|
||||||
if (autoAllocateChunkSize === 0) {
|
if (autoAllocateChunkSize === 0) {
|
||||||
throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
throw new TypeError('"autoAllocateChunkSize" must be greater than 0');
|
||||||
}
|
}
|
||||||
setUpReadableByteStreamController(
|
setUpReadableByteStreamController(
|
||||||
stream,
|
stream,
|
||||||
|
@ -3706,7 +3710,7 @@ function setUpReadableStreamDefaultControllerFromUnderlyingSource(
|
||||||
*/
|
*/
|
||||||
function setUpReadableStreamBYOBReader(reader, stream) {
|
function setUpReadableStreamBYOBReader(reader, stream) {
|
||||||
if (isReadableStreamLocked(stream)) {
|
if (isReadableStreamLocked(stream)) {
|
||||||
throw new TypeError("ReadableStream is locked.");
|
throw new TypeError("ReadableStream is locked");
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!(ObjectPrototypeIsPrototypeOf(
|
!(ObjectPrototypeIsPrototypeOf(
|
||||||
|
@ -3727,7 +3731,7 @@ function setUpReadableStreamBYOBReader(reader, stream) {
|
||||||
*/
|
*/
|
||||||
function setUpReadableStreamDefaultReader(reader, stream) {
|
function setUpReadableStreamDefaultReader(reader, stream) {
|
||||||
if (isReadableStreamLocked(stream)) {
|
if (isReadableStreamLocked(stream)) {
|
||||||
throw new TypeError("ReadableStream is locked.");
|
throw new TypeError("ReadableStream is locked");
|
||||||
}
|
}
|
||||||
readableStreamReaderGenericInitialize(reader, stream);
|
readableStreamReaderGenericInitialize(reader, stream);
|
||||||
reader[_readRequests] = new Queue();
|
reader[_readRequests] = new Queue();
|
||||||
|
@ -3961,7 +3965,7 @@ function setUpWritableStreamDefaultControllerFromUnderlyingSink(
|
||||||
*/
|
*/
|
||||||
function setUpWritableStreamDefaultWriter(writer, stream) {
|
function setUpWritableStreamDefaultWriter(writer, stream) {
|
||||||
if (isWritableStreamLocked(stream) === true) {
|
if (isWritableStreamLocked(stream) === true) {
|
||||||
throw new TypeError("The stream is already locked.");
|
throw new TypeError("The stream is already locked");
|
||||||
}
|
}
|
||||||
writer[_stream] = stream;
|
writer[_stream] = stream;
|
||||||
stream[_writer] = writer;
|
stream[_writer] = writer;
|
||||||
|
@ -4019,7 +4023,7 @@ function transformStreamDefaultControllerEnqueue(controller, chunk) {
|
||||||
/** @type {ReadableStreamDefaultController<O>} */ readableController,
|
/** @type {ReadableStreamDefaultController<O>} */ readableController,
|
||||||
) === false
|
) === false
|
||||||
) {
|
) {
|
||||||
throw new TypeError("Readable stream is unavailable.");
|
throw new TypeError("Readable stream is unavailable");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
readableStreamDefaultControllerEnqueue(
|
readableStreamDefaultControllerEnqueue(
|
||||||
|
@ -5143,7 +5147,7 @@ class ReadableStream {
|
||||||
if (underlyingSourceDict.type === "bytes") {
|
if (underlyingSourceDict.type === "bytes") {
|
||||||
if (strategy.size !== undefined) {
|
if (strategy.size !== undefined) {
|
||||||
throw new RangeError(
|
throw new RangeError(
|
||||||
`${prefix}: When underlying source is "bytes", strategy.size must be undefined.`,
|
`${prefix}: When underlying source is "bytes", strategy.size must be 'undefined'`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const highWaterMark = extractHighWaterMark(strategy, 0);
|
const highWaterMark = extractHighWaterMark(strategy, 0);
|
||||||
|
@ -5273,10 +5277,10 @@ class ReadableStream {
|
||||||
const { readable, writable } = transform;
|
const { readable, writable } = transform;
|
||||||
const { preventClose, preventAbort, preventCancel, signal } = options;
|
const { preventClose, preventAbort, preventCancel, signal } = options;
|
||||||
if (isReadableStreamLocked(this)) {
|
if (isReadableStreamLocked(this)) {
|
||||||
throw new TypeError("ReadableStream is already locked.");
|
throw new TypeError("ReadableStream is already locked");
|
||||||
}
|
}
|
||||||
if (isWritableStreamLocked(writable)) {
|
if (isWritableStreamLocked(writable)) {
|
||||||
throw new TypeError("Target WritableStream is already locked.");
|
throw new TypeError("Target WritableStream is already locked");
|
||||||
}
|
}
|
||||||
const promise = readableStreamPipeTo(
|
const promise = readableStreamPipeTo(
|
||||||
this,
|
this,
|
||||||
|
@ -5814,7 +5818,7 @@ class ReadableByteStreamController {
|
||||||
}
|
}
|
||||||
if (this[_stream][_state] !== "readable") {
|
if (this[_stream][_state] !== "readable") {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"ReadableByteStreamController's stream is not in a readable state.",
|
"ReadableByteStreamController's stream is not in a readable state",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
readableByteStreamControllerClose(this);
|
readableByteStreamControllerClose(this);
|
||||||
|
@ -5846,7 +5850,7 @@ class ReadableByteStreamController {
|
||||||
if (byteLength === 0) {
|
if (byteLength === 0) {
|
||||||
throw webidl.makeException(
|
throw webidl.makeException(
|
||||||
TypeError,
|
TypeError,
|
||||||
"length must be non-zero",
|
"Length must be non-zero",
|
||||||
prefix,
|
prefix,
|
||||||
arg1,
|
arg1,
|
||||||
);
|
);
|
||||||
|
@ -5854,19 +5858,19 @@ class ReadableByteStreamController {
|
||||||
if (getArrayBufferByteLength(buffer) === 0) {
|
if (getArrayBufferByteLength(buffer) === 0) {
|
||||||
throw webidl.makeException(
|
throw webidl.makeException(
|
||||||
TypeError,
|
TypeError,
|
||||||
"buffer length must be non-zero",
|
"Buffer length must be non-zero",
|
||||||
prefix,
|
prefix,
|
||||||
arg1,
|
arg1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this[_closeRequested] === true) {
|
if (this[_closeRequested] === true) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"Cannot enqueue chunk after a close has been requested.",
|
"Cannot enqueue chunk after a close has been requested",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this[_stream][_state] !== "readable") {
|
if (this[_stream][_state] !== "readable") {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"Cannot enqueue chunk when underlying stream is not readable.",
|
"Cannot enqueue chunk when underlying stream is not readable",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return readableByteStreamControllerEnqueue(this, chunk);
|
return readableByteStreamControllerEnqueue(this, chunk);
|
||||||
|
@ -6006,7 +6010,7 @@ class ReadableStreamDefaultController {
|
||||||
close() {
|
close() {
|
||||||
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
|
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
|
||||||
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
|
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
|
||||||
throw new TypeError("The stream controller cannot close or enqueue.");
|
throw new TypeError("The stream controller cannot close or enqueue");
|
||||||
}
|
}
|
||||||
readableStreamDefaultControllerClose(this);
|
readableStreamDefaultControllerClose(this);
|
||||||
}
|
}
|
||||||
|
@ -6021,7 +6025,7 @@ class ReadableStreamDefaultController {
|
||||||
chunk = webidl.converters.any(chunk);
|
chunk = webidl.converters.any(chunk);
|
||||||
}
|
}
|
||||||
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
|
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
|
||||||
throw new TypeError("The stream controller cannot close or enqueue.");
|
throw new TypeError("The stream controller cannot close or enqueue");
|
||||||
}
|
}
|
||||||
readableStreamDefaultControllerEnqueue(this, chunk);
|
readableStreamDefaultControllerEnqueue(this, chunk);
|
||||||
}
|
}
|
||||||
|
@ -6146,12 +6150,12 @@ class TransformStream {
|
||||||
);
|
);
|
||||||
if (transformerDict.readableType !== undefined) {
|
if (transformerDict.readableType !== undefined) {
|
||||||
throw new RangeError(
|
throw new RangeError(
|
||||||
`${prefix}: readableType transformers not supported.`,
|
`${prefix}: readableType transformers not supported`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (transformerDict.writableType !== undefined) {
|
if (transformerDict.writableType !== undefined) {
|
||||||
throw new RangeError(
|
throw new RangeError(
|
||||||
`${prefix}: writableType transformers not supported.`,
|
`${prefix}: writableType transformers not supported`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const readableHighWaterMark = extractHighWaterMark(readableStrategy, 0);
|
const readableHighWaterMark = extractHighWaterMark(readableStrategy, 0);
|
||||||
|
@ -6356,7 +6360,7 @@ class WritableStream {
|
||||||
);
|
);
|
||||||
if (underlyingSinkDict.type != null) {
|
if (underlyingSinkDict.type != null) {
|
||||||
throw new RangeError(
|
throw new RangeError(
|
||||||
`${prefix}: WritableStream does not support 'type' in the underlying sink.`,
|
`${prefix}: WritableStream does not support 'type' in the underlying sink`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
initializeWritableStream(this);
|
initializeWritableStream(this);
|
||||||
|
@ -6483,7 +6487,7 @@ class WritableStreamDefaultWriter {
|
||||||
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
|
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
|
||||||
if (this[_stream] === undefined) {
|
if (this[_stream] === undefined) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"A writable stream is not associated with the writer.",
|
"A writable stream is not associated with the writer",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return writableStreamDefaultWriterGetDesiredSize(this);
|
return writableStreamDefaultWriterGetDesiredSize(this);
|
||||||
|
|
|
@ -65,7 +65,7 @@ class FileReader extends EventTarget {
|
||||||
// 1. If fr's state is "loading", throw an InvalidStateError DOMException.
|
// 1. If fr's state is "loading", throw an InvalidStateError DOMException.
|
||||||
if (this[state] === "loading") {
|
if (this[state] === "loading") {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Invalid FileReader state.",
|
"Invalid FileReader state",
|
||||||
"InvalidStateError",
|
"InvalidStateError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const locationConstructorKey = Symbol("locationConstructorKey");
|
||||||
class Location {
|
class Location {
|
||||||
constructor(href = null, key = null) {
|
constructor(href = null, key = null) {
|
||||||
if (key != locationConstructorKey) {
|
if (key != locationConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
const url = new URL(href);
|
const url = new URL(href);
|
||||||
url.username = "";
|
url.username = "";
|
||||||
|
@ -41,7 +41,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.hash".`,
|
`Cannot set "location.hash"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -54,7 +54,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.host".`,
|
`Cannot set "location.host"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -67,7 +67,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.hostname".`,
|
`Cannot set "location.hostname"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -80,7 +80,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.href".`,
|
`Cannot set "location.href"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -100,7 +100,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.pathname".`,
|
`Cannot set "location.pathname"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -113,7 +113,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.port".`,
|
`Cannot set "location.port"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -126,7 +126,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.protocol".`,
|
`Cannot set "location.protocol"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -139,7 +139,7 @@ class Location {
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot set "location.search".`,
|
`Cannot set "location.search"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -161,7 +161,7 @@ class Location {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
value: function assign() {
|
value: function assign() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot call "location.assign()".`,
|
`Cannot call "location.assign()"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -171,7 +171,7 @@ class Location {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
value: function reload() {
|
value: function reload() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot call "location.reload()".`,
|
`Cannot call "location.reload()"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -181,7 +181,7 @@ class Location {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
value: function replace() {
|
value: function replace() {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot call "location.replace()".`,
|
`Cannot call "location.replace()"`,
|
||||||
"NotSupportedError",
|
"NotSupportedError",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -229,7 +229,7 @@ const workerLocationUrls = new SafeWeakMap();
|
||||||
class WorkerLocation {
|
class WorkerLocation {
|
||||||
constructor(href = null, key = null) {
|
constructor(href = null, key = null) {
|
||||||
if (key != locationConstructorKey) {
|
if (key != locationConstructorKey) {
|
||||||
throw new TypeError("Illegal constructor.");
|
throw new TypeError("Illegal constructor");
|
||||||
}
|
}
|
||||||
const url = new URL(href);
|
const url = new URL(href);
|
||||||
url.username = "";
|
url.username = "";
|
||||||
|
@ -244,7 +244,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.hash;
|
return url.hash;
|
||||||
},
|
},
|
||||||
|
@ -256,7 +256,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.host;
|
return url.host;
|
||||||
},
|
},
|
||||||
|
@ -268,7 +268,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.hostname;
|
return url.hostname;
|
||||||
},
|
},
|
||||||
|
@ -280,7 +280,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.href;
|
return url.href;
|
||||||
},
|
},
|
||||||
|
@ -292,7 +292,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.origin;
|
return url.origin;
|
||||||
},
|
},
|
||||||
|
@ -304,7 +304,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.pathname;
|
return url.pathname;
|
||||||
},
|
},
|
||||||
|
@ -316,7 +316,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.port;
|
return url.port;
|
||||||
},
|
},
|
||||||
|
@ -328,7 +328,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.protocol;
|
return url.protocol;
|
||||||
},
|
},
|
||||||
|
@ -340,7 +340,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
get() {
|
get() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.search;
|
return url.search;
|
||||||
},
|
},
|
||||||
|
@ -352,7 +352,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
||||||
value: function toString() {
|
value: function toString() {
|
||||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new TypeError("Illegal invocation.");
|
throw new TypeError("Illegal invocation");
|
||||||
}
|
}
|
||||||
return url.href;
|
return url.href;
|
||||||
},
|
},
|
||||||
|
@ -414,7 +414,7 @@ const locationDescriptor = {
|
||||||
return location;
|
return location;
|
||||||
},
|
},
|
||||||
set() {
|
set() {
|
||||||
throw new DOMException(`Cannot set "location".`, "NotSupportedError");
|
throw new DOMException(`Cannot set "location"`, "NotSupportedError");
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
};
|
};
|
||||||
|
@ -422,7 +422,7 @@ const workerLocationDescriptor = {
|
||||||
get() {
|
get() {
|
||||||
if (workerLocation == null) {
|
if (workerLocation == null) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Assertion: "globalThis.location" must be defined in a worker.`,
|
`Assertion: "globalThis.location" must be defined in a worker`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return workerLocation;
|
return workerLocation;
|
||||||
|
|
|
@ -123,14 +123,14 @@ function convertMarkToTimestamp(mark) {
|
||||||
const entry = findMostRecent(mark, "mark");
|
const entry = findMostRecent(mark, "mark");
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
`Cannot find mark: "${mark}".`,
|
`Cannot find mark: "${mark}"`,
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return entry.startTime;
|
return entry.startTime;
|
||||||
}
|
}
|
||||||
if (mark < 0) {
|
if (mark < 0) {
|
||||||
throw new TypeError("Mark cannot be negative.");
|
throw new TypeError(`Mark cannot be negative: received ${mark}`);
|
||||||
}
|
}
|
||||||
return mark;
|
return mark;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,9 @@ class PerformanceMark extends PerformanceEntry {
|
||||||
super(name, "mark", startTime, 0, illegalConstructorKey);
|
super(name, "mark", startTime, 0, illegalConstructorKey);
|
||||||
this[webidl.brand] = webidl.brand;
|
this[webidl.brand] = webidl.brand;
|
||||||
if (startTime < 0) {
|
if (startTime < 0) {
|
||||||
throw new TypeError("startTime cannot be negative");
|
throw new TypeError(
|
||||||
|
`Cannot construct PerformanceMark: startTime cannot be negative, received ${startTime}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this[_detail] = structuredClone(detail);
|
this[_detail] = structuredClone(detail);
|
||||||
}
|
}
|
||||||
|
@ -504,14 +506,14 @@ class Performance extends EventTarget {
|
||||||
ObjectKeys(startOrMeasureOptions).length > 0
|
ObjectKeys(startOrMeasureOptions).length > 0
|
||||||
) {
|
) {
|
||||||
if (endMark) {
|
if (endMark) {
|
||||||
throw new TypeError("Options cannot be passed with endMark.");
|
throw new TypeError('Options cannot be passed with "endMark"');
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!ReflectHas(startOrMeasureOptions, "start") &&
|
!ReflectHas(startOrMeasureOptions, "start") &&
|
||||||
!ReflectHas(startOrMeasureOptions, "end")
|
!ReflectHas(startOrMeasureOptions, "end")
|
||||||
) {
|
) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"A start or end mark must be supplied in options.",
|
'A "start" or "end" mark must be supplied in options',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -520,7 +522,7 @@ class Performance extends EventTarget {
|
||||||
ReflectHas(startOrMeasureOptions, "end")
|
ReflectHas(startOrMeasureOptions, "end")
|
||||||
) {
|
) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"Cannot specify start, end, and duration together in options.",
|
'Cannot specify "start", "end", and "duration" together in options',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,35 +84,35 @@ class ImageData {
|
||||||
|
|
||||||
if (dataLength === 0) {
|
if (dataLength === 0) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The input data has zero elements.",
|
"Failed to construct 'ImageData': the input data has zero elements",
|
||||||
"InvalidStateError",
|
"InvalidStateError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataLength % 4 !== 0) {
|
if (dataLength % 4 !== 0) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The input data length is not a multiple of 4.",
|
`Failed to construct 'ImageData': the input data length is not a multiple of 4, received ${dataLength}`,
|
||||||
"InvalidStateError",
|
"InvalidStateError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceWidth < 1) {
|
if (sourceWidth < 1) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The source width is zero or not a number.",
|
"Failed to construct 'ImageData': the source width is zero or not a number",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webidl.type(sourceHeight) !== "Undefined" && sourceHeight < 1) {
|
if (webidl.type(sourceHeight) !== "Undefined" && sourceHeight < 1) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The source height is zero or not a number.",
|
"Failed to construct 'ImageData': the source height is zero or not a number",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataLength / 4 % sourceWidth !== 0) {
|
if (dataLength / 4 % sourceWidth !== 0) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The input data length is not a multiple of (4 * width).",
|
"Failed to construct 'ImageData': the input data length is not a multiple of (4 * width)",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class ImageData {
|
||||||
(sourceWidth * sourceHeight * 4 !== dataLength)
|
(sourceWidth * sourceHeight * 4 !== dataLength)
|
||||||
) {
|
) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The input data length is not equal to (4 * width * height).",
|
"Failed to construct 'ImageData': the input data length is not equal to (4 * width * height)",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -159,14 +159,14 @@ class ImageData {
|
||||||
|
|
||||||
if (sourceWidth < 1) {
|
if (sourceWidth < 1) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The source width is zero or not a number.",
|
"Failed to construct 'ImageData': the source width is zero or not a number",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceHeight < 1) {
|
if (sourceHeight < 1) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Failed to construct 'ImageData': The source height is zero or not a number.",
|
"Failed to construct 'ImageData': the source height is zero or not a number",
|
||||||
"IndexSizeError",
|
"IndexSizeError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,5 @@ Location {
|
||||||
protocol: "https:",
|
protocol: "https:",
|
||||||
search: "?baz"
|
search: "?baz"
|
||||||
}
|
}
|
||||||
NotSupportedError: Cannot set "location".
|
NotSupportedError: Cannot set "location"
|
||||||
NotSupportedError: Cannot set "location.hostname".
|
NotSupportedError: Cannot set "location.hostname"
|
||||||
|
|
Loading…
Reference in a new issue