Skip to content

Commit

Permalink
Add initialFrame parameter to handleFrameTree
Browse files Browse the repository at this point in the history
The only reason we have initialFrame flag is to use in logging, so it's
not an important thing to factor in for the runtime, but it may help in
debugging issues. Rather than remove it, I've changed it so any
mainframe is regarded as the initialFrame.
  • Loading branch information
ankur22 committed May 24, 2024
1 parent 21d3226 commit e5f8098
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ func (fs *FrameSession) initFrameTree() error {
return fmt.Errorf("got a nil page frame tree")
}

fs.handleFrameTree(frameTree)
// Any new frame may have a child frame, not just mainframes.
fs.handleFrameTree(frameTree, fs.isMainFrame())

if fs.isMainFrame() {
fs.initRendererEvents()
Expand Down Expand Up @@ -578,19 +579,19 @@ func (fs *FrameSession) isMainFrame() bool {
return fs.targetID == fs.page.targetID
}

func (fs *FrameSession) handleFrameTree(frameTree *cdppage.FrameTree) {
func (fs *FrameSession) handleFrameTree(frameTree *cdppage.FrameTree, initialFrame bool) {
fs.logger.Debugf("FrameSession:handleFrameTree",
"sid:%v tid:%v", fs.session.ID(), fs.targetID)
"fid:%v sid:%v tid:%v", frameTree.Frame.ID, fs.session.ID(), fs.targetID)

if frameTree.Frame.ParentID != "" {
fs.onFrameAttached(frameTree.Frame.ID, frameTree.Frame.ParentID)
}
fs.onFrameNavigated(frameTree.Frame, true)
fs.onFrameNavigated(frameTree.Frame, initialFrame)
if frameTree.ChildFrames == nil {
return
}
for _, child := range frameTree.ChildFrames {
fs.handleFrameTree(child)
fs.handleFrameTree(child, initialFrame)
}
}

Expand Down

0 comments on commit e5f8098

Please sign in to comment.