From 97b363f4a2811dce982525b2c67d2afcc0e08bd6 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Mon, 18 Nov 2024 13:48:26 +0000 Subject: [PATCH] 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. --- common/frame_manager.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/frame_manager.go b/common/frame_manager.go index 9aa3dcbd8..0a675b666 100644 --- a/common/frame_manager.go +++ b/common/frame_manager.go @@ -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",