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

https://github.com/denoland/deno/issues/20851#issuecomment-1779226106
for `jsdom`
This commit is contained in:
Divy Srivastava 2023-12-14 15:49:50 +05:30 committed by GitHub
parent 4b6fc64646
commit 5ace65485f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -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,
@ -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);
},
});

View file

@ -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) {