summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/event_target_test.ts37
1 files changed, 36 insertions, 1 deletions
diff --git a/cli/tests/unit/event_target_test.ts b/cli/tests/unit/event_target_test.ts
index dfc28605b..f732003ec 100644
--- a/cli/tests/unit/event_target_test.ts
+++ b/cli/tests/unit/event_target_test.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-window-prefix
-import { assertEquals } from "./test_util.ts";
+import { assertEquals, assertThrows } from "./test_util.ts";
Deno.test(function addEventListenerTest() {
const document = new EventTarget();
@@ -244,3 +244,38 @@ Deno.test(function eventTargetDispatchShouldSetTargetInListener() {
target.dispatchEvent(event);
assertEquals(called, true);
});
+
+Deno.test(function eventTargetAddEventListenerGlobalAbort() {
+ return new Promise((resolve) => {
+ const c = new AbortController();
+
+ c.signal.addEventListener("abort", () => resolve());
+ addEventListener("test", () => {}, { signal: c.signal });
+ c.abort();
+ });
+});
+
+Deno.test(function eventTargetBrandChecking() {
+ const self = {};
+
+ assertThrows(
+ () => {
+ EventTarget.prototype.addEventListener.call(self, "test", null);
+ },
+ TypeError,
+ );
+
+ assertThrows(
+ () => {
+ EventTarget.prototype.removeEventListener.call(self, "test", null);
+ },
+ TypeError,
+ );
+
+ assertThrows(
+ () => {
+ EventTarget.prototype.dispatchEvent.call(self, new Event("test"));
+ },
+ TypeError,
+ );
+});