Skip to content

Commit

Permalink
dns error is special for the new chromium version
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Jun 6, 2022
1 parent 809a341 commit c7dfaa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 2 additions & 4 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,8 @@ func (p *Page) Navigate(url string) error {
url = "about:blank"
}

err := p.StopLoading()
if err != nil {
return err
}
// try to stop loading
_ = p.StopLoading()

res, err := proto.PageNavigate{URL: url}.Call(p)
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,19 @@ func TestPagePDF(t *testing.T) {
})
}

func TestPageNavigateErr(t *testing.T) {
func TestPageNavigateDNSErr(t *testing.T) {
g := setup(t)
p := g.newPage()

// dns error
err := g.page.Navigate("http://" + g.RandStr(16))
err := p.Navigate("http://" + g.RandStr(16))
g.Is(err, &rod.ErrNavigation{})
g.Is(err.Error(), "navigation failed: net::ERR_NAME_NOT_RESOLVED")
p.MustNavigate("about:blank")
}

func TestPageNavigateErr(t *testing.T) {
g := setup(t)

s := g.Serve()

Expand All @@ -691,10 +697,6 @@ func TestPageNavigateErr(t *testing.T) {
g.page.MustNavigate(s.URL("/404"))
g.page.MustNavigate(s.URL("/500"))

g.Panic(func() {
g.mc.stubErr(1, proto.PageStopLoading{})
g.page.MustNavigate(g.blank())
})
g.Panic(func() {
g.mc.stubErr(1, proto.PageNavigate{})
g.page.MustNavigate(g.blank())
Expand Down

0 comments on commit c7dfaa5

Please sign in to comment.