@@ -15,6 +15,7 @@ import (
15
15
. "github.com/gost-dom/browser/internal/html"
16
16
. "github.com/gost-dom/browser/internal/testing/gomega-matchers"
17
17
"github.com/gost-dom/browser/internal/testing/gosttest"
18
+ "github.com/stretchr/testify/assert"
18
19
"github.com/stretchr/testify/suite"
19
20
20
21
"github.com/onsi/gomega/types"
@@ -218,6 +219,23 @@ func (s *XMLHTTPRequestTestSuite) TestCookieVisibility() {
218
219
).To (HaveLines ("x-test-1: value1" , "x-test-2: value2" , "content-type: text/plain" ))
219
220
}
220
221
222
+ func TestXMLHTTPRequestRedirect (t * testing.T ) {
223
+ m := http .NewServeMux ()
224
+ m .Handle ("GET /redirect" , http .RedirectHandler ("/redirect-temp" , 301 ))
225
+ m .Handle ("GET /redirect-temp" , http .RedirectHandler ("/redirected-url" , 301 ))
226
+ m .HandleFunc ("GET /redirected-url" , func (w http.ResponseWriter , r * http.Request ) {
227
+ w .Write ([]byte ("Handled" ))
228
+ })
229
+ xhr := NewXmlHttpRequest (
230
+ stubBrowsingContext {client : gosthttp .NewHttpClientFromHandler (m )},
231
+ clock .New (),
232
+ )
233
+ xhr .Open ("GET" , "https://example.com/redirect" , RequestOptionAsync (false ))
234
+ xhr .Send ()
235
+
236
+ assert .Equal (t , "https://example.com/redirected-url" , xhr .ResponseURL ())
237
+ }
238
+
221
239
func HaveLines (expected ... string ) types.GomegaMatcher {
222
240
return WithTransform (func (s string ) []string {
223
241
lines := strings .Split (s , "\r \n " )
0 commit comments