Skip to content

Commit

Permalink
catch edge case where the _biloba object isn't available because the …
Browse files Browse the repository at this point in the history
…browser is in the middle of a redirect
  • Loading branch information
onsi committed Sep 18, 2023
1 parent 20acefd commit d9df233
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions biloba.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ func (b *Biloba) ensureBiloba() {
if installed {
return
}
b.reloadBiloba()
}

func (b *Biloba) reloadBiloba() {
b.Run(bilobaJS)
b.lock.Lock()
b.bilobaIsInstalled = true
Expand Down
4 changes: 4 additions & 0 deletions javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (b *Biloba) RunErr(script string, args ...any) (any, error) {
}
err := chromedp.Run(b.Context, chromedp.EvaluateAsDevTools(script, &encodedResult, withUserGesture))
if err != nil {
if strings.Contains(err.Error(), "_biloba is not defined") {
b.reloadBiloba()
return b.RunErr(script, args...)
}
return nil, err
}

Expand Down

0 comments on commit d9df233

Please sign in to comment.