Use dumpJSConsoleLogInStdErr=true webkit-test-runner option for non-imported tests...
[WebKit-https.git] / LayoutTests / http / tests / cache / disk-cache / redirect-chain-limits.html
1 <!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
2 <script src="/js-test-resources/js-test-pre.js"></script>
3 <script>
4 window.jsTestIsAsync = true;
5
6 description("Test the limits of redirect chain length.");
7
8 function redirectChain(length, uniqueId, onload)
9 {
10     internals.clearMemoryCache()
11
12     var url = "resources/redirect-chain.php?length=" + length + "&uniqueId=" + uniqueId;
13
14     xhr = new XMLHttpRequest();
15     xhr.onload = onload;
16     xhr.onerror = onload;
17     xhr.onabort = onload;
18     xhr.open("get", url, true);
19
20     xhr.send();
21 }
22
23 function testRedirectChain(length, completionHandler)
24 {
25     var uniqueId = Math.floor(Math.random() * 1000000000000);
26     redirectChain(length, uniqueId, (ev) => {
27         redirectChain(length, uniqueId, (ev) => {
28             debug("Redirect chain length: " + length)
29             debug("Response status code: " + ev.target.status);
30             debug("Response source: " + internals.xhrResponseSource(ev.target));
31             debug("");
32             completionHandler();
33         });
34     });
35 }
36
37 testRedirectChain(1, () => {
38     testRedirectChain(5, () => {
39         testRedirectChain(6, () => {
40             testRedirectChain(20, () => {
41                 testRedirectChain(40, () => {
42                     finishJSTest();
43                 });
44             });
45         });
46     });
47 });
48 </script>
49 <script src="/js-test-resources/js-test-post.js"></script>