(t *testing.T)
| 1326 | } |
| 1327 | |
| 1328 | func TestRuntimeContextBootstrapOptions(t *testing.T) { |
| 1329 | rt := NewRuntime() |
| 1330 | defer rt.Close() |
| 1331 | |
| 1332 | typeOfSetTimeout := func(ctx *Context) string { |
| 1333 | v := ctx.Eval(`typeof globalThis.setTimeout`) |
| 1334 | require.NotNil(t, v) |
| 1335 | defer v.Free() |
| 1336 | require.False(t, v.IsException()) |
| 1337 | return v.ToString() |
| 1338 | } |
| 1339 | |
| 1340 | defaultCtx := rt.NewContext() |
| 1341 | require.NotNil(t, defaultCtx) |
| 1342 | require.Equal(t, "function", typeOfSetTimeout(defaultCtx)) |
| 1343 | defaultCtx.Close() |
| 1344 | |
| 1345 | bareCtx := rt.NewBareContext() |
| 1346 | require.NotNil(t, bareCtx) |
| 1347 | require.Equal(t, "undefined", typeOfSetTimeout(bareCtx)) |
| 1348 | require.True(t, bareCtx.BootstrapStdOS()) |
| 1349 | require.True(t, bareCtx.BootstrapTimers()) |
| 1350 | require.Equal(t, "function", typeOfSetTimeout(bareCtx)) |
| 1351 | bareCtx.Close() |
| 1352 | |
| 1353 | minimalCtx := rt.NewContextWithOptions(MinimalBootstrap()) |
| 1354 | require.NotNil(t, minimalCtx) |
| 1355 | require.Equal(t, "undefined", typeOfSetTimeout(minimalCtx)) |
| 1356 | require.True(t, minimalCtx.BootstrapTimers()) |
| 1357 | require.Equal(t, "function", typeOfSetTimeout(minimalCtx)) |
| 1358 | minimalCtx.Close() |
| 1359 | |
| 1360 | noBootstrapCtx := rt.NewContextWithOptions(NoBootstrap()) |
| 1361 | require.NotNil(t, noBootstrapCtx) |
| 1362 | require.Equal(t, "undefined", typeOfSetTimeout(noBootstrapCtx)) |
| 1363 | noBootstrapCtx.Close() |
| 1364 | |
| 1365 | customCtx := rt.NewContextWithOptions(DefaultBootstrap(), WithBootstrapTimers(false)) |
| 1366 | require.NotNil(t, customCtx) |
| 1367 | require.Equal(t, "undefined", typeOfSetTimeout(customCtx)) |
| 1368 | customCtx.Close() |
| 1369 | |
| 1370 | autoStdCtx := rt.NewContextWithOptions(WithBootstrapStdOS(false), WithBootstrapTimers(true)) |
| 1371 | require.NotNil(t, autoStdCtx) |
| 1372 | require.Equal(t, "function", typeOfSetTimeout(autoStdCtx)) |
| 1373 | autoStdCtx.Close() |
| 1374 | } |
| 1375 | |
| 1376 | func TestRuntimeContextBootstrapFailClosedAfterClose(t *testing.T) { |
| 1377 | var nilCtx *Context |
nothing calls this directly
no test coverage detected