1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/ext/node/polyfills/internal
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
..
console fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
crypto chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
dns chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
fs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
process chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
readline chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
streams chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
test chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
util fix: strict type check for cross realms (#21669) 2024-01-04 09:42:38 +05:30
assert.mjs refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme for snapshotted modules (#18041) 2023-03-08 12:44:54 +01:00
async_hooks.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
buffer.d.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
buffer.mjs fix(ext/node): fix Buffer.copy when sourceStart > source.length (#21345) 2023-11-28 22:28:07 +09:00
child_process.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
cli_table.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
constants.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
dgram.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
dtrace.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
error_codes.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
errors.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
event_target.mjs chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
fixed_queue.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
hide_stack_frames.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
http.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
idna.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
net.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
normalize_encoding.mjs chore(ext/node): disable prefer-primordials on a per-file basis (#19553) 2023-06-27 15:18:22 +09:00
options.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
primordials.mjs chore(ext/node): disable prefer-primordials on a per-file basis (#19553) 2023-06-27 15:18:22 +09:00
querystring.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
stream_base_commons.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
timers.mjs refactor: pull 'core', 'internals', 'primordials' from ES module (#21462) 2023-12-07 14:21:01 +01:00
url.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
util.mjs chore: upgrade to dprint 0.39 (#19768) 2023-07-08 18:34:08 +00:00
validators.mjs refactor: pull 'core', 'internals', 'primordials' from ES module (#21462) 2023-12-07 14:21:01 +01:00