From 971f09abe486185247e1faf4e8d1419ba2506b8d Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 23 May 2024 00:03:35 +0200 Subject: fix(runtime): use more null proto objects (#23921) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a primordialization effort to improve resistance against users tampering with the global `Object` prototype. --------- Co-authored-by: Bartek IwaƄczuk --- tests/unit/event_test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/unit/event_test.ts b/tests/unit/event_test.ts index c82873cf6..bd398fd41 100644 --- a/tests/unit/event_test.ts +++ b/tests/unit/event_test.ts @@ -141,3 +141,17 @@ Deno.test(function inspectEvent() { `Event {\n bubbles: false,\n cancelable: false,`, ); }); + +Deno.test("default argument is null prototype", () => { + const event = new Event("test"); + assertEquals(event.bubbles, false); + + // @ts-ignore this is on purpose to check if overriding prototype + // has effect on `Event. + Object.prototype.bubbles = true; + const event2 = new Event("test"); + assertEquals(event2.bubbles, false); + + // @ts-ignore this is done on purpose + delete Object.prototype.bubbles; +}); -- cgit v1.2.3