From 5a23d176208bb38483b65b9420b18c8597fabfef Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 19 Mar 2023 14:08:20 -0700 Subject: Several bug fixes (#2427) * Fix test * Fix segfault when unexpected type is passed in `expect().toThrow` * Fix issues with request constructor * Don't bother cloning headers when its empty * woops * more tests * fix incorrect test * Make the fetch error messages better * Update response.zig * Fix test that failed on macOS * Fix test * Remove extra hash table lookups * Support running dummy registry directly cc @alexlamsl * Update test * Update test * fixup * Workaround crash in test runner * Fixup test * Fixup test * Update os.test.js --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/bindings.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/bun.js/bindings/bindings.cpp') diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 774c14d0c..a5af29128 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -700,6 +700,11 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, extern "C" { +bool WebCore__FetchHeaders__isEmpty(WebCore__FetchHeaders* arg0) +{ + return arg0->size() == 0; +} + void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool is_ssl, void* arg2) { if (is_ssl) { @@ -3566,11 +3571,14 @@ enum class BuiltinNamesMap : uint8_t { url, body, data, + toString, + redirect, }; static JSC::Identifier builtinNameMap(JSC::JSGlobalObject* globalObject, unsigned char name) { - auto clientData = WebCore::clientData(globalObject->vm()); + auto& vm = globalObject->vm(); + auto clientData = WebCore::clientData(vm); switch (static_cast(name)) { case BuiltinNamesMap::method: { return clientData->builtinNames().methodPublicName(); @@ -3590,7 +3598,24 @@ static JSC::Identifier builtinNameMap(JSC::JSGlobalObject* globalObject, unsigne case BuiltinNamesMap::data: { return clientData->builtinNames().dataPublicName(); } + case BuiltinNamesMap::toString: { + return vm.propertyNames->toString; + } + case BuiltinNamesMap::redirect: { + return clientData->builtinNames().redirectPublicName(); } + } +} + +JSC__JSValue JSC__JSValue__fastGetDirect_(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, unsigned char arg2) +{ + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + if (!value.isCell()) { + return JSValue::encode({}); + } + + return JSValue::encode( + value.getObject()->getDirect(globalObject->vm(), PropertyName(builtinNameMap(globalObject, arg2)))); } JSC__JSValue JSC__JSValue__fastGet_(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, unsigned char arg2) -- cgit v1.2.3