Skip to content

Commit 5ace654

Browse files
authored
fix(node): return false from vm.isContext (#21568)
#20851 (comment) for `jsdom`
1 parent 4b6fc64 commit 5ace654

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cli/tests/unit_node/vm_test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2-
import { runInNewContext } from "node:vm";
2+
import { isContext, runInNewContext } from "node:vm";
33
import {
44
assertEquals,
55
assertThrows,
@@ -55,3 +55,15 @@ Deno.test({
5555
}
5656
},
5757
});
58+
59+
Deno.test({
60+
name: "vm isContext",
61+
fn() {
62+
// Currently we do not expose VM contexts so this is always false.
63+
const obj = {};
64+
assertEquals(isContext(obj), false);
65+
assertEquals(isContext(globalThis), false);
66+
const sandbox = runInNewContext("{}");
67+
assertEquals(isContext(sandbox), false);
68+
},
69+
});

ext/node/polyfills/vm.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export function runInThisContext(
7575
}
7676

7777
export function isContext(_maybeContext: any) {
78-
notImplemented("isContext");
78+
// TODO(@littledivy): Currently we do not expose contexts so this is always false.
79+
return false;
7980
}
8081

8182
export function compileFunction(_code: string, _params: any, _options: any) {

0 commit comments

Comments
 (0)