aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigGlobalObject.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-05-26 03:32:28 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-26 03:32:28 -0700
commit0f2a79b9c1a5b0142f8099e94712799607e8990f (patch)
tree99077706398898df3abda3a9a45a9abc0093e8fc /src/bun.js/bindings/ZigGlobalObject.cpp
parent62f05ec1037009cc1724674277df82f1a9ec75ab (diff)
downloadbun-0f2a79b9c1a5b0142f8099e94712799607e8990f.tar.gz
bun-0f2a79b9c1a5b0142f8099e94712799607e8990f.tar.zst
bun-0f2a79b9c1a5b0142f8099e94712799607e8990f.zip
Fix crash in test.todo + remove JSC C API usages in bun:test (#3079)
* Fix crash in test.todo * remove usages of JSC C API in bun:test * Remove additional JSC-C API usages * fix `make headers` * URLSearchParams.length * FormData length * URLSearchParams length * Fix `make headers` * very fancy length * Fix bug with exceptions being ignored sometimes * Add tests for extension toHaveLength --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 92568f1a9..f0ff9cf16 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -2041,6 +2041,17 @@ JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArraysFromIterator, (JSGlobalObject
return flattenArrayOfBuffersIntoArrayBuffer(globalObject, iter->getDirect(vm, vm.propertyNames->value));
}
+extern "C" JSC__JSValue Bun__Jest__createTestModuleObject(JSC::JSGlobalObject*);
+extern "C" JSC__JSValue Bun__Jest__createTestPreloadObject(JSC::JSGlobalObject*);
+extern "C" JSC__JSValue Bun__Jest__testPreloadObject(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->lazyPreloadTestModuleObject());
+}
+extern "C" JSC__JSValue Bun__Jest__testModuleObject(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->lazyTestModuleObject());
+}
+
static inline JSC__JSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue);
static inline JSC__JSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue)
{
@@ -2578,6 +2589,24 @@ void GlobalObject::finishCreation(VM& vm)
init.set(result.toObject(globalObject));
});
+ m_lazyTestModuleObject.initLater(
+ [](const Initializer<JSObject>& init) {
+ JSC::VM& vm = init.vm;
+ JSC::JSGlobalObject* globalObject = init.owner;
+
+ JSValue result = JSValue::decode(Bun__Jest__createTestModuleObject(globalObject));
+ init.set(result.toObject(globalObject));
+ });
+
+ m_lazyPreloadTestModuleObject.initLater(
+ [](const Initializer<JSObject>& init) {
+ JSC::VM& vm = init.vm;
+ JSC::JSGlobalObject* globalObject = init.owner;
+
+ JSValue result = JSValue::decode(Bun__Jest__createTestPreloadObject(globalObject));
+ init.set(result.toObject(globalObject));
+ });
+
// Change prototype from null to object for synthetic modules.
m_moduleNamespaceObjectStructure.initLater(
[](const Initializer<Structure>& init) {
@@ -3767,7 +3796,8 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_lazyRequireCacheObject.visit(visitor);
thisObject->m_vmModuleContextMap.visit(visitor);
thisObject->m_bunSleepThenCallback.visit(visitor);
-
+ thisObject->m_lazyTestModuleObject.visit(visitor);
+ thisObject->m_lazyPreloadTestModuleObject.visit(visitor);
thisObject->m_cachedGlobalObjectStructure.visit(visitor);
thisObject->m_cachedGlobalProxyStructure.visit(visitor);