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

Commit

Permalink
Quickly return an error if we get a nil FrameTree
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Mar 11, 2022
1 parent c31e1e7 commit 6f0dd9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
strategy:
matrix:
go: [stable, tip]
platform: [ubuntu-latest, windows-latest, macos-latest]
# platform: [ubuntu-latest, windows-latest, macos-latest]
platform: [windows-latest, macos-latest]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down Expand Up @@ -64,10 +65,11 @@ jobs:
- name: Run E2E tests
run: |
set -x
export XK6_HEADLESS=true
for f in examples/*.js; do
./k6ext run "$f"
done
- name: Check screenshot
# TODO: Do something more sophisticated?
run: test -s screenshot.png
export XK6_HEADLESS=true XK6_BROWSER_LOG=trace
# for f in examples/*.js; do
# ./k6ext run "$f"
# done
./k6ext run examples/browser_on.js
# - name: Check screenshot
# # TODO: Do something more sophisticated?
# run: test -s screenshot.png
12 changes: 5 additions & 7 deletions common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ func (fs *FrameSession) initFrameTree() error {
action2 := cdppage.GetFrameTree()
if frameTree, err = action2.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("unable to get page frame tree: %w", err)
} else if frameTree == nil {
// This can happen with very short scripts when we might not have enough
// time to initialize properly.
return fmt.Errorf("got a nil page frame tree")
}

if fs.isMainFrame() {
Expand Down Expand Up @@ -475,13 +479,7 @@ func (fs *FrameSession) isMainFrame() bool {

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

if frameTree == nil {
// Sometimes on very short scripts we might not have time to initialize
// and frameTree will be nil.
return
}
"sid:%v tid:%v", fs.session.ID(), fs.targetID)

if frameTree.Frame.ParentID != "" {
fs.onFrameAttached(frameTree.Frame.ID, frameTree.Frame.ParentID)
Expand Down

0 comments on commit 6f0dd9a

Please sign in to comment.