Get foreground tab on Android
[chromium-blink-merge.git] / content / test / data / cross-origin-redirect-blocked.html
blobd0e8ee9f3d920147a5b659d7caa42b5342996ddb
1 <html>
2 <head>
3 <title></title>
4 </head>
5 <body>
6 <script>
8 function NewXHR(url) {
9 var r = new XMLHttpRequest
10 r.open("GET", url);
11 return r;
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!
45 SignalFailure();
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;
52 request.send(null);
54 </script>
55 </body>
56 </html>