From d0cd7a39a2d05343c5501dc286bb59096659654f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Fri, 19 Apr 2019 09:56:33 +0800 Subject: avoid prototype builtin hasOwnProperty (#2144) --- js/event_target_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/event_target_test.ts') diff --git a/js/event_target_test.ts b/js/event_target_test.ts index 71c872dab..aedbbf72a 100644 --- a/js/event_target_test.ts +++ b/js/event_target_test.ts @@ -92,3 +92,21 @@ test(function toStringShouldBeWebCompatibility() { const target = new EventTarget(); assertEquals(target.toString(), "[object EventTarget]"); }); + +test(function dispatchEventShouldNotThrowError() { + let hasThrown = false; + + try { + const target = new EventTarget(); + const event = new Event("hasOwnProperty", { + bubbles: true, + cancelable: false + }); + target.addEventListener("hasOwnProperty", () => {}); + target.dispatchEvent(event); + } catch { + hasThrown = true; + } + + assertEquals(hasThrown, false); +}); -- cgit v1.2.3