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

Commit 1bf1451

Browse files
committed
Remove subtreeLifecycleEvents
subtreeLifecycleEvents is no longer needed. It's just a duplicate of lifecycleEvents.
1 parent db31e86 commit 1bf1451

File tree

1 file changed

+16
-45
lines changed

1 file changed

+16
-45
lines changed

common/frame.go

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ type Frame struct {
5454

5555
// A life cycle event is only considered triggered for a frame if the entire
5656
// frame subtree has also had the life cycle event triggered.
57-
lifecycleEventsMu sync.RWMutex
58-
lifecycleEvents map[LifecycleEvent]bool
59-
subtreeLifecycleEvents map[LifecycleEvent]bool
57+
lifecycleEventsMu sync.RWMutex
58+
lifecycleEvents map[LifecycleEvent]bool
6059

6160
documentHandle *ElementHandle
6261

@@ -92,20 +91,19 @@ func NewFrame(
9291
}
9392

9493
return &Frame{
95-
BaseEventEmitter: NewBaseEventEmitter(ctx),
96-
ctx: ctx,
97-
page: m.page,
98-
manager: m,
99-
parentFrame: parentFrame,
100-
childFrames: make(map[api.Frame]bool),
101-
id: frameID,
102-
vu: k6ext.GetVU(ctx),
103-
lifecycleEvents: make(map[LifecycleEvent]bool),
104-
subtreeLifecycleEvents: make(map[LifecycleEvent]bool),
105-
inflightRequests: make(map[network.RequestID]bool),
106-
executionContexts: make(map[executionWorld]frameExecutionContext),
107-
currentDocument: &DocumentInfo{},
108-
log: log,
94+
BaseEventEmitter: NewBaseEventEmitter(ctx),
95+
ctx: ctx,
96+
page: m.page,
97+
manager: m,
98+
parentFrame: parentFrame,
99+
childFrames: make(map[api.Frame]bool),
100+
id: frameID,
101+
vu: k6ext.GetVU(ctx),
102+
lifecycleEvents: make(map[LifecycleEvent]bool),
103+
inflightRequests: make(map[network.RequestID]bool),
104+
executionContexts: make(map[executionWorld]frameExecutionContext),
105+
currentDocument: &DocumentInfo{},
106+
log: log,
109107
}
110108
}
111109

@@ -163,7 +161,6 @@ func (f *Frame) clearLifecycle() {
163161
// clear lifecycle events
164162
f.lifecycleEventsMu.Lock()
165163
f.lifecycleEvents = make(map[LifecycleEvent]bool)
166-
f.subtreeLifecycleEvents = make(map[LifecycleEvent]bool)
167164
f.lifecycleEventsMu.Unlock()
168165

169166
// keep the request related to the document if present
@@ -190,25 +187,6 @@ func (f *Frame) recalculateLifecycle(event LifecycleEvent) {
190187
f.log.Debugf("Frame:recalculateLifecycle", "fid:%s furl:%q", f.ID(), f.URL())
191188

192189
f.emit(EventFrameAddLifecycle, event)
193-
194-
// Start with triggered events.
195-
events := make(map[LifecycleEvent]bool)
196-
f.lifecycleEventsMu.RLock()
197-
{
198-
for k, v := range f.lifecycleEvents {
199-
events[k] = v
200-
}
201-
}
202-
f.lifecycleEventsMu.RUnlock()
203-
204-
f.lifecycleEventsMu.Lock()
205-
{
206-
f.subtreeLifecycleEvents = make(map[LifecycleEvent]bool)
207-
for k, v := range events {
208-
f.subtreeLifecycleEvents[k] = v
209-
}
210-
}
211-
f.lifecycleEventsMu.Unlock()
212190
}
213191

214192
func (f *Frame) detach() {
@@ -331,13 +309,6 @@ func (f *Frame) hasLifecycleEventFired(event LifecycleEvent) bool {
331309
return f.lifecycleEvents[event]
332310
}
333311

334-
func (f *Frame) hasSubtreeLifecycleEventFired(event LifecycleEvent) bool {
335-
f.lifecycleEventsMu.RLock()
336-
defer f.lifecycleEventsMu.RUnlock()
337-
338-
return f.subtreeLifecycleEvents[event]
339-
}
340-
341312
func (f *Frame) navigated(name string, url string, loaderID string) {
342313
f.log.Debugf("Frame:navigated", "fid:%s furl:%q lid:%s name:%q url:%q", f.ID(), f.URL(), loaderID, name, url)
343314

@@ -1848,7 +1819,7 @@ func (f *Frame) WaitForNavigation(opts goja.Value) *goja.Promise {
18481819
// A lifecycle event won't be received when navigating within the same
18491820
// document, so don't wait for it. The event might've also already been
18501821
// fired once we're here, so also skip waiting in that case.
1851-
if !sameDocNav && !f.hasSubtreeLifecycleEventFired(parsedOpts.WaitUntil) {
1822+
if !sameDocNav && !f.hasLifecycleEventFired(parsedOpts.WaitUntil) {
18521823
select {
18531824
case <-lifecycleEvtCh:
18541825
case <-timeoutCtx.Done():

0 commit comments

Comments
 (0)