From 4ec213b0aa1aeb1b3220ef4b65d8b94f54ddc7b9 Mon Sep 17 00:00:00 2001 From: Garcia Date: Fri, 2 Sep 2022 08:55:44 -0700 Subject: fix(ext/timers): create primordial `eval` (#15110) --- cli/tests/unit/timers_test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts index e6901a42c..735e53e0f 100644 --- a/cli/tests/unit/timers_test.ts +++ b/cli/tests/unit/timers_test.ts @@ -84,6 +84,27 @@ Deno.test(async function timeoutEvalNoScopeLeak() { Reflect.deleteProperty(global, "globalPromise"); }); +Deno.test(async function evalPrimordial() { + const global = globalThis as unknown as { + globalPromise: ReturnType; + }; + global.globalPromise = deferred(); + const originalEval = globalThis.eval; + let wasCalled = false; + globalThis.eval = (argument) => { + wasCalled = true; + return originalEval(argument); + }; + setTimeout( + "globalThis.globalPromise.resolve();" as unknown as () => void, + 0, + ); + await global.globalPromise; + assert(!wasCalled); + Reflect.deleteProperty(global, "globalPromise"); + globalThis.eval = originalEval; +}); + Deno.test(async function timeoutArgs() { const promise = deferred(); const arg = 1; -- cgit v1.2.3