1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/cli/tests/unit_node
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
..
_fs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
crypto chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
internal chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00: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-01 19:58:21 +00:00
assertion_error_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
async_hooks_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
buffer_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
child_process_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
console_test.ts fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
dgram_test.ts fix(ext/node): UdpSocket ref and unref (#21777) 2024-01-04 08:51:39 +05:30
events_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
fs_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
http2_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
http_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
module_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
net_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
os_test.ts fix(ext/node): implement os.machine (#21751) 2024-01-02 14:57:54 +01:00
path_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
perf_hooks_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
process_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
querystring_test.ts fix(ext/node): querystring stringify without encode callback (#21740) 2024-01-02 04:54:11 +00:00
readline_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
repl_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
stream_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
string_decoder_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
timers_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
tls_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
tty_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
util_test.ts fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
v8_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
vm_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
worker_threads_test.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
zlib_test.ts fix(node/zlib): accept dataview and buffer in zlib bindings (#21756) 2024-01-03 19:03:51 +05:30