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

Commit c610fe6

Browse files
committed
Update frameNavigated return nil on frame == nil
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.
1 parent 93ba678 commit c610fe6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

common/frame_manager.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,19 @@ func (m *FrameManager) frameNavigated(frameID cdp.FrameID, parentFrameID cdp.Fra
246246
frame := m.frames[frameID]
247247

248248
if !isMainFrame && frame == nil {
249-
return errors.New("we either navigate top level or have old version of the navigated frame")
249+
m.logger.Debugf("FrameManager:frameNavigated:nil frame",
250+
"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t",
251+
m.ID(), frameID, parentFrameID, documentID, name, url, initial)
252+
253+
// If the frame is nil at this point, then the cause of this is likely
254+
// due to chrome not sending a frameAttached event ahead of time. This
255+
// isn't a bug in chrome, and seems to be intended behavior. Instead
256+
// of worrying about the nil frame and causing the test to fail when
257+
// the frame is nil, we can instead return early. The frame will
258+
// be initialized when getFrameTree CDP request is made, which will
259+
// call onFrameAttached and onFrameNavigated.
260+
261+
return nil
250262
}
251263

252264
m.logger.Debugf("FrameManager:frameNavigated:removeFrames",

0 commit comments

Comments
 (0)