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