diff options
author | justjavac <justjavac@gmail.com> | 2019-06-11 15:50:36 +0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-06-11 10:09:33 -0400 |
commit | cb581620522febe618cbf084b0dc3428479e84a9 (patch) | |
tree | 0cc7d6f4f0c626921b8cee13db5a8af87ef8e433 /js/timers_test.ts | |
parent | 0efb7c2ab7b9705a9f5f177b4dc170c1abbd97ed (diff) |
set setTimeout callback's this to window object
Diffstat (limited to 'js/timers_test.ts')
-rw-r--r-- | js/timers_test.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/js/timers_test.ts b/js/timers_test.ts index 7769be010..cbdc6eaba 100644 --- a/js/timers_test.ts +++ b/js/timers_test.ts @@ -165,3 +165,15 @@ test(async function fireCallbackImmediatelyWhenDelayOverMaxValue(): Promise< await waitForMs(1); assertEquals(count, 1); }); + +test(async function timeoutCallbackThis(): Promise<void> { + const { promise, resolve } = deferred(); + const obj = { + foo(): void { + assertEquals(this, window); + resolve(); + } + }; + setTimeout(obj.foo, 1); + await promise; +}); |