summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/06_util.js11
-rw-r--r--runtime/js/11_workers.js12
-rw-r--r--runtime/js/30_fs.js4
-rw-r--r--runtime/js/40_fs_events.js9
-rw-r--r--runtime/js/40_testing.js9
-rw-r--r--runtime/js/99_main.js15
6 files changed, 39 insertions, 21 deletions
diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js
index 9b255615e..e934c4f0e 100644
--- a/runtime/js/06_util.js
+++ b/runtime/js/06_util.js
@@ -3,14 +3,15 @@
((window) => {
const {
- StringPrototypeReplace,
- TypeError,
- Promise,
decodeURIComponent,
Error,
+ ObjectPrototypeIsPrototypeOf,
+ Promise,
+ StringPrototypeReplace,
+ TypeError,
} = window.__bootstrap.primordials;
const { build } = window.__bootstrap.build;
- const { URL } = window.__bootstrap.url;
+ const { URLPrototype } = window.__bootstrap.url;
let logDebug = false;
let logSource = "JS";
@@ -93,7 +94,7 @@
}
function pathFromURL(pathOrUrl) {
- if (pathOrUrl instanceof URL) {
+ if (ObjectPrototypeIsPrototypeOf(URLPrototype, pathOrUrl)) {
if (pathOrUrl.protocol != "file:") {
throw new TypeError("Must be a file URL.");
}
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js
index 4510004d6..80e85a3a1 100644
--- a/runtime/js/11_workers.js
+++ b/runtime/js/11_workers.js
@@ -5,6 +5,7 @@
const core = window.Deno.core;
const {
Error,
+ ObjectPrototypeIsPrototypeOf,
StringPrototypeStartsWith,
String,
SymbolIterator,
@@ -16,8 +17,11 @@
const { serializePermissions } = window.__bootstrap.permissions;
const { log } = window.__bootstrap.util;
const { defineEventHandler } = window.__bootstrap.event;
- const { deserializeJsMessageData, serializeJsMessageData } =
- window.__bootstrap.messagePort;
+ const {
+ deserializeJsMessageData,
+ serializeJsMessageData,
+ MessagePortPrototype,
+ } = window.__bootstrap.messagePort;
function createWorker(
specifier,
@@ -199,7 +203,9 @@
const event = new MessageEvent("message", {
cancelable: false,
data: message,
- ports: transferables.filter((t) => t instanceof MessagePort),
+ ports: transferables.filter((t) =>
+ ObjectPrototypeIsPrototypeOf(MessagePortPrototype, t)
+ ),
});
this.dispatchEvent(event);
}
diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js
index bdd575f19..51f2c411e 100644
--- a/runtime/js/30_fs.js
+++ b/runtime/js/30_fs.js
@@ -5,7 +5,9 @@
const core = window.Deno.core;
const {
Date,
+ DatePrototype,
MathTrunc,
+ ObjectPrototypeIsPrototypeOf,
SymbolAsyncIterator,
SymbolIterator,
} = window.__bootstrap.primordials;
@@ -277,7 +279,7 @@
}
function toUnixTimeFromEpoch(value) {
- if (value instanceof Date) {
+ if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
const time = value.valueOf();
const seconds = MathTrunc(time / 1e3);
const nanoseconds = MathTrunc(time - (seconds * 1e3)) * 1e6;
diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js
index 27825eaac..939d3ac7b 100644
--- a/runtime/js/40_fs_events.js
+++ b/runtime/js/40_fs_events.js
@@ -3,9 +3,10 @@
((window) => {
const core = window.Deno.core;
- const { errors } = window.__bootstrap.errors;
+ const { BadResourcePrototype, InterruptedPrototype } = core;
const {
ArrayIsArray,
+ ObjectPrototypeIsPrototypeOf,
PromiseResolve,
SymbolAsyncIterator,
} = window.__bootstrap.primordials;
@@ -28,9 +29,11 @@
? { value, done: false }
: { value: undefined, done: true };
} catch (error) {
- if (error instanceof errors.BadResource) {
+ if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error)) {
return { value: undefined, done: true };
- } else if (error instanceof errors.Interrupted) {
+ } else if (
+ ObjectPrototypeIsPrototypeOf(InterruptedPrototype, error)
+ ) {
return { value: undefined, done: true };
}
throw error;
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index 5979a523e..62eb1e9a9 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -9,14 +9,15 @@
const { serializePermissions } = window.__bootstrap.permissions;
const { assert } = window.__bootstrap.util;
const {
- AggregateError,
+ AggregateErrorPrototype,
ArrayPrototypeFilter,
ArrayPrototypePush,
ArrayPrototypeShift,
ArrayPrototypeSome,
DateNow,
Error,
- Function,
+ FunctionPrototype,
+ ObjectPrototypeIsPrototypeOf,
Number,
ObjectKeys,
Promise,
@@ -530,7 +531,7 @@ finishing test case.`;
}
function formatError(error) {
- if (error instanceof AggregateError) {
+ if (ObjectPrototypeIsPrototypeOf(AggregateErrorPrototype, error)) {
const message = error
.errors
.map((error) =>
@@ -984,7 +985,7 @@ finishing test case.`;
/** @returns {TestStepDefinition} */
function getDefinition() {
if (typeof nameOrTestDefinition === "string") {
- if (!(fn instanceof Function)) {
+ if (!(ObjectPrototypeIsPrototypeOf(FunctionPrototype, fn))) {
throw new TypeError("Expected function for second argument.");
}
return {
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index ba2b36705..5a4d7e989 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -16,6 +16,7 @@ delete Object.prototype.__proto__;
ObjectDefineProperty,
ObjectDefineProperties,
ObjectFreeze,
+ ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
PromiseResolve,
Symbol,
@@ -142,7 +143,9 @@ delete Object.prototype.__proto__;
const msgEvent = new MessageEvent("message", {
cancelable: false,
data: message,
- ports: transferables.filter((t) => t instanceof MessagePort),
+ ports: transferables.filter((t) =>
+ ObjectPrototypeIsPrototypeOf(messagePort.MessagePortPrototype, t)
+ ),
});
try {
@@ -311,7 +314,7 @@ delete Object.prototype.__proto__;
configurable: true,
enumerable: true,
get() {
- webidl.assertBranded(this, Navigator);
+ webidl.assertBranded(this, NavigatorPrototype);
return webgpu.gpu;
},
},
@@ -319,11 +322,12 @@ delete Object.prototype.__proto__;
configurable: true,
enumerable: true,
get() {
- webidl.assertBranded(this, Navigator);
+ webidl.assertBranded(this, NavigatorPrototype);
return numCpus;
},
},
});
+ const NavigatorPrototype = Navigator.prototype;
class WorkerNavigator {
constructor() {
@@ -342,7 +346,7 @@ delete Object.prototype.__proto__;
configurable: true,
enumerable: true,
get() {
- webidl.assertBranded(this, WorkerNavigator);
+ webidl.assertBranded(this, WorkerNavigatorPrototype);
return webgpu.gpu;
},
},
@@ -350,11 +354,12 @@ delete Object.prototype.__proto__;
configurable: true,
enumerable: true,
get() {
- webidl.assertBranded(this, WorkerNavigator);
+ webidl.assertBranded(this, WorkerNavigatorPrototype);
return numCpus;
},
},
});
+ const WorkerNavigatorPrototype = WorkerNavigator.prototype;
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope
const windowOrWorkerGlobalScope = {