Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): return false from vm.isContext #21568

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cli/tests/unit_node/vm_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { runInNewContext } from "node:vm";
import { isContext, runInNewContext } from "node:vm";
import {
assertEquals,
assertThrows,
Expand Down Expand Up @@ -55,3 +55,15 @@ Deno.test({
}
},
});

Deno.test({
name: "vm isContext",
fn() {
// Currently we do not expose VM contexts so this is always false.
const obj = {};
assertEquals(isContext(obj), false);
assertEquals(isContext(globalThis), false);
const sandbox = runInNewContext("{}");
assertEquals(isContext(sandbox), false);
},
});
3 changes: 2 additions & 1 deletion ext/node/polyfills/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export function runInThisContext(
}

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

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