Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / cache / loaded-from-cache-after-reload.html
blob047dd1fdffcaa1dcb2a87cb5663c759ce3abb442
1 <body>
2 <h1></h1>
3 <script>
4 // Test that a subresource fetched after onload, following a reload, is still
5 // loaded from the cache.
7 if (!sessionStorage.lastRandom) {
8 if (window.testRunner) {
9 testRunner.dumpAsText();
10 testRunner.waitUntilDone();
14 function done(result)
16 delete sessionStorage.lastRandom;
18 document.body.innerText = result;
20 if (window.testRunner)
21 testRunner.notifyDone();
24 function scriptLoaded()
26 setTimeout(function()
28 if (!window.randomNumber)
29 done('FAIL: window.randomNumber not defined!');
30 else if (sessionStorage.lastRandom) {
31 if ((sessionStorage.lastRandom - 0) == (randomNumber - 0))
32 done('PASS');
33 else
34 done('FAIL');
35 } else {
36 sessionStorage.lastRandom = randomNumber;
37 location.reload();
39 }, 0);
42 onload = function()
44 // After onload, add a script tag that should always load from the cache.
45 setTimeout(function()
47 var s = document.createElement("script");
48 s.src = "resources/random-cached.cgi";
49 s.onload = scriptLoaded;
50 document.body.appendChild(s);
51 }, 0);
53 </script>
54 </body>