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 === 3) return base64url + "=";
|
||||
if (base64url.length % 4 === 1) {
|
||||
throw new TypeError("Illegal base64url string!");
|
||||
throw new TypeError("Illegal base64url string");
|
||||
}
|
||||
return base64url;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ function assert(cond, msg = "Assertion failed.") {
|
|||
function serializeJSValueToJSONString(value) {
|
||||
const result = JSONStringify(value);
|
||||
if (result === undefined) {
|
||||
throw new TypeError("Value is not JSON serializable.");
|
||||
throw new TypeError("Value is not JSON serializable");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ function pathFromURLWin32(url) {
|
|||
*/
|
||||
function pathFromURLPosix(url) {
|
||||
if (url.hostname !== "") {
|
||||
throw new TypeError(`Host must be empty.`);
|
||||
throw new TypeError("Host must be empty");
|
||||
}
|
||||
|
||||
return decodeURIComponent(
|
||||
|
@ -444,7 +444,7 @@ function pathFromURLPosix(url) {
|
|||
function pathFromURL(pathOrUrl) {
|
||||
if (ObjectPrototypeIsPrototypeOf(URLPrototype, pathOrUrl)) {
|
||||
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"
|
||||
|
|
|
@ -1031,11 +1031,11 @@ class EventTarget {
|
|||
}
|
||||
|
||||
if (getDispatched(event)) {
|
||||
throw new DOMException("Invalid event state.", "InvalidStateError");
|
||||
throw new DOMException("Invalid event state", "InvalidStateError");
|
||||
}
|
||||
|
||||
if (event.eventPhase !== Event.NONE) {
|
||||
throw new DOMException("Invalid event state.", "InvalidStateError");
|
||||
throw new DOMException("Invalid event state", "InvalidStateError");
|
||||
}
|
||||
|
||||
return dispatch(self, event);
|
||||
|
|
|
@ -196,7 +196,7 @@ class AbortSignal extends EventTarget {
|
|||
|
||||
constructor(key = null) {
|
||||
if (key !== illegalConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ const illegalConstructorKey = Symbol("illegalConstructorKey");
|
|||
class Window extends EventTarget {
|
||||
constructor(key = null) {
|
||||
if (key !== illegalConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class Window extends EventTarget {
|
|||
class WorkerGlobalScope extends EventTarget {
|
||||
constructor(key = null) {
|
||||
if (key != illegalConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class WorkerGlobalScope extends EventTarget {
|
|||
class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
||||
constructor(key = null) {
|
||||
if (key != illegalConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ function btoa(data) {
|
|||
} catch (e) {
|
||||
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -523,10 +523,14 @@ function dequeueValue(container) {
|
|||
function enqueueValueWithSize(container, value, size) {
|
||||
assert(container[_queue] && typeof container[_queueTotalSize] === "number");
|
||||
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) {
|
||||
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[_queueTotalSize] += size;
|
||||
|
@ -1097,7 +1101,7 @@ async function readableStreamCollectIntoUint8Array(stream) {
|
|||
|
||||
if (TypedArrayPrototypeGetSymbolToStringTag(chunk) !== "Uint8Array") {
|
||||
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)) {
|
||||
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);
|
||||
|
@ -2095,14 +2099,14 @@ function readableByteStreamControllerRespond(controller, bytesWritten) {
|
|||
if (state === "closed") {
|
||||
if (bytesWritten !== 0) {
|
||||
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 {
|
||||
assert(state === "readable");
|
||||
if (bytesWritten === 0) {
|
||||
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 (
|
||||
|
@ -2110,7 +2114,7 @@ function readableByteStreamControllerRespond(controller, bytesWritten) {
|
|||
// deno-lint-ignore prefer-primordials
|
||||
firstDescriptor.byteLength
|
||||
) {
|
||||
throw new RangeError("bytesWritten out of range");
|
||||
throw new RangeError('"bytesWritten" out of range');
|
||||
}
|
||||
}
|
||||
firstDescriptor.buffer = ArrayBufferPrototypeTransferToFixedLength(
|
||||
|
@ -2305,7 +2309,7 @@ function readableByteStreamControllerRespondWithNewView(controller, view) {
|
|||
if (state === "closed") {
|
||||
if (byteLength !== 0) {
|
||||
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 {
|
||||
|
@ -3577,7 +3581,7 @@ function setUpReadableByteStreamControllerFromUnderlyingSource(
|
|||
}
|
||||
const autoAllocateChunkSize = underlyingSourceDict["autoAllocateChunkSize"];
|
||||
if (autoAllocateChunkSize === 0) {
|
||||
throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
||||
throw new TypeError('"autoAllocateChunkSize" must be greater than 0');
|
||||
}
|
||||
setUpReadableByteStreamController(
|
||||
stream,
|
||||
|
@ -3706,7 +3710,7 @@ function setUpReadableStreamDefaultControllerFromUnderlyingSource(
|
|||
*/
|
||||
function setUpReadableStreamBYOBReader(reader, stream) {
|
||||
if (isReadableStreamLocked(stream)) {
|
||||
throw new TypeError("ReadableStream is locked.");
|
||||
throw new TypeError("ReadableStream is locked");
|
||||
}
|
||||
if (
|
||||
!(ObjectPrototypeIsPrototypeOf(
|
||||
|
@ -3727,7 +3731,7 @@ function setUpReadableStreamBYOBReader(reader, stream) {
|
|||
*/
|
||||
function setUpReadableStreamDefaultReader(reader, stream) {
|
||||
if (isReadableStreamLocked(stream)) {
|
||||
throw new TypeError("ReadableStream is locked.");
|
||||
throw new TypeError("ReadableStream is locked");
|
||||
}
|
||||
readableStreamReaderGenericInitialize(reader, stream);
|
||||
reader[_readRequests] = new Queue();
|
||||
|
@ -3961,7 +3965,7 @@ function setUpWritableStreamDefaultControllerFromUnderlyingSink(
|
|||
*/
|
||||
function setUpWritableStreamDefaultWriter(writer, stream) {
|
||||
if (isWritableStreamLocked(stream) === true) {
|
||||
throw new TypeError("The stream is already locked.");
|
||||
throw new TypeError("The stream is already locked");
|
||||
}
|
||||
writer[_stream] = stream;
|
||||
stream[_writer] = writer;
|
||||
|
@ -4019,7 +4023,7 @@ function transformStreamDefaultControllerEnqueue(controller, chunk) {
|
|||
/** @type {ReadableStreamDefaultController<O>} */ readableController,
|
||||
) === false
|
||||
) {
|
||||
throw new TypeError("Readable stream is unavailable.");
|
||||
throw new TypeError("Readable stream is unavailable");
|
||||
}
|
||||
try {
|
||||
readableStreamDefaultControllerEnqueue(
|
||||
|
@ -5143,7 +5147,7 @@ class ReadableStream {
|
|||
if (underlyingSourceDict.type === "bytes") {
|
||||
if (strategy.size !== undefined) {
|
||||
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);
|
||||
|
@ -5273,10 +5277,10 @@ class ReadableStream {
|
|||
const { readable, writable } = transform;
|
||||
const { preventClose, preventAbort, preventCancel, signal } = options;
|
||||
if (isReadableStreamLocked(this)) {
|
||||
throw new TypeError("ReadableStream is already locked.");
|
||||
throw new TypeError("ReadableStream is already locked");
|
||||
}
|
||||
if (isWritableStreamLocked(writable)) {
|
||||
throw new TypeError("Target WritableStream is already locked.");
|
||||
throw new TypeError("Target WritableStream is already locked");
|
||||
}
|
||||
const promise = readableStreamPipeTo(
|
||||
this,
|
||||
|
@ -5814,7 +5818,7 @@ class ReadableByteStreamController {
|
|||
}
|
||||
if (this[_stream][_state] !== "readable") {
|
||||
throw new TypeError(
|
||||
"ReadableByteStreamController's stream is not in a readable state.",
|
||||
"ReadableByteStreamController's stream is not in a readable state",
|
||||
);
|
||||
}
|
||||
readableByteStreamControllerClose(this);
|
||||
|
@ -5846,7 +5850,7 @@ class ReadableByteStreamController {
|
|||
if (byteLength === 0) {
|
||||
throw webidl.makeException(
|
||||
TypeError,
|
||||
"length must be non-zero",
|
||||
"Length must be non-zero",
|
||||
prefix,
|
||||
arg1,
|
||||
);
|
||||
|
@ -5854,19 +5858,19 @@ class ReadableByteStreamController {
|
|||
if (getArrayBufferByteLength(buffer) === 0) {
|
||||
throw webidl.makeException(
|
||||
TypeError,
|
||||
"buffer length must be non-zero",
|
||||
"Buffer length must be non-zero",
|
||||
prefix,
|
||||
arg1,
|
||||
);
|
||||
}
|
||||
if (this[_closeRequested] === true) {
|
||||
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") {
|
||||
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);
|
||||
|
@ -6006,7 +6010,7 @@ class ReadableStreamDefaultController {
|
|||
close() {
|
||||
webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
|
||||
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);
|
||||
}
|
||||
|
@ -6021,7 +6025,7 @@ class ReadableStreamDefaultController {
|
|||
chunk = webidl.converters.any(chunk);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -6146,12 +6150,12 @@ class TransformStream {
|
|||
);
|
||||
if (transformerDict.readableType !== undefined) {
|
||||
throw new RangeError(
|
||||
`${prefix}: readableType transformers not supported.`,
|
||||
`${prefix}: readableType transformers not supported`,
|
||||
);
|
||||
}
|
||||
if (transformerDict.writableType !== undefined) {
|
||||
throw new RangeError(
|
||||
`${prefix}: writableType transformers not supported.`,
|
||||
`${prefix}: writableType transformers not supported`,
|
||||
);
|
||||
}
|
||||
const readableHighWaterMark = extractHighWaterMark(readableStrategy, 0);
|
||||
|
@ -6356,7 +6360,7 @@ class WritableStream {
|
|||
);
|
||||
if (underlyingSinkDict.type != null) {
|
||||
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);
|
||||
|
@ -6483,7 +6487,7 @@ class WritableStreamDefaultWriter {
|
|||
webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
|
||||
if (this[_stream] === undefined) {
|
||||
throw new TypeError(
|
||||
"A writable stream is not associated with the writer.",
|
||||
"A writable stream is not associated with the writer",
|
||||
);
|
||||
}
|
||||
return writableStreamDefaultWriterGetDesiredSize(this);
|
||||
|
|
|
@ -65,7 +65,7 @@ class FileReader extends EventTarget {
|
|||
// 1. If fr's state is "loading", throw an InvalidStateError DOMException.
|
||||
if (this[state] === "loading") {
|
||||
throw new DOMException(
|
||||
"Invalid FileReader state.",
|
||||
"Invalid FileReader state",
|
||||
"InvalidStateError",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ const locationConstructorKey = Symbol("locationConstructorKey");
|
|||
class Location {
|
||||
constructor(href = null, key = null) {
|
||||
if (key != locationConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
const url = new URL(href);
|
||||
url.username = "";
|
||||
|
@ -41,7 +41,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.hash".`,
|
||||
`Cannot set "location.hash"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.host".`,
|
||||
`Cannot set "location.host"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -67,7 +67,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.hostname".`,
|
||||
`Cannot set "location.hostname"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.href".`,
|
||||
`Cannot set "location.href"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -100,7 +100,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.pathname".`,
|
||||
`Cannot set "location.pathname"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.port".`,
|
||||
`Cannot set "location.port"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -126,7 +126,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.protocol".`,
|
||||
`Cannot set "location.protocol"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -139,7 +139,7 @@ class Location {
|
|||
},
|
||||
set() {
|
||||
throw new DOMException(
|
||||
`Cannot set "location.search".`,
|
||||
`Cannot set "location.search"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -161,7 +161,7 @@ class Location {
|
|||
__proto__: null,
|
||||
value: function assign() {
|
||||
throw new DOMException(
|
||||
`Cannot call "location.assign()".`,
|
||||
`Cannot call "location.assign()"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -171,7 +171,7 @@ class Location {
|
|||
__proto__: null,
|
||||
value: function reload() {
|
||||
throw new DOMException(
|
||||
`Cannot call "location.reload()".`,
|
||||
`Cannot call "location.reload()"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -181,7 +181,7 @@ class Location {
|
|||
__proto__: null,
|
||||
value: function replace() {
|
||||
throw new DOMException(
|
||||
`Cannot call "location.replace()".`,
|
||||
`Cannot call "location.replace()"`,
|
||||
"NotSupportedError",
|
||||
);
|
||||
},
|
||||
|
@ -229,7 +229,7 @@ const workerLocationUrls = new SafeWeakMap();
|
|||
class WorkerLocation {
|
||||
constructor(href = null, key = null) {
|
||||
if (key != locationConstructorKey) {
|
||||
throw new TypeError("Illegal constructor.");
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
const url = new URL(href);
|
||||
url.username = "";
|
||||
|
@ -244,7 +244,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.hash;
|
||||
},
|
||||
|
@ -256,7 +256,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.host;
|
||||
},
|
||||
|
@ -268,7 +268,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.hostname;
|
||||
},
|
||||
|
@ -280,7 +280,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.href;
|
||||
},
|
||||
|
@ -292,7 +292,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.origin;
|
||||
},
|
||||
|
@ -304,7 +304,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.pathname;
|
||||
},
|
||||
|
@ -316,7 +316,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.port;
|
||||
},
|
||||
|
@ -328,7 +328,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.protocol;
|
||||
},
|
||||
|
@ -340,7 +340,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
get() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.search;
|
||||
},
|
||||
|
@ -352,7 +352,7 @@ ObjectDefineProperties(WorkerLocation.prototype, {
|
|||
value: function toString() {
|
||||
const url = WeakMapPrototypeGet(workerLocationUrls, this);
|
||||
if (url == null) {
|
||||
throw new TypeError("Illegal invocation.");
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return url.href;
|
||||
},
|
||||
|
@ -414,7 +414,7 @@ const locationDescriptor = {
|
|||
return location;
|
||||
},
|
||||
set() {
|
||||
throw new DOMException(`Cannot set "location".`, "NotSupportedError");
|
||||
throw new DOMException(`Cannot set "location"`, "NotSupportedError");
|
||||
},
|
||||
enumerable: true,
|
||||
};
|
||||
|
@ -422,7 +422,7 @@ const workerLocationDescriptor = {
|
|||
get() {
|
||||
if (workerLocation == null) {
|
||||
throw new Error(
|
||||
`Assertion: "globalThis.location" must be defined in a worker.`,
|
||||
`Assertion: "globalThis.location" must be defined in a worker`,
|
||||
);
|
||||
}
|
||||
return workerLocation;
|
||||
|
|
|
@ -123,14 +123,14 @@ function convertMarkToTimestamp(mark) {
|
|||
const entry = findMostRecent(mark, "mark");
|
||||
if (!entry) {
|
||||
throw new DOMException(
|
||||
`Cannot find mark: "${mark}".`,
|
||||
`Cannot find mark: "${mark}"`,
|
||||
"SyntaxError",
|
||||
);
|
||||
}
|
||||
return entry.startTime;
|
||||
}
|
||||
if (mark < 0) {
|
||||
throw new TypeError("Mark cannot be negative.");
|
||||
throw new TypeError(`Mark cannot be negative: received ${mark}`);
|
||||
}
|
||||
return mark;
|
||||
}
|
||||
|
@ -261,7 +261,9 @@ class PerformanceMark extends PerformanceEntry {
|
|||
super(name, "mark", startTime, 0, illegalConstructorKey);
|
||||
this[webidl.brand] = webidl.brand;
|
||||
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);
|
||||
}
|
||||
|
@ -504,14 +506,14 @@ class Performance extends EventTarget {
|
|||
ObjectKeys(startOrMeasureOptions).length > 0
|
||||
) {
|
||||
if (endMark) {
|
||||
throw new TypeError("Options cannot be passed with endMark.");
|
||||
throw new TypeError('Options cannot be passed with "endMark"');
|
||||
}
|
||||
if (
|
||||
!ReflectHas(startOrMeasureOptions, "start") &&
|
||||
!ReflectHas(startOrMeasureOptions, "end")
|
||||
) {
|
||||
throw new TypeError(
|
||||
"A start or end mark must be supplied in options.",
|
||||
'A "start" or "end" mark must be supplied in options',
|
||||
);
|
||||
}
|
||||
if (
|
||||
|
@ -520,7 +522,7 @@ class Performance extends EventTarget {
|
|||
ReflectHas(startOrMeasureOptions, "end")
|
||||
) {
|
||||
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) {
|
||||
throw new DOMException(
|
||||
"Failed to construct 'ImageData': The input data has zero elements.",
|
||||
"Failed to construct 'ImageData': the input data has zero elements",
|
||||
"InvalidStateError",
|
||||
);
|
||||
}
|
||||
|
||||
if (dataLength % 4 !== 0) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
||||
if (sourceWidth < 1) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
||||
if (webidl.type(sourceHeight) !== "Undefined" && sourceHeight < 1) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
||||
if (dataLength / 4 % sourceWidth !== 0) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class ImageData {
|
|||
(sourceWidth * sourceHeight * 4 !== dataLength)
|
||||
) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ class ImageData {
|
|||
|
||||
if (sourceWidth < 1) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
||||
if (sourceHeight < 1) {
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@ Location {
|
|||
protocol: "https:",
|
||||
search: "?baz"
|
||||
}
|
||||
NotSupportedError: Cannot set "location".
|
||||
NotSupportedError: Cannot set "location.hostname".
|
||||
NotSupportedError: Cannot set "location"
|
||||
NotSupportedError: Cannot set "location.hostname"
|
||||
|
|
Loading…
Reference in a new issue