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