diff --git a/test/napi/napi-app/main.js b/test/napi/napi-app/main.js index 50a8796d4050f..fa33b106f6ad6 100644 --- a/test/napi/napi-app/main.js +++ b/test/napi/napi-app/main.js @@ -14,6 +14,8 @@ if (typeof fn !== "function") { // pass GC runner as first argument try { + // napi.test.ts:147 tries to read this variable and shouldn't be able to + let shouldNotExist = 5; const result = fn.apply(null, [ () => { if (process.isBun) { diff --git a/test/napi/napi.test.ts b/test/napi/napi.test.ts index 15faf07e26bae..df6bc413a996d 100644 --- a/test/napi/napi.test.ts +++ b/test/napi/napi.test.ts @@ -142,6 +142,10 @@ describe("napi", () => { it("propagates exceptions", () => { checkSameOutput("eval_wrapper", ["(()=>{ throw new TypeError('oops'); })()"]); }); + it("cannot see locals from around its invocation", () => { + // variable is declared on main.js:18, but it should not be in scope for the eval'd code + checkSameOutput("eval_wrapper", ["shouldNotExist"]); + }); }); });