1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/runtime/js
Kenta Moriuchi b2cd254c35
fix: strict type check for cross realms (#21669)
Deno v1.39 introduces `vm.runInNewContext`. This may cause problems when
using `Object.prototype.isPrototypeOf` to check built-in types.

```js
import vm from "node:vm";

const err = new Error();
const crossErr = vm.runInNewContext(`new Error()`);

console.assert( !(crossErr instanceof Error) );
console.assert( Object.getPrototypeOf(err) !== Object.getPrototypeOf(crossErr) );
```

This PR changes to check using internal slots solves them.

---

current: 

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error {}
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
Date {}
```

this PR:

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error: message
    at <anonymous>:1:1
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
2018-12-10T02:26:59.002Z
```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-04 09:42:38 +05:30
..
01_errors.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
01_version.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
06_util.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
10_permissions.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
11_workers.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
13_buffer.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
30_os.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
40_fs_events.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
40_http.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
40_process.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
40_signals.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
40_tty.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
41_prompt.js Revert "fix(runtime): Make native modal keyboard interaction consistent with browsers" (#21739) 2024-01-02 09:36:05 +05:30
90_deno_ns.js chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
98_global_scope.js fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
99_main.js fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
README.md feat: add --location=<href> and globalThis.location (#7369) 2021-01-07 19:06:08 +01:00

Runtime JavaScript Code

This directory contains Deno runtime code written in plain JavaScript.

Each file is a plain, old script, not ES modules. The reason is that snapshotting ES modules is much harder, especially if one needs to manipulate global scope (like in case of Deno).

Each file is prefixed with a number, telling in which order scripts should be loaded into V8 isolate. This is temporary solution and we're striving not to require specific order (though it's not 100% obvious if that's feasible).

Deno Web APIs

This directory facilities Web APIs that are available in Deno.

Please note, that some implementations might not be completely aligned with specification.

Some Web APIs are using ops under the hood, eg. console, performance.

Implemented Web APIs