MCPcopy Create free account
hub / github.com/buke/quickjs-go / TestBridgeMappingCorruptionFailClosed

Function TestBridgeMappingCorruptionFailClosed

bridge_test.go:116–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestBridgeMappingCorruptionFailClosed(t *testing.T) {
117 rt := NewRuntime()
118 defer rt.Close()
119 ctx := rt.NewContext()
120 defer ctx.Close()
121
122 require.NotNil(t, getContextFromJS(ctx.ref))
123 require.NotNil(t, getRuntimeFromJS(rt.ref))
124
125 contextMapping.Store(ctx.ref, "corrupted-context")
126 require.Nil(t, getContextFromJS(ctx.ref))
127
128 runtimeMapping.Store(rt.ref, "corrupted-runtime")
129 require.Nil(t, getRuntimeFromJS(rt.ref))
130 require.NotPanics(t, func() {
131 _ = goInterruptHandler(rt.ref)
132 })
133
134 registerContext(ctx.ref, ctx)
135 registerRuntime(rt.ref, rt)
136
137 fn := ctx.NewFunction(func(ctx *Context, this *Value, args []*Value) *Value {
138 return ctx.NewString("ok")
139 })
140 ctx.Globals().Set("__bridge_boundary_fn", fn)
141
142 result := ctx.Eval(`
143 try {
144 __bridge_boundary_fn();
145 "ok";
146 } catch (e) {
147 String(e);
148 }
149 `)
150 defer result.Free()
151 require.False(t, result.IsException())
152 require.Equal(t, "ok", result.ToString())
153}
154
155func TestResolveClassObjectFromOpaqueContracts(t *testing.T) {
156 rt := NewRuntime()

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
NewFunctionMethod · 0.95
NewStringMethod · 0.95
GlobalsMethod · 0.95
EvalMethod · 0.95
NewRuntimeFunction · 0.85
getContextFromJSFunction · 0.85
getRuntimeFromJSFunction · 0.85
goInterruptHandlerFunction · 0.85
registerContextFunction · 0.85

Tested by

no test coverage detected