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

Commit

Permalink
Update to work with frameLifecycleEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Oct 13, 2022
1 parent 5cd4121 commit 714629c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions common/frame_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,6 @@ func (m *FrameManager) frameLifecycleEvent(frameID cdp.FrameID, event LifecycleE
}
}

// This only tries to recalculate the lifecycle and not set the
// `networkIdle` state to the Frame. `networkIdle` events need to be
// handled after `frameLoadingStopped`` has been called (which
// internally sets the `networkidle` state to the Frame). Once
// this is done, we can safely recalculateLifecycle which should
// emit the internal `networkidle` event.
func (m *FrameManager) frameNetworkIdleLifecycleEvent(frameID cdp.FrameID, event LifecycleEvent) {
m.logger.Debugf("FrameManager:frameNetworkIdleLifecycleEvent",
"fmid:%d fid:%v event:%s",
m.ID(), frameID, lifecycleEventToString[event])

frame := m.getFrameByID(frameID)
if frame != nil {
frame.recalculateLifecycle()
}
}

func (m *FrameManager) frameLoadingStarted(frameID cdp.FrameID) {
m.logger.Debugf("FrameManager:frameLoadingStarted",
"fmid:%d fid:%v", m.ID(), frameID)
Expand Down
2 changes: 1 addition & 1 deletion common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func (fs *FrameSession) onPageLifecycle(event *cdppage.EventLifecycleEvent) {
case "DOMContentLoaded":
fs.manager.frameLifecycleEvent(event.FrameID, LifecycleEventDOMContentLoad)
case "networkIdle":
fs.manager.frameNetworkIdleLifecycleEvent(event.FrameID, LifecycleEventNetworkIdle)
fs.manager.frameLifecycleEvent(event.FrameID, LifecycleEventNetworkIdle)
}

eventToMetric := map[string]*k6metrics.Metric{
Expand Down

0 comments on commit 714629c

Please sign in to comment.