Don't include rawKeys in the Headers prototype

This commit is contained in:
Kai Tamkun
2025-02-20 14:41:51 -08:00
parent bab4b9fb51
commit 67b71fae98
3 changed files with 13 additions and 4 deletions

View File

@@ -71,7 +71,6 @@ static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_has);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_set);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_entries);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_keys);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_rawKeys);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_values);
static JSC_DECLARE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_forEach);
@@ -219,6 +218,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_getAll, (JSGlobalObject
auto& impl = castedThis->wrapped();
if (name->length() != "set-cookie"_s.length() || name->convertToASCIILowercase() != "set-cookie"_s) {
throwTypeError(lexicalGlobalObject, scope, "Only \"set-cookie\" is supported."_s);
return {};
}
auto values = impl.getSetCookieHeaders();
@@ -311,7 +311,6 @@ static const HashTableValue JSFetchHeadersPrototypeTableValues[] = {
{ "set"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_set, 2 } },
{ "entries"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_entries, 0 } },
{ "keys"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_keys, 0 } },
{ "rawKeys"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_rawKeys, 0 } },
{ "values"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_values, 0 } },
{ "forEach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_forEach, 1 } },
{ "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_toJSON, 0 } },
@@ -585,11 +584,18 @@ JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_keys, (JSC::JSGlobalObj
return IDLOperation<JSFetchHeaders>::call<jsFetchHeadersPrototypeFunction_keysCaller>(*lexicalGlobalObject, *callFrame, "keys");
}
JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_rawKeys, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
JSC_DEFINE_HOST_FUNCTION(jsFetchHeaders_getRawKeys, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
VM& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
auto* thisObject = castThisValue<JSFetchHeaders>(*lexicalGlobalObject, callFrame->thisValue());
if (!thisObject) {
throwTypeError(lexicalGlobalObject, scope, "\"this\" must be an instance of Headers"_s);
return {};
}
FetchHeaders& headers = thisObject->wrapped();
JSArray* outArray = JSC::JSArray::create(vm, lexicalGlobalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous), headers.size());

View File

@@ -100,4 +100,6 @@ template<> struct JSDOMWrapperConverterTraits<FetchHeaders> {
JSC::EncodedJSValue fetchHeadersGetSetCookie(JSC::JSGlobalObject* lexicalGlobalObject, VM& vm, WebCore::FetchHeaders* impl);
JSC_DEFINE_HOST_FUNCTION(jsFetchHeaders_getRawKeys, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame));
} // namespace WebCore

View File

@@ -109,6 +109,7 @@ const {
let cluster;
const sendHelper = $newZigFunction("node_cluster_binding.zig", "sendHelperChild", 3);
const getBunServerAllClosedPromise = $newZigFunction("node_http_binding.zig", "getBunServerAllClosedPromise", 1);
const getRawKeys = $newCppFunction("JSFetchHeaders.cpp", "jsFetchHeaders_getRawKeys", 0);
// TODO: make this more robust.
function isAbortError(err) {
@@ -1609,7 +1610,7 @@ const OutgoingMessagePrototype = {
getRawHeaderNames() {
var headers = this[headersSymbol];
if (!headers) return [];
return headers.rawKeys();
return getRawKeys.$call(headers);
},
getHeaders() {