Skip to content

Commit

Permalink
Update frameNavigated return nil on frame == nil
Browse files Browse the repository at this point in the history
If the frame is nil at this point, then the cause of this is likely
due to chrome not sending a frameAttached event ahead of time. This
isn't a bug in chrome, and seems to be intended behavior. Instead
of worrying about the nil frame and causing the test to fail when
the frame is nil, we can instead return early. The frame will
be initialized when getFrameTree CDP request is made, which will
call onFrameAttached and onFrameNavigated.
  • Loading branch information
ankur22 committed Nov 18, 2024
1 parent 93ba678 commit c610fe6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion common/frame_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,19 @@ func (m *FrameManager) frameNavigated(frameID cdp.FrameID, parentFrameID cdp.Fra
frame := m.frames[frameID]

if !isMainFrame && frame == nil {
return errors.New("we either navigate top level or have old version of the navigated frame")
m.logger.Debugf("FrameManager:frameNavigated:nil frame",
"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t",
m.ID(), frameID, parentFrameID, documentID, name, url, initial)

// If the frame is nil at this point, then the cause of this is likely
// due to chrome not sending a frameAttached event ahead of time. This
// isn't a bug in chrome, and seems to be intended behavior. Instead
// of worrying about the nil frame and causing the test to fail when
// the frame is nil, we can instead return early. The frame will
// be initialized when getFrameTree CDP request is made, which will
// call onFrameAttached and onFrameNavigated.

return nil
}

m.logger.Debugf("FrameManager:frameNavigated:removeFrames",
Expand Down

0 comments on commit c610fe6

Please sign in to comment.