summaryrefslogtreecommitdiff
path: root/cli/tests/unit/flash_test.ts
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2022-10-29 18:25:23 +0900
committerGitHub <noreply@github.com>2022-10-29 18:25:23 +0900
commit59ac110edd1f376bed7fa6bbdbe2ee09c266bf74 (patch)
treeda654d1ecb6141b620141d634d99ca34c6d568db /cli/tests/unit/flash_test.ts
parentedaceecec771cf0395639175b5a21d20530f6080 (diff)
fix(core): fix APIs not to be affected by `Promise.prototype.then` modification (#16326)
Diffstat (limited to 'cli/tests/unit/flash_test.ts')
-rw-r--r--cli/tests/unit/flash_test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index 375fdb8f3..e2e64dfe3 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -2227,6 +2227,32 @@ Deno.test(
},
);
+Deno.test(
+ { permissions: { net: true } },
+ async function serveWithPromisePrototypeThenOverride() {
+ const originalThen = Promise.prototype.then;
+ try {
+ Promise.prototype.then = () => {
+ throw new Error();
+ };
+ const ac = new AbortController();
+ const listeningPromise = deferred();
+ const server = Deno.serve({
+ handler: (_req) => new Response("ok"),
+ hostname: "localhost",
+ port: 4501,
+ signal: ac.signal,
+ onListen: onListen(listeningPromise),
+ onError: createOnErrorCb(ac),
+ });
+ ac.abort();
+ await server;
+ } finally {
+ Promise.prototype.then = originalThen;
+ }
+ },
+);
+
// https://github.com/denoland/deno/issues/15549
Deno.test(
{ permissions: { net: true } },