summaryrefslogtreecommitdiff
path: root/ext/web
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-01-27 16:27:22 +0100
committerGitHub <noreply@github.com>2022-01-27 16:27:22 +0100
commitf248e6f1778dc26db91d3322de2ecca5d1aa9866 (patch)
tree46b1ff59091cc8d31ff67427173d3a0148734007 /ext/web
parent382a978859a7a7a4351542be818bb2e59523429c (diff)
Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511)
This reverts commit 884143218fad0e18f7553aaf079d52de703f7601.
Diffstat (limited to 'ext/web')
-rw-r--r--ext/web/01_dom_exception.js4
-rw-r--r--ext/web/02_event.js16
-rw-r--r--ext/web/02_structured_clone.js12
-rw-r--r--ext/web/03_abort_signal.js15
-rw-r--r--ext/web/06_streams.js235
-rw-r--r--ext/web/08_text_encoding.js42
-rw-r--r--ext/web/09_file.js43
-rw-r--r--ext/web/10_filereader.js28
-rw-r--r--ext/web/13_message_port.js39
-rw-r--r--ext/web/14_compression.js10
10 files changed, 166 insertions, 278 deletions
diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js
index a3beb3064..44aa72abe 100644
--- a/ext/web/01_dom_exception.js
+++ b/ext/web/01_dom_exception.js
@@ -16,7 +16,6 @@
ErrorPrototype,
ObjectDefineProperty,
ObjectEntries,
- ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
SymbolFor,
} = window.__bootstrap.primordials;
@@ -127,7 +126,7 @@
}
[SymbolFor("Deno.customInspect")](inspect) {
- if (ObjectPrototypeIsPrototypeOf(DOMExceptionPrototype, this)) {
+ if (this instanceof DOMException) {
return `DOMException: ${this.#message}`;
} else {
return inspect(consoleInternal.createFilteredInspectProxy({
@@ -146,7 +145,6 @@
ObjectSetPrototypeOf(DOMException.prototype, ErrorPrototype);
webidl.configurePrototype(DOMException);
- const DOMExceptionPrototype = DOMException.prototype;
for (
const [key, value] of ObjectEntries({
diff --git a/ext/web/02_event.js b/ext/web/02_event.js
index b32bb01b8..7ba5afa27 100644
--- a/ext/web/02_event.js
+++ b/ext/web/02_event.js
@@ -29,7 +29,6 @@
ObjectCreate,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
- ObjectPrototypeIsPrototypeOf,
ReflectDefineProperty,
Symbol,
SymbolFor,
@@ -175,7 +174,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(Event.prototype, this),
+ evaluate: this instanceof Event,
keys: EVENT_PROPS,
}));
}
@@ -1059,7 +1058,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this),
+ evaluate: this instanceof ErrorEvent,
keys: [
...EVENT_PROPS,
"message",
@@ -1120,7 +1119,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this),
+ evaluate: this instanceof CloseEvent,
keys: [
...EVENT_PROPS,
"wasClean",
@@ -1152,7 +1151,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this),
+ evaluate: this instanceof MessageEvent,
keys: [
...EVENT_PROPS,
"data",
@@ -1185,7 +1184,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this),
+ evaluate: this instanceof CustomEvent,
keys: [
...EVENT_PROPS,
"detail",
@@ -1215,7 +1214,7 @@
[SymbolFor("Deno.privateCustomInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this),
+ evaluate: this instanceof ProgressEvent,
keys: [
...EVENT_PROPS,
"lengthComputable",
@@ -1239,8 +1238,7 @@
if (
isSpecialErrorEventHandler &&
- ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, evt) &&
- evt.type === "error"
+ evt instanceof ErrorEvent && evt.type === "error"
) {
const ret = FunctionPrototypeCall(
wrappedHandler.handler,
diff --git a/ext/web/02_structured_clone.js b/ext/web/02_structured_clone.js
index 058390cfe..005b668af 100644
--- a/ext/web/02_structured_clone.js
+++ b/ext/web/02_structured_clone.js
@@ -13,12 +13,10 @@
const { DOMException } = window.__bootstrap.domException;
const {
ArrayBuffer,
- ArrayBufferPrototype,
ArrayBufferIsView,
- DataViewPrototype,
- ObjectPrototypeIsPrototypeOf,
+ DataView,
TypedArrayPrototypeSlice,
- TypeErrorPrototype,
+ TypeError,
WeakMap,
WeakMapPrototypeSet,
} = window.__bootstrap.primordials;
@@ -44,7 +42,7 @@
function structuredClone(value) {
// Performance optimization for buffers, otherwise
// `serialize/deserialize` will allocate new buffer.
- if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, value)) {
+ if (value instanceof ArrayBuffer) {
const cloned = cloneArrayBuffer(
value,
0,
@@ -61,7 +59,7 @@
// only DataView has a length in bytes and TypedArrays use a length in
// terms of elements, so we adjust for that.
let length;
- if (ObjectPrototypeIsPrototypeOf(DataViewPrototype, view)) {
+ if (value instanceof DataView) {
length = value.byteLength;
} else {
length = value.length;
@@ -76,7 +74,7 @@
try {
return core.deserialize(core.serialize(value));
} catch (e) {
- if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
+ if (e instanceof TypeError) {
throw new DOMException("Uncloneable value", "DataCloneError");
}
throw e;
diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js
index 8b089d031..cd9b11d4b 100644
--- a/ext/web/03_abort_signal.js
+++ b/ext/web/03_abort_signal.js
@@ -77,17 +77,17 @@
}
get aborted() {
- webidl.assertBranded(this, AbortSignalPrototype);
+ webidl.assertBranded(this, AbortSignal);
return this[abortReason] !== undefined;
}
get reason() {
- webidl.assertBranded(this, AbortSignalPrototype);
+ webidl.assertBranded(this, AbortSignal);
return this[abortReason];
}
throwIfAborted() {
- webidl.assertBranded(this, AbortSignalPrototype);
+ webidl.assertBranded(this, AbortSignal);
if (this[abortReason] !== undefined) {
throw this[abortReason];
}
@@ -96,7 +96,6 @@
defineEventHandler(AbortSignal.prototype, "abort");
webidl.configurePrototype(AbortSignal);
- const AbortSignalPrototype = AbortSignal.prototype;
class AbortController {
[signal] = new AbortSignal(illegalConstructorKey);
@@ -106,22 +105,21 @@
}
get signal() {
- webidl.assertBranded(this, AbortControllerPrototype);
+ webidl.assertBranded(this, AbortController);
return this[signal];
}
abort(reason) {
- webidl.assertBranded(this, AbortControllerPrototype);
+ webidl.assertBranded(this, AbortController);
this[signal][signalAbort](reason);
}
}
webidl.configurePrototype(AbortController);
- const AbortControllerPrototype = AbortController.prototype;
webidl.converters["AbortSignal"] = webidl.createInterfaceConverter(
"AbortSignal",
- AbortSignal.prototype,
+ AbortSignal,
);
function newSignal() {
@@ -144,7 +142,6 @@
window.AbortSignal = AbortSignal;
window.AbortController = AbortController;
window.__bootstrap.abortSignal = {
- AbortSignalPrototype,
add,
signalAbort,
remove,
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js
index 777ad152b..d32a72c6e 100644
--- a/ext/web/06_streams.js
+++ b/ext/web/06_streams.js
@@ -9,22 +9,21 @@
((window) => {
const webidl = window.__bootstrap.webidl;
- const { add, remove, signalAbort, newSignal, AbortSignalPrototype } =
+ const { add, remove, signalAbort, newSignal } =
window.__bootstrap.abortSignal;
const {
ArrayBuffer,
- ArrayBufferPrototype,
ArrayBufferIsView,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeShift,
- BigInt64ArrayPrototype,
- BigUint64ArrayPrototype,
+ BigInt64Array,
+ BigUint64Array,
DataView,
Error,
- Int8ArrayPrototype,
- Int16ArrayPrototype,
- Int32ArrayPrototype,
+ Int8Array,
+ Int16Array,
+ Int32Array,
NumberIsInteger,
NumberIsNaN,
MathMin,
@@ -32,7 +31,6 @@
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetPrototypeOf,
- ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
Promise,
PromiseAll,
@@ -48,10 +46,9 @@
SymbolFor,
TypeError,
Uint8Array,
- Uint8ArrayPrototype,
- Uint16ArrayPrototype,
- Uint32ArrayPrototype,
- Uint8ClampedArrayPrototype,
+ Uint16Array,
+ Uint32Array,
+ Uint8ClampedArray,
WeakMap,
WeakMapPrototypeGet,
WeakMapPrototypeHas,
@@ -137,7 +134,7 @@
/** @param {any} e */
function rethrowAssertionErrorRejection(e) {
- if (e && ObjectPrototypeIsPrototypeOf(AssertionError.prototype, e)) {
+ if (e && e instanceof AssertionError) {
queueMicrotask(() => {
console.error(`Internal Error: ${e.stack}`);
});
@@ -217,10 +214,7 @@
*/
function canTransferArrayBuffer(O) {
assert(typeof O === "object");
- assert(
- ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, O) ||
- ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, O),
- );
+ assert(O instanceof ArrayBuffer || O instanceof SharedArrayBuffer);
if (isDetachedBuffer(O)) {
return false;
}
@@ -1370,15 +1364,15 @@
let ctor = DataView;
if (
- ObjectPrototypeIsPrototypeOf(Int8ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Uint8ClampedArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Int16ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Uint16ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Int32ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(Uint32ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(BigInt64ArrayPrototype, view) ||
- ObjectPrototypeIsPrototypeOf(BigUint64ArrayPrototype, view)
+ view instanceof Int8Array ||
+ view instanceof Uint8Array ||
+ view instanceof Uint8ClampedArray ||
+ view instanceof Int16Array ||
+ view instanceof Uint16Array ||
+ view instanceof Int32Array ||
+ view instanceof Uint32Array ||
+ view instanceof BigInt64Array ||
+ view instanceof BigUint64Array
) {
elementSize = view.constructor.BYTES_PER_ELEMENT;
ctor = view.constructor;
@@ -1989,10 +1983,7 @@
typeof preventClose === "boolean" && typeof preventAbort === "boolean" &&
typeof preventCancel === "boolean",
);
- assert(
- signal === undefined ||
- ObjectPrototypeIsPrototypeOf(AbortSignalPrototype, signal),
- );
+ assert(signal === undefined || signal instanceof AbortSignal);
assert(!isReadableStreamLocked(source));
assert(!isWritableStreamLocked(dest));
// We use acquireReadableStreamDefaultReader even in case of ReadableByteStreamController
@@ -2336,12 +2327,7 @@
function readableStreamTee(stream, cloneForBranch2) {
assert(isReadableStream(stream));
assert(typeof cloneForBranch2 === "boolean");
- if (
- ObjectPrototypeIsPrototypeOf(
- ReadableByteStreamControllerPrototype,
- stream[_controller],
- )
- ) {
+ if (stream[_controller] instanceof ReadableByteStreamController) {
return readableByteStreamTee(stream);
} else {
return readableStreamDefaultTee(stream, cloneForBranch2);
@@ -2505,12 +2491,7 @@
*/
function readableByteStreamTee(stream) {
assert(isReadableStream(stream));
- assert(
- ObjectPrototypeIsPrototypeOf(
- ReadableByteStreamControllerPrototype,
- stream[_controller],
- ),
- );
+ assert(stream[_controller] instanceof ReadableByteStreamController);
let reader = acquireReadableStreamDefaultReader(stream);
let reading = false;
let readAgainForBranch1 = false;
@@ -3018,12 +2999,7 @@
if (isReadableStreamLocked(stream)) {
throw new TypeError("ReadableStream is locked.");
}
- if (
- !(ObjectPrototypeIsPrototypeOf(
- ReadableByteStreamControllerPrototype,
- stream[_controller],
- ))
- ) {
+ if (!(stream[_controller] instanceof ReadableByteStreamController)) {
throw new TypeError("Cannot use a BYOB reader with a non-byte stream");
}
readableStreamReaderGenericInitialize(reader, stream);
@@ -3056,7 +3032,7 @@
transformAlgorithm,
flushAlgorithm,
) {
- assert(ObjectPrototypeIsPrototypeOf(TransformStreamPrototype, stream));
+ assert(stream instanceof TransformStream);
assert(stream[_controller] === undefined);
controller[_stream] = stream;
stream[_controller] = controller;
@@ -4198,13 +4174,13 @@
/** @returns {number} */
get highWaterMark() {
- webidl.assertBranded(this, ByteLengthQueuingStrategyPrototype);
+ webidl.assertBranded(this, ByteLengthQueuingStrategy);
return this[_highWaterMark];
}
/** @returns {(chunk: ArrayBufferView) => number} */
get size() {
- webidl.assertBranded(this, ByteLengthQueuingStrategyPrototype);
+ webidl.assertBranded(this, ByteLengthQueuingStrategy);
initializeByteLengthSizeFunction(this[_globalObject]);
return WeakMapPrototypeGet(byteSizeFunctionWeakMap, this[_globalObject]);
}
@@ -4212,10 +4188,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- ByteLengthQueuingStrategyPrototype,
- this,
- ),
+ evaluate: this instanceof ByteLengthQueuingStrategy,
keys: [
"highWaterMark",
"size",
@@ -4225,8 +4198,6 @@
}
webidl.configurePrototype(ByteLengthQueuingStrategy);
- const ByteLengthQueuingStrategyPrototype =
- ByteLengthQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, (chunk: ArrayBufferView) => number>} */
const byteSizeFunctionWeakMap = new WeakMap();
@@ -4255,13 +4226,13 @@
/** @returns {number} */
get highWaterMark() {
- webidl.assertBranded(this, CountQueuingStrategyPrototype);
+ webidl.assertBranded(this, CountQueuingStrategy);
return this[_highWaterMark];
}
/** @returns {(chunk: any) => 1} */
get size() {
- webidl.assertBranded(this, CountQueuingStrategyPrototype);
+ webidl.assertBranded(this, CountQueuingStrategy);
initializeCountSizeFunction(this[_globalObject]);
return WeakMapPrototypeGet(countSizeFunctionWeakMap, this[_globalObject]);
}
@@ -4269,10 +4240,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- CountQueuingStrategyPrototype,
- this,
- ),
+ evaluate: this instanceof CountQueuingStrategy,
keys: [
"highWaterMark",
"size",
@@ -4282,7 +4250,6 @@
}
webidl.configurePrototype(CountQueuingStrategy);
- const CountQueuingStrategyPrototype = CountQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, () => 1>} */
const countSizeFunctionWeakMap = new WeakMap();
@@ -4366,7 +4333,7 @@
/** @returns {boolean} */
get locked() {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
return isReadableStreamLocked(this);
}
@@ -4376,7 +4343,7 @@
*/
cancel(reason = undefined) {
try {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@@ -4396,7 +4363,7 @@
* @returns {ReadableStreamDefaultReader<R> | ReadableStreamBYOBReader}
*/
getReader(options = {}) {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
const prefix = "Failed to execute 'getReader' on 'ReadableStream'";
options = webidl.converters.ReadableStreamGetReaderOptions(options, {
prefix,
@@ -4417,7 +4384,7 @@
* @returns {ReadableStream<T>}
*/
pipeThrough(transform, options = {}) {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
const prefix = "Failed to execute 'pipeThrough' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix });
transform = webidl.converters.ReadableWritablePair(transform, {
@@ -4455,7 +4422,7 @@
*/
pipeTo(destination, options = {}) {
try {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
const prefix = "Failed to execute 'pipeTo' on 'ReadableStream'";
webidl.requiredArguments(arguments.length, 1, { prefix });
destination = webidl.converters.WritableStream(destination, {
@@ -4492,7 +4459,7 @@
/** @returns {[ReadableStream<R>, ReadableStream<R>]} */
tee() {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
return readableStreamTee(this, false);
}
@@ -4502,7 +4469,7 @@
* @returns {AsyncIterableIterator<R>}
*/
values(options = {}) {
- webidl.assertBranded(this, ReadableStreamPrototype);
+ webidl.assertBranded(this, ReadableStream);
const prefix = "Failed to execute 'values' on 'ReadableStream'";
options = webidl.converters.ReadableStreamIteratorOptions(options, {
prefix,
@@ -4531,7 +4498,6 @@
});
webidl.configurePrototype(ReadableStream);
- const ReadableStreamPrototype = ReadableStream.prototype;
function errorReadableStream(stream, e) {
readableStreamDefaultControllerError(stream[_controller], e);
@@ -4561,7 +4527,7 @@
/** @returns {Promise<ReadableStreamReadResult<R>>} */
read() {
try {
- webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultReader);
} catch (err) {
return PromiseReject(err);
}
@@ -4590,7 +4556,7 @@
/** @returns {void} */
releaseLock() {
- webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultReader);
if (this[_stream] === undefined) {
return;
}
@@ -4599,7 +4565,7 @@
get closed() {
try {
- webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultReader);
} catch (err) {
return PromiseReject(err);
}
@@ -4612,7 +4578,7 @@
*/
cancel(reason = undefined) {
try {
- webidl.assertBranded(this, ReadableStreamDefaultReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultReader);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@@ -4634,8 +4600,6 @@
}
webidl.configurePrototype(ReadableStreamDefaultReader);
- const ReadableStreamDefaultReaderPrototype =
- ReadableStreamDefaultReader.prototype;
/** @template R */
class ReadableStreamBYOBReader {
@@ -4664,7 +4628,7 @@
*/
read(view) {
try {
- webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBReader);
const prefix = "Failed to execute 'read' on 'ReadableStreamBYOBReader'";
view = webidl.converters.ArrayBufferView(view, {
prefix,
@@ -4714,7 +4678,7 @@
/** @returns {void} */
releaseLock() {
- webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBReader);
if (this[_stream] === undefined) {
return;
}
@@ -4723,7 +4687,7 @@
get closed() {
try {
- webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBReader);
} catch (err) {
return PromiseReject(err);
}
@@ -4736,7 +4700,7 @@
*/
cancel(reason = undefined) {
try {
- webidl.assertBranded(this, ReadableStreamBYOBReaderPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBReader);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@@ -4758,7 +4722,6 @@
}
webidl.configurePrototype(ReadableStreamBYOBReader);
- const ReadableStreamBYOBReaderPrototype = ReadableStreamBYOBReader.prototype;
class ReadableStreamBYOBRequest {
/** @type {ReadableByteStreamController} */
@@ -4768,7 +4731,7 @@
/** @returns {ArrayBufferView | null} */
get view() {
- webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBRequest);
return this[_view];
}
@@ -4777,7 +4740,7 @@
}
respond(bytesWritten) {
- webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBRequest);
const prefix =
"Failed to execute 'respond' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -4801,7 +4764,7 @@
}
respondWithNewView(view) {
- webidl.assertBranded(this, ReadableStreamBYOBRequestPrototype);
+ webidl.assertBranded(this, ReadableStreamBYOBRequest);
const prefix =
"Failed to execute 'respondWithNewView' on 'ReadableStreamBYOBRequest'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -4823,8 +4786,6 @@
}
webidl.configurePrototype(ReadableStreamBYOBRequest);
- const ReadableStreamBYOBRequestPrototype =
- ReadableStreamBYOBRequest.prototype;
class ReadableByteStreamController {
/** @type {number | undefined} */
@@ -4860,19 +4821,19 @@
/** @returns {ReadableStreamBYOBRequest | null} */
get byobRequest() {
- webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
+ webidl.assertBranded(this, ReadableByteStreamController);
return readableByteStreamControllerGetBYOBRequest(this);
}
/** @returns {number | null} */
get desiredSize() {
- webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
+ webidl.assertBranded(this, ReadableByteStreamController);
return readableByteStreamControllerGetDesiredSize(this);
}
/** @returns {void} */
close() {
- webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
+ webidl.assertBranded(this, ReadableByteStreamController);
if (this[_closeRequested] === true) {
throw new TypeError("Closed already requested.");
}
@@ -4889,7 +4850,7 @@
* @returns {void}
*/
enqueue(chunk) {
- webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
+ webidl.assertBranded(this, ReadableByteStreamController);
const prefix =
"Failed to execute 'enqueue' on 'ReadableByteStreamController'";
webidl.requiredArguments(arguments.length, 1, { prefix });
@@ -4929,7 +4890,7 @@
* @returns {void}
*/
error(e = undefined) {
- webidl.assertBranded(this, ReadableByteStreamControllerPrototype);
+ webidl.assertBranded(this, ReadableByteStreamController);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@@ -4939,10 +4900,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- ReadableByteStreamControllerPrototype,
- this,
- ),
+ evaluate: this instanceof ReadableByteStreamController,
keys: ["desiredSize"],
}));
}
@@ -5009,8 +4967,6 @@
}
webidl.configurePrototype(ReadableByteStreamController);
- const ReadableByteStreamControllerPrototype =
- ReadableByteStreamController.prototype;
/** @template R */
class ReadableStreamDefaultController {
@@ -5043,13 +4999,13 @@
/** @returns {number | null} */
get desiredSize() {
- webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultController);
return readableStreamDefaultControllerGetDesiredSize(this);
}
/** @returns {void} */
close() {
- webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultController);
if (readableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
throw new TypeError("The stream controller cannot close or enqueue.");
}
@@ -5061,7 +5017,7 @@
* @returns {void}
*/
enqueue(chunk = undefined) {
- webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultController);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@@ -5076,7 +5032,7 @@
* @returns {void}
*/
error(e = undefined) {
- webidl.assertBranded(this, ReadableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, ReadableStreamDefaultController);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@@ -5086,10 +5042,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- ReadableStreamDefaultController.prototype,
- this,
- ),
+ evaluate: this instanceof ReadableStreamDefaultController,
keys: ["desiredSize"],
}));
}
@@ -5132,8 +5085,6 @@
}
webidl.configurePrototype(ReadableStreamDefaultController);
- const ReadableStreamDefaultControllerPrototype =
- ReadableStreamDefaultController.prototype;
/**
* @template I
@@ -5235,13 +5186,13 @@
/** @returns {ReadableStream<O>} */
get readable() {
- webidl.assertBranded(this, TransformStreamPrototype);
+ webidl.assertBranded(this, TransformStream);
return this[_readable];
}
/** @returns {WritableStream<I>} */
get writable() {
- webidl.assertBranded(this, TransformStreamPrototype);
+ webidl.assertBranded(this, TransformStream);
return this[_writable];
}
@@ -5253,7 +5204,6 @@
}
webidl.configurePrototype(TransformStream);
- const TransformStreamPrototype = TransformStream.prototype;
/** @template O */
class TransformStreamDefaultController {
@@ -5270,7 +5220,7 @@
/** @returns {number | null} */
get desiredSize() {
- webidl.assertBranded(this, TransformStreamDefaultController.prototype);
+ webidl.assertBranded(this, TransformStreamDefaultController);
const readableController = this[_stream][_readable][_controller];
return readableStreamDefaultControllerGetDesiredSize(
/** @type {ReadableStreamDefaultController<O>} */ readableController,
@@ -5282,7 +5232,7 @@
* @returns {void}
*/
enqueue(chunk = undefined) {
- webidl.assertBranded(this, TransformStreamDefaultController.prototype);
+ webidl.assertBranded(this, TransformStreamDefaultController);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@@ -5294,7 +5244,7 @@
* @returns {void}
*/
error(reason = undefined) {
- webidl.assertBranded(this, TransformStreamDefaultController.prototype);
+ webidl.assertBranded(this, TransformStreamDefaultController);
if (reason !== undefined) {
reason = webidl.converters.any(reason);
}
@@ -5303,25 +5253,20 @@
/** @returns {void} */
terminate() {
- webidl.assertBranded(this, TransformStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, TransformStreamDefaultController);
transformStreamDefaultControllerTerminate(this);
}
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- TransformStreamDefaultController.prototype,
- this,
- ),
+ evaluate: this instanceof TransformStreamDefaultController,
keys: ["desiredSize"],
}));
}
}
webidl.configurePrototype(TransformStreamDefaultController);
- const TransformStreamDefaultControllerPrototype =
- TransformStreamDefaultController.prototype;
/** @template W */
class WritableStream {
@@ -5391,7 +5336,7 @@
/** @returns {boolean} */
get locked() {
- webidl.assertBranded(this, WritableStreamPrototype);
+ webidl.assertBranded(this, WritableStream);
return isWritableStreamLocked(this);
}
@@ -5401,7 +5346,7 @@
*/
abort(reason = undefined) {
try {
- webidl.assertBranded(this, WritableStreamPrototype);
+ webidl.assertBranded(this, WritableStream);
} catch (err) {
return PromiseReject(err);
}
@@ -5421,7 +5366,7 @@
/** @returns {Promise<void>} */
close() {
try {
- webidl.assertBranded(this, WritableStreamPrototype);
+ webidl.assertBranded(this, WritableStream);
} catch (err) {
return PromiseReject(err);
}
@@ -5442,7 +5387,7 @@
/** @returns {WritableStreamDefaultWriter<W>} */
getWriter() {
- webidl.assertBranded(this, WritableStreamPrototype);
+ webidl.assertBranded(this, WritableStream);
return acquireWritableStreamDefaultWriter(this);
}
@@ -5452,7 +5397,6 @@
}
webidl.configurePrototype(WritableStream);
- const WritableStreamPrototype = WritableStream.prototype;
/** @template W */
class WritableStreamDefaultWriter {
@@ -5482,7 +5426,7 @@
/** @returns {Promise<void>} */
get closed() {
try {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
} catch (err) {
return PromiseReject(err);
}
@@ -5491,7 +5435,7 @@
/** @returns {number} */
get desiredSize() {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
if (this[_stream] === undefined) {
throw new TypeError(
"A writable stream is not associated with the writer.",
@@ -5503,7 +5447,7 @@
/** @returns {Promise<void>} */
get ready() {
try {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
} catch (err) {
return PromiseReject(err);
}
@@ -5516,7 +5460,7 @@
*/
abort(reason = undefined) {
try {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
} catch (err) {
return PromiseReject(err);
}
@@ -5534,7 +5478,7 @@
/** @returns {Promise<void>} */
close() {
try {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
} catch (err) {
return PromiseReject(err);
}
@@ -5554,7 +5498,7 @@
/** @returns {void} */
releaseLock() {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
const stream = this[_stream];
if (stream === undefined) {
return;
@@ -5569,7 +5513,7 @@
*/
write(chunk = undefined) {
try {
- webidl.assertBranded(this, WritableStreamDefaultWriterPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultWriter);
if (chunk !== undefined) {
chunk = webidl.converters.any(chunk);
}
@@ -5587,10 +5531,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- WritableStreamDefaultWriter.prototype,
- this,
- ),
+ evaluate: this instanceof WritableStreamDefaultWriter,
keys: [
"closed",
"desiredSize",
@@ -5601,8 +5542,6 @@
}
webidl.configurePrototype(WritableStreamDefaultWriter);
- const WritableStreamDefaultWriterPrototype =
- WritableStreamDefaultWriter.prototype;
/** @template W */
class WritableStreamDefaultController {
@@ -5628,7 +5567,7 @@
[_signal];
get signal() {
- webidl.assertBranded(this, WritableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultController);
return this[_signal];
}
@@ -5641,7 +5580,7 @@
* @returns {void}
*/
error(e = undefined) {
- webidl.assertBranded(this, WritableStreamDefaultControllerPrototype);
+ webidl.assertBranded(this, WritableStreamDefaultController);
if (e !== undefined) {
e = webidl.converters.any(e);
}
@@ -5655,10 +5594,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(
- WritableStreamDefaultController.prototype,
- this,
- ),
+ evaluate: this instanceof WritableStreamDefaultController,
keys: [],
}));
}
@@ -5679,8 +5615,6 @@
}
webidl.configurePrototype(WritableStreamDefaultController);
- const WritableStreamDefaultControllerPrototype =
- WritableStreamDefaultController.prototype;
/**
* @param {ReadableStream} stream
@@ -5690,9 +5624,9 @@
}
webidl.converters.ReadableStream = webidl
- .createInterfaceConverter("ReadableStream", ReadableStream.prototype);
+ .createInterfaceConverter("ReadableStream", ReadableStream);
webidl.converters.WritableStream = webidl
- .createInterfaceConverter("WritableStream", WritableStream.prototype);
+ .createInterfaceConverter("WritableStream", WritableStream);
webidl.converters.ReadableStreamType = webidl.createEnumConverter(
"ReadableStreamType",
@@ -5853,7 +5787,6 @@
ByteLengthQueuingStrategy,
CountQueuingStrategy,
ReadableStream,
- ReadableStreamPrototype,
ReadableStreamDefaultReader,
TransformStream,
WritableStream,
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js
index 4f26089b1..cf7b7e12f 100644
--- a/ext/web/08_text_encoding.js
+++ b/ext/web/08_text_encoding.js
@@ -16,7 +16,6 @@
const webidl = window.__bootstrap.webidl;
const {
ArrayBufferIsView,
- ObjectPrototypeIsPrototypeOf,
PromiseReject,
PromiseResolve,
StringPrototypeCharCodeAt,
@@ -60,19 +59,19 @@
/** @returns {string} */
get encoding() {
- webidl.assertBranded(this, TextDecoderPrototype);
+ webidl.assertBranded(this, TextDecoder);
return this.#encoding;
}
/** @returns {boolean} */
get fatal() {
- webidl.assertBranded(this, TextDecoderPrototype);
+ webidl.assertBranded(this, TextDecoder);
return this.#fatal;
}
/** @returns {boolean} */
get ignoreBOM() {
- webidl.assertBranded(this, TextDecoderPrototype);
+ webidl.assertBranded(this, TextDecoder);
return this.#ignoreBOM;
}
@@ -81,7 +80,7 @@
* @param {TextDecodeOptions} options
*/
decode(input = new Uint8Array(), options = {}) {
- webidl.assertBranded(this, TextDecoderPrototype);
+ webidl.assertBranded(this, TextDecoder);
const prefix = "Failed to execute 'decode' on 'TextDecoder'";
if (input !== undefined) {
input = webidl.converters.BufferSource(input, {
@@ -120,12 +119,7 @@
// If the buffer is detached, just create a new empty Uint8Array.
input = new Uint8Array();
}
- if (
- ObjectPrototypeIsPrototypeOf(
- SharedArrayBuffer.prototype,
- input.buffer,
- )
- ) {
+ if (input.buffer instanceof SharedArrayBuffer) {
// We clone the data into a non-shared ArrayBuffer so we can pass it
// to Rust.
// `input` is now a Uint8Array, and calling the TypedArray constructor
@@ -146,7 +140,6 @@
}
webidl.configurePrototype(TextDecoder);
- const TextDecoderPrototype = TextDecoder.prototype;
class TextEncoder {
constructor() {
@@ -155,7 +148,7 @@
/** @returns {string} */
get encoding() {
- webidl.assertBranded(this, TextEncoderPrototype);
+ webidl.assertBranded(this, TextEncoder);
return "utf-8";
}
@@ -164,7 +157,7 @@
* @returns {Uint8Array}
*/
encode(input = "") {
- webidl.assertBranded(this, TextEncoderPrototype);
+ webidl.assertBranded(this, TextEncoder);
const prefix = "Failed to execute 'encode' on 'TextEncoder'";
// The WebIDL type of `input` is `USVString`, but `core.encode` already
// converts lone surrogates to the replacement character.
@@ -181,7 +174,7 @@
* @returns {TextEncoderEncodeIntoResult}
*/
encodeInto(source, destination) {
- webidl.assertBranded(this, TextEncoderPrototype);
+ webidl.assertBranded(this, TextEncoder);
const prefix = "Failed to execute 'encodeInto' on 'TextEncoder'";
// The WebIDL type of `source` is `USVString`, but the ops bindings
// already convert lone surrogates to the replacement character.
@@ -199,7 +192,6 @@
}
webidl.configurePrototype(TextEncoder);
- const TextEncoderPrototype = TextEncoder.prototype;
class TextDecoderStream {
/** @type {TextDecoder} */
@@ -256,37 +248,36 @@
/** @returns {string} */
get encoding() {
- webidl.assertBranded(this, TextDecoderStreamPrototype);
+ webidl.assertBranded(this, TextDecoderStream);
return this.#decoder.encoding;
}
/** @returns {boolean} */
get fatal() {
- webidl.assertBranded(this, TextDecoderStreamPrototype);
+ webidl.assertBranded(this, TextDecoderStream);
return this.#decoder.fatal;
}
/** @returns {boolean} */
get ignoreBOM() {
- webidl.assertBranded(this, TextDecoderStreamPrototype);
+ webidl.assertBranded(this, TextDecoderStream);
return this.#decoder.ignoreBOM;
}
/** @returns {ReadableStream<string>} */
get readable() {
- webidl.assertBranded(this, TextDecoderStreamPrototype);
+ webidl.assertBranded(this, TextDecoderStream);
return this.#transform.readable;
}
/** @returns {WritableStream<BufferSource>} */
get writable() {
- webidl.assertBranded(this, TextDecoderStreamPrototype);
+ webidl.assertBranded(this, TextDecoderStream);
return this.#transform.writable;
}
}
webidl.configurePrototype(TextDecoderStream);
- const TextDecoderStreamPrototype = TextDecoderStream.prototype;
class TextEncoderStream {
/** @type {string | null} */
@@ -341,25 +332,24 @@
/** @returns {string} */
get encoding() {
- webidl.assertBranded(this, TextEncoderStreamPrototype);
+ webidl.assertBranded(this, TextEncoderStream);
return "utf-8";
}
/** @returns {ReadableStream<Uint8Array>} */
get readable() {
- webidl.assertBranded(this, TextEncoderStreamPrototype);
+ webidl.assertBranded(this, TextEncoderStream);
return this.#transform.readable;
}
/** @returns {WritableStream<string>} */
get writable() {
- webidl.assertBranded(this, TextEncoderStreamPrototype);
+ webidl.assertBranded(this, TextEncoderStream);
return this.#transform.writable;
}
}
webidl.configurePrototype(TextEncoderStream);
- const TextEncoderStreamPrototype = TextEncoderStream.prototype;
webidl.converters.TextDecoderOptions = webidl.createDictionaryConverter(
"TextDecoderOptions",
diff --git a/ext/web/09_file.js b/ext/web/09_file.js
index fbc00326e..289db22ec 100644
--- a/ext/web/09_file.js
+++ b/ext/web/09_file.js
@@ -15,7 +15,7 @@
const core = window.Deno.core;
const webidl = window.__bootstrap.webidl;
const {
- ArrayBufferPrototype,
+ ArrayBuffer,
ArrayBufferPrototypeSlice,
ArrayBufferIsView,
ArrayPrototypePush,
@@ -23,7 +23,6 @@
DatePrototypeGetTime,
MathMax,
MathMin,
- ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest,
StringPrototypeCharAt,
StringPrototypeToLowerCase,
@@ -110,7 +109,7 @@
const processedParts = [];
let size = 0;
for (const element of parts) {
- if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, element)) {
+ if (element instanceof ArrayBuffer) {
const chunk = new Uint8Array(ArrayBufferPrototypeSlice(element, 0));
ArrayPrototypePush(processedParts, BlobReference.fromUint8Array(chunk));
size += element.byteLength;
@@ -122,7 +121,7 @@
);
size += element.byteLength;
ArrayPrototypePush(processedParts, BlobReference.fromUint8Array(chunk));
- } else if (ObjectPrototypeIsPrototypeOf(BlobPrototype, element)) {
+ } else if (element instanceof Blob) {
ArrayPrototypePush(processedParts, element);
size += element.size;
} else if (typeof element === "string") {
@@ -158,7 +157,7 @@
*/
function getParts(blob, bag = []) {
for (const part of blob[_parts]) {
- if (ObjectPrototypeIsPrototypeOf(BlobPrototype, part)) {
+ if (part instanceof Blob) {
getParts(part, bag);
} else {
ArrayPrototypePush(bag, part._id);
@@ -205,13 +204,13 @@
/** @returns {number} */
get size() {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
return this[_size];
}
/** @returns {string} */
get type() {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
return this[_type];
}
@@ -222,7 +221,7 @@
* @returns {Blob}
*/
slice(start = undefined, end = undefined, contentType = undefined) {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
const prefix = "Failed to execute 'slice' on 'Blob'";
if (start !== undefined) {
start = webidl.converters["long long"](start, {
@@ -317,7 +316,7 @@
* @returns {ReadableStream<Uint8Array>}
*/
stream() {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
const partIterator = toIterator(this[_parts]);
const stream = new ReadableStream({
type: "bytes",
@@ -339,7 +338,7 @@
* @returns {Promise<string>}
*/
async text() {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
const buffer = await this.arrayBuffer();
return core.decode(new Uint8Array(buffer));
}
@@ -348,7 +347,7 @@
* @returns {Promise<ArrayBuffer>}
*/
async arrayBuffer() {
- webidl.assertBranded(this, BlobPrototype);
+ webidl.assertBranded(this, Blob);
const stream = this.stream();
const bytes = new Uint8Array(this.size);
let offset = 0;
@@ -362,7 +361,7 @@
[SymbolFor("Deno.customInspect")](inspect) {
return inspect(consoleInternal.createFilteredInspectProxy({
object: this,
- evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this),
+ evaluate: this instanceof Blob,
keys: [
"size",
"type",
@@ -372,22 +371,15 @@
}
webidl.configurePrototype(Blob);
- const BlobPrototype = Blob.prototype;
- webidl.converters["Blob"] = webidl.createInterfaceConverter(
- "Blob",
- Blob.prototype,
- );
+ webidl.converters["Blob"] = webidl.createInterfaceConverter("Blob", Blob);
webidl.converters["BlobPart"] = (V, opts) => {
// Union for ((ArrayBuffer or ArrayBufferView) or Blob or USVString)
if (typeof V == "object") {
- if (ObjectPrototypeIsPrototypeOf(BlobPrototype, V)) {
+ if (V instanceof Blob) {
return webidl.converters["Blob"](V, opts);
}
- if (
- ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) ||
- ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V)
- ) {
+ if (V instanceof ArrayBuffer || V instanceof SharedArrayBuffer) {
return webidl.converters["ArrayBuffer"](V, opts);
}
if (ArrayBufferIsView(V)) {
@@ -466,19 +458,18 @@
/** @returns {string} */
get name() {
- webidl.assertBranded(this, FilePrototype);
+ webidl.assertBranded(this, File);
return this[_Name];
}
/** @returns {number} */
get lastModified() {
- webidl.assertBranded(this, FilePrototype);
+ webidl.assertBranded(this, File);
return this[_LastModified];
}
}
webidl.configurePrototype(File);
- const FilePrototype = File.prototype;
webidl.converters["FilePropertyBag"] = webidl.createDictionaryConverter(
"FilePropertyBag",
@@ -602,8 +593,6 @@
blobFromObjectUrl,
getParts,
Blob,
- BlobPrototype,
File,
- FilePrototype,
};
})(this);
diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js
index 039d3395d..294d96ebd 100644
--- a/ext/web/10_filereader.js
+++ b/ext/web/10_filereader.js
@@ -28,14 +28,12 @@
MapPrototypeGet,
MapPrototypeSet,
ObjectDefineProperty,
- ObjectPrototypeIsPrototypeOf,
queueMicrotask,
StringFromCodePoint,
Symbol,
TypedArrayPrototypeSet,
TypeError,
Uint8Array,
- Uint8ArrayPrototype,
} = window.__bootstrap.primordials;
const state = Symbol("[[state]]");
@@ -118,10 +116,7 @@
// 4. If chunkPromise is fulfilled with an object whose done property is false
// and whose value property is a Uint8Array object, run these steps:
- if (
- !chunk.done &&
- ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk.value)
- ) {
+ if (!chunk.done && chunk.value instanceof Uint8Array) {
ArrayPrototypePush(chunks, chunk.value);
// TODO(bartlomieju): (only) If roughly 50ms have passed since last progress
@@ -265,7 +260,7 @@
}
#getEventHandlerFor(name) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
const maybeMap = this[handlerSymbol];
if (!maybeMap) return null;
@@ -274,7 +269,7 @@
}
#setEventHandlerFor(name, value) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
if (!this[handlerSymbol]) {
this[handlerSymbol] = new Map();
@@ -297,7 +292,7 @@
/** @returns {number} */
get readyState() {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
switch (this[state]) {
case "empty":
return FileReader.EMPTY;
@@ -311,17 +306,17 @@
}
get result() {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
return this[result];
}
get error() {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
return this[error];
}
abort() {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
// If context object's state is "empty" or if context object's state is "done" set context object's result to null and terminate this algorithm.
if (
this[state] === "empty" ||
@@ -354,7 +349,7 @@
/** @param {Blob} blob */
readAsArrayBuffer(blob) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
const prefix = "Failed to execute 'readAsArrayBuffer' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix });
this.#readOperation(blob, { kind: "ArrayBuffer" });
@@ -362,7 +357,7 @@
/** @param {Blob} blob */
readAsBinaryString(blob) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
const prefix = "Failed to execute 'readAsBinaryString' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix });
// alias for readAsArrayBuffer
@@ -371,7 +366,7 @@
/** @param {Blob} blob */
readAsDataURL(blob) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
const prefix = "Failed to execute 'readAsDataURL' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix });
// alias for readAsArrayBuffer
@@ -383,7 +378,7 @@
* @param {string} [encoding]
*/
readAsText(blob, encoding = undefined) {
- webidl.assertBranded(this, FileReaderPrototype);
+ webidl.assertBranded(this, FileReader);
const prefix = "Failed to execute 'readAsText' on 'FileReader'";
webidl.requiredArguments(arguments.length, 1, { prefix });
if (encoding !== undefined) {
@@ -440,7 +435,6 @@
}
webidl.configurePrototype(FileReader);
- const FileReaderPrototype = FileReader.prototype;
ObjectDefineProperty(FileReader, "EMPTY", {
writable: false,
diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js
index 8242f85f3..ef332dd7a 100644
--- a/ext/web/13_message_port.js
+++ b/ext/web/13_message_port.js
@@ -10,21 +10,19 @@
((window) => {
const core = window.Deno.core;
- const { InterruptedPrototype } = core;
+ const { Interrupted } = core;
const webidl = window.__bootstrap.webidl;
const { setEventTargetData } = window.__bootstrap.eventTarget;
const { defineEventHandler } = window.__bootstrap.event;
const { DOMException } = window.__bootstrap.domException;
const {
- ArrayBufferPrototype,
+ ArrayBuffer,
ArrayPrototypeFilter,
ArrayPrototypeIncludes,
ArrayPrototypePush,
- ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
SymbolFor,
- SymbolIterator,
TypeError,
WeakSet,
WeakSetPrototypeAdd,
@@ -47,12 +45,12 @@
}
get port1() {
- webidl.assertBranded(this, MessageChannelPrototype);
+ webidl.assertBranded(this, MessageChannel);
return this.#port1;
}
get port2() {
- webidl.assertBranded(this, MessageChannelPrototype);
+ webidl.assertBranded(this, MessageChannel);
return this.#port2;
}
@@ -64,7 +62,6 @@
}
webidl.configurePrototype(MessageChannel);
- const MessageChannelPrototype = MessageChannel.prototype;
const _id = Symbol("id");
const _enabled = Symbol("enabled");
@@ -75,7 +72,7 @@
*/
function createMessagePort(id) {
const port = core.createHostObject();
- ObjectSetPrototypeOf(port, MessagePortPrototype);
+ ObjectSetPrototypeOf(port, MessagePort.prototype);
port[webidl.brand] = webidl.brand;
setEventTargetData(port);
port[_id] = id;
@@ -98,7 +95,7 @@
* @param {object[] | StructuredSerializeOptions} transferOrOptions
*/
postMessage(message, transferOrOptions = {}) {
- webidl.assertBranded(this, MessagePortPrototype);
+ webidl.assertBranded(this, MessagePort);
const prefix = "Failed to execute 'postMessage' on 'MessagePort'";
webidl.requiredArguments(arguments.length, 1, { prefix });
message = webidl.converters.any(message);
@@ -106,7 +103,7 @@
if (
webidl.type(transferOrOptions) === "Object" &&
transferOrOptions !== undefined &&
- transferOrOptions[SymbolIterator] !== undefined
+ transferOrOptions[Symbol.iterator] !== undefined
) {
const transfer = webidl.converters["sequence<object>"](
transferOrOptions,
@@ -132,7 +129,7 @@
}
start() {
- webidl.assertBranded(this, MessagePortPrototype);
+ webidl.assertBranded(this, MessagePort);
if (this[_enabled]) return;
(async () => {
this[_enabled] = true;
@@ -145,7 +142,7 @@
this[_id],
);
} catch (err) {
- if (ObjectPrototypeIsPrototypeOf(InterruptedPrototype, err)) break;
+ if (err instanceof Interrupted) break;
throw err;
}
if (data === null) break;
@@ -163,7 +160,7 @@
data: message,
ports: ArrayPrototypeFilter(
transferables,
- (t) => ObjectPrototypeIsPrototypeOf(MessagePortPrototype, t),
+ (t) => t instanceof MessagePort,
),
});
this.dispatchEvent(event);
@@ -173,7 +170,7 @@
}
close() {
- webidl.assertBranded(this, MessagePortPrototype);
+ webidl.assertBranded(this, MessagePort);
if (this[_id] !== null) {
core.close(this[_id]);
this[_id] = null;
@@ -187,7 +184,6 @@
defineEventHandler(MessagePort.prototype, "messageerror");
webidl.configurePrototype(MessagePort);
- const MessagePortPrototype = MessagePort.prototype;
/**
* @returns {[number, number]}
@@ -249,7 +245,7 @@
function serializeJsMessageData(data, transferables) {
const transferedArrayBuffers = ArrayPrototypeFilter(
transferables,
- (a) => ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, a),
+ (a) => a instanceof ArrayBuffer,
);
for (const arrayBuffer of transferedArrayBuffers) {
@@ -270,7 +266,7 @@
serializedData = core.serialize(data, {
hostObjects: ArrayPrototypeFilter(
transferables,
- (a) => ObjectPrototypeIsPrototypeOf(MessagePortPrototype, a),
+ (a) => a instanceof MessagePort,
),
transferedArrayBuffers,
});
@@ -283,8 +279,8 @@
let arrayBufferI = 0;
for (const transferable of transferables) {
- if (ObjectPrototypeIsPrototypeOf(MessagePortPrototype, transferable)) {
- webidl.assertBranded(transferable, MessagePortPrototype);
+ if (transferable instanceof MessagePort) {
+ webidl.assertBranded(transferable, MessagePort);
const id = transferable[_id];
if (id === null) {
throw new DOMException(
@@ -297,9 +293,7 @@
kind: "messagePort",
data: id,
});
- } else if (
- ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, transferable)
- ) {
+ } else if (transferable instanceof ArrayBuffer) {
ArrayPrototypePush(serializedTransferables, {
kind: "arrayBuffer",
data: transferedArrayBuffers[arrayBufferI],
@@ -345,7 +339,6 @@
window.__bootstrap.messagePort = {
MessageChannel,
MessagePort,
- MessagePortPrototype,
deserializeJsMessageData,
serializeJsMessageData,
structuredClone,
diff --git a/ext/web/14_compression.js b/ext/web/14_compression.js
index 081495894..1a0f77e66 100644
--- a/ext/web/14_compression.js
+++ b/ext/web/14_compression.js
@@ -53,18 +53,17 @@
}
get readable() {
- webidl.assertBranded(this, CompressionStreamPrototype);
+ webidl.assertBranded(this, CompressionStream);
return this.#transform.readable;
}
get writable() {
- webidl.assertBranded(this, CompressionStreamPrototype);
+ webidl.assertBranded(this, CompressionStream);
return this.#transform.writable;
}
}
webidl.configurePrototype(CompressionStream);
- const CompressionStreamPrototype = CompressionStream.prototype;
class DecompressionStream {
#transform;
@@ -99,12 +98,12 @@
}
get readable() {
- webidl.assertBranded(this, DecompressionStreamPrototype);
+ webidl.assertBranded(this, DecompressionStream);
return this.#transform.readable;
}
get writable() {
- webidl.assertBranded(this, DecompressionStreamPrototype);
+ webidl.assertBranded(this, DecompressionStream);
return this.#transform.writable;
}
}
@@ -116,7 +115,6 @@
}
webidl.configurePrototype(DecompressionStream);
- const DecompressionStreamPrototype = DecompressionStream.prototype;
window.__bootstrap.compression = {
CompressionStream,