Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 230721f

Browse files
committed
Rename execution context names to world
1 parent 16b4632 commit 230721f

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

common/execution_context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ const evaluationScriptURL = "__xk6_browser_evaluation_script__"
3939
var sourceURLRegex = regexp.MustCompile(`^(?s)[\040\t]*//[@#] sourceURL=\s*(\S*?)\s*$`)
4040

4141
const (
42-
mainExecutionContext = "main"
43-
utilityExecutionContext = "utility"
42+
mainWorld = "main"
43+
utilityWorld = "utility"
4444
)
4545

4646
// ExecutionContext represents a JS execution context

common/frame.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (f *Frame) document() (*ElementHandle, error) {
319319
return f.documentHandle, nil
320320
}
321321

322-
f.waitForExecutionContext(mainExecutionContext)
322+
f.waitForExecutionContext(mainWorld)
323323

324324
var (
325325
result interface{}
@@ -346,9 +346,9 @@ func (f *Frame) hasContext(world string) bool {
346346
defer f.executionContextMu.RUnlock()
347347

348348
switch world {
349-
case mainExecutionContext:
349+
case mainWorld:
350350
return f.mainExecutionContext != nil
351-
case utilityExecutionContext:
351+
case utilityWorld:
352352
return f.utilityExecutionContext != nil
353353
}
354354
return false // Should never reach here!
@@ -461,11 +461,11 @@ func (f *Frame) setContext(world string, execCtx frameExecutionContext) {
461461
f.ID(), f.URL(), execCtx.ID(), world)
462462

463463
switch world {
464-
case mainExecutionContext:
464+
case mainWorld:
465465
if f.mainExecutionContext == nil {
466466
f.mainExecutionContext = execCtx
467467
}
468-
case utilityExecutionContext:
468+
case utilityWorld:
469469
if f.utilityExecutionContext == nil {
470470
f.utilityExecutionContext = execCtx
471471
}
@@ -524,7 +524,7 @@ func (f *Frame) waitForFunction(apiCtx context.Context, world string, predicateF
524524
defer f.executionContextMu.RUnlock()
525525

526526
execCtx := f.mainExecutionContext
527-
if world == utilityExecutionContext {
527+
if world == utilityWorld {
528528
execCtx = f.utilityExecutionContext
529529
}
530530
injected, err := execCtx.getInjectedScript(apiCtx)
@@ -722,7 +722,7 @@ func (f *Frame) Evaluate(pageFunc goja.Value, args ...goja.Value) (result interf
722722

723723
rt := k6common.GetRuntime(f.ctx)
724724

725-
f.waitForExecutionContext(mainExecutionContext)
725+
f.waitForExecutionContext(mainWorld)
726726

727727
var err error
728728
f.executionContextMu.RLock()
@@ -744,7 +744,7 @@ func (f *Frame) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) (handle
744744

745745
rt := k6common.GetRuntime(f.ctx)
746746

747-
f.waitForExecutionContext(mainExecutionContext)
747+
f.waitForExecutionContext(mainWorld)
748748

749749
var err error
750750
f.executionContextMu.RLock()
@@ -1377,7 +1377,7 @@ func (f *Frame) WaitForFunction(pageFunc goja.Value, opts goja.Value, args ...go
13771377
k6common.Throw(rt, fmt.Errorf("failed parsing options: %w", err))
13781378
}
13791379

1380-
handle, err := f.waitForFunction(f.ctx, utilityExecutionContext, pageFunc, parsedOpts.Polling, parsedOpts.Interval, parsedOpts.Timeout, args...)
1380+
handle, err := f.waitForFunction(f.ctx, utilityWorld, pageFunc, parsedOpts.Polling, parsedOpts.Interval, parsedOpts.Timeout, args...)
13811381
if err != nil {
13821382
k6common.Throw(rt, err)
13831383
}

common/frame_session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,12 @@ func (fs *FrameSession) onExecutionContextCreated(event *runtime.EventExecutionC
553553
frame := fs.manager.getFrameByID(i.FrameID)
554554
if frame != nil {
555555
if i.IsDefault {
556-
world = mainExecutionContext
557-
} else if event.Context.Name == utilityWorldName && !frame.hasContext(utilityExecutionContext) {
556+
world = mainWorld
557+
} else if event.Context.Name == utilityWorldName && !frame.hasContext(utilityWorld) {
558558
// In case of multiple sessions to the same target, there's a race between
559559
// connections so we might end up creating multiple isolated worlds.
560560
// We can use either.
561-
world = utilityExecutionContext
561+
world = utilityWorld
562562
}
563563
}
564564
if i.Type == "isolated" {

0 commit comments

Comments
 (0)