feat(op_crates/web) EventTarget signal support (#8616)

Fixes: https://github.com/denoland/deno/issues/8606
This commit is contained in:
Benjamin Gruenbaum 2020-12-04 19:47:08 +02:00 committed by GitHub
parent ae21a9569b
commit 71ef5a9cd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 3 deletions

View file

@ -106,6 +106,25 @@ function eventIsTrustedGetterName() {
assert(e.message.includes("not a constructor"));
}
}
function eventAbortSignal() {
let count = 0;
function handler() {
count++;
}
const et = new EventTarget();
const controller = new AbortController();
et.addEventListener("test", handler, { signal: controller.signal });
et.dispatchEvent(new Event("test"));
assert(count === 1);
et.dispatchEvent(new Event("test"));
assert(count === 2);
controller.abort();
et.dispatchEvent(new Event("test"));
assert(count === 2);
et.addEventListener("test", handler, { signal: controller.signal });
et.dispatchEvent(new Event("test"));
assert(count === 2);
}
function main() {
eventInitializedWithType();
eventInitializedWithTypeAndDict();
@ -116,6 +135,7 @@ function main() {
eventInitializedWithNonStringType();
eventIsTrusted();
eventIsTrustedGetterName();
eventAbortSignal();
}
main();