9 var r
= new XMLHttpRequest
14 function SignalSuccess() {
15 document
.location
= "title3.html";
18 function SignalFailure() {
19 document
.location
= "title1.html";
22 function CreateDummyRequest() {
23 dummy_request
= NewXHR("http://mock.http/title2.html");
24 dummy_request
.onload
= SignalSuccess
;
25 dummy_request
.send(null);
28 function RedirectFailed() {
29 // Good, the redirect was blocked by WebKit.
31 // We also care that the underlying network stack does not send the redirect.
32 // We cannot detect that from JS, but our test harness is designed to detect
33 // that (see ResourceDispatcherTest::CrossOriginRedirectBlocked). Before
34 // calling SignalSuccess, we want to allow the browser time to notice a request
35 // to follow the redirect if one should exist. To do that, we just need to
36 // make another network request.
38 // The setTimeout call is intended to delay CreateDummyRequest so that any
39 // processing associated with the current "error" handler completes.
40 setTimeout(CreateDummyRequest
, 0);
43 function RedirectSucceeded() {
44 // Oops, the redirect should have been denied!
48 // Kick off a request that will attempt a cross-origin redirect.
49 request
= NewXHR("http://mock.http/redirect-to-title2.html");
50 request
.onerror
= RedirectFailed
;
51 request
.onload
= RedirectSucceeded
;