aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2022-02-14 11:11:37 -0500
committerJamal Carvalho <jamalcarvalho@google.com>2022-02-14 18:38:36 +0000
commit2c19c4c8fc05a70e4fd6de781b9735895e97b45b (patch)
tree750d22468826892d28872ced7e3cc803209c34d5
parentaeb216c1e46134805bf60b177fb01b71a29a9c48 (diff)
downloadgo-x-website-2c19c4c8fc05a70e4fd6de781b9735895e97b45b.tar.xz
internal/screentest: capture response status from redirect
Change-Id: I6c7ae3eb3447c67d30b8dc2c4fb02f331ada15c8 Reviewed-on: https://go-review.googlesource.com/c/website/+/385634 Run-TryBot: Jamal Carvalho <jamal@golang.org> Trust: Jamal Carvalho <jamalcarvalho@google.com> Run-TryBot: Jamal Carvalho <jamalcarvalho@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
-rw-r--r--cmd/screentest/testdata/godev.txt1
-rw-r--r--internal/screentest/screentest.go13
2 files changed, 10 insertions, 4 deletions
diff --git a/cmd/screentest/testdata/godev.txt b/cmd/screentest/testdata/godev.txt
index 42f21fd8..60d784ee 100644
--- a/cmd/screentest/testdata/godev.txt
+++ b/cmd/screentest/testdata/godev.txt
@@ -57,6 +57,7 @@ capture fullscreen 540x1080
test help
pathname /help/
+status 301
capture fullscreen
capture fullscreen 540x1080
diff --git a/internal/screentest/screentest.go b/internal/screentest/screentest.go
index b6299e2f..bca7a8ef 100644
--- a/internal/screentest/screentest.go
+++ b/internal/screentest/screentest.go
@@ -893,15 +893,20 @@ func waitForEvent(eventName string) chromedp.ActionFunc {
func getResponse(u string, res *Response) chromedp.ActionFunc {
return func(ctx context.Context) error {
chromedp.ListenTarget(ctx, func(ev interface{}) {
+ // URL fragments are dropped in request targets so we must strip the fragment
+ // from the URL to make a comparison.
+ _u, _ := url.Parse(u)
+ _u.Fragment = ""
switch e := ev.(type) {
case *network.EventResponseReceived:
- // URL fragments are dropped in request targets so we must strip the fragment
- // from the URL to make a comparison.
- _u, _ := url.Parse(u)
- _u.Fragment = ""
if e.Response.URL == _u.String() {
res.Status = int(e.Response.Status)
}
+ // Capture the status from a redirected response.
+ case *network.EventRequestWillBeSent:
+ if e.RedirectResponse != nil && e.RedirectResponse.URL == _u.String() {
+ res.Status = int(e.RedirectResponse.Status)
+ }
}
})
return nil