1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-13 11:02:19 -05:00
denoland-deno/ext/node/polyfills/internal_binding
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
..
_libuv_winerror.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
_listen.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
_node.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
_timingSafeEqual.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
_utils.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
ares.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
async_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
buffer.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
cares_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
connection_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
constants.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
crypto.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
handle_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
mod.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
node_file.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
node_options.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
pipe_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
README.md feat(ext/node): embed std/node into the snapshot (#17724) 2023-02-14 17:38:45 +01:00
stream_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
string_decoder.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
symbols.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
tcp_wrap.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
types.ts fix: strict type check for cross realms (#21669) 2024-01-04 20:34:55 +01:00
udp_wrap.ts fix(ext/node): UdpSocket ref and unref (#21777) 2024-01-04 20:34:55 +01:00
util.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
uv.ts chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00

Internal Bindings

The modules in this directory implement (simulate) C++ bindings implemented in the ./src/ directory of the Node.js repository.

These bindings are created in the Node.js source code by using NODE_MODULE_CONTEXT_AWARE_INTERNAL.

Please refer to https://github.com/nodejs/node/blob/master/src/README.md for further information.