From f867a7e7c19c4712a40432a0d924eec3662cdef8 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 22 Jul 2024 15:59:57 -0700 Subject: [PATCH] fix: headers unused code and state transition invariants --- builtins/web/fetch/headers.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/builtins/web/fetch/headers.cpp b/builtins/web/fetch/headers.cpp index c682bc0..69f18bd 100644 --- a/builtins/web/fetch/headers.cpp +++ b/builtins/web/fetch/headers.cpp @@ -283,18 +283,12 @@ static bool switch_mode(JSContext* cx, HandleObject self, const Headers::Mode mo } if (current_mode == Headers::Mode::Uninitialized) { - if (mode == Headers::Mode::ContentOnly) { - RootedObject map(cx, JS::NewMapObject(cx)); - if (!map) { - return false; - } - SetReservedSlot(self, static_cast(Headers::Slots::Entries), ObjectValue(*map)); - } else { - MOZ_ASSERT(mode == Headers::Mode::HostOnly); - auto handle = new host_api::HttpHeaders(Headers::guard(self)); - SetReservedSlot(self, static_cast(Headers::Slots::Handle), PrivateValue(handle)); + MOZ_ASSERT(mode == Headers::Mode::ContentOnly); + RootedObject map(cx, JS::NewMapObject(cx)); + if (!map) { + return false; } - + SetReservedSlot(self, static_cast(Headers::Slots::Entries), ObjectValue(*map)); SetReservedSlot(self, static_cast(Headers::Slots::Mode), JS::Int32Value(static_cast(mode))); return true; } @@ -403,8 +397,6 @@ static bool switch_mode(JSContext* cx, HandleObject self, const Headers::Mode mo auto handle = get_handle(self); delete handle; SetReservedSlot(self, static_cast(Headers::Slots::Handle), PrivateValue(nullptr)); - SetReservedSlot(self, static_cast(Headers::Slots::Mode), - JS::Int32Value(static_cast(Headers::Mode::CachedInContent))); } SetReservedSlot(self, static_cast(Headers::Slots::Mode),