1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-06 22:35:51 -05:00
denoland-deno/cli/tests/unit_node
Kenta Moriuchi ab60d9e6a3
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 20:34:55 +01:00
..
_fs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
crypto chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
internal chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
testdata fix(ext/node): sign with PEM private keys (#21287) 2023-12-03 09:58:13 +05:30
_test_utils.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
assertion_error_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
async_hooks_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
buffer_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
child_process_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
console_test.ts fix: strict type check for cross realms (#21669) 2024-01-04 20:34:55 +01:00
dgram_test.ts fix(ext/node): UdpSocket ref and unref (#21777) 2024-01-04 20:34:55 +01:00
events_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
fs_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
http2_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
http_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
module_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
net_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
os_test.ts fix(ext/node): implement os.machine (#21751) 2024-01-04 20:34:52 +01:00
path_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
perf_hooks_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
process_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
querystring_test.ts fix(ext/node): querystring stringify without encode callback (#21740) 2024-01-04 20:34:52 +01:00
readline_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
repl_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
stream_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
string_decoder_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
timers_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
tls_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
tty_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
util_test.ts fix: strict type check for cross realms (#21669) 2024-01-04 20:34:55 +01:00
v8_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
vm_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
worker_threads_test.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
zlib_test.ts fix(node/zlib): accept dataview and buffer in zlib bindings (#21756) 2024-01-04 20:34:54 +01:00