1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00
denoland-deno/ext
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
..
broadcast_channel fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
cache chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
console fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
cron chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
crypto fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
fetch fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
ffi fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
fs fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
http fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
io chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
kv fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
napi chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
net fix(ext/node): UdpSocket ref and unref (#21777) 2024-01-04 08:51:39 +05:30
node fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
tls chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
url chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
web fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
webgpu fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
webidl fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
websocket fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
webstorage chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00