From 241cbc8a27dbeafce0385a0a1d8bfcaa937c8372 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Sun, 13 Sep 2020 21:00:13 +0900 Subject: [PATCH] add test for isNilContextErr --- page_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/page_test.go b/page_test.go index 3d163522..354fe7a1 100644 --- a/page_test.go +++ b/page_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/go-rod/rod" + "github.com/go-rod/rod/lib/cdp" "github.com/go-rod/rod/lib/defaults" "github.com/go-rod/rod/lib/devices" "github.com/go-rod/rod/lib/input" @@ -272,6 +273,16 @@ func (s *S) TestPageEval() { s.NotEqualValues(1, page.MustEval(`/* ) */`)) } +func (s *S) TestPageEvalNilContext() { + page := s.browser.MustPage(srcFile("fixtures/click.html")) + defer page.MustClose() + + s.stub(1, proto.RuntimeEvaluate{}, func(func() ([]byte, error)) ([]byte, error) { + return nil, &cdp.Error{Code: -32000} + }) + s.EqualValues(1, page.MustEval(`1`).Int()) +} + func (s *S) TestPageExposeJSHelper() { page := s.browser.MustPage(srcFile("fixtures/click.html")) defer page.MustClose()