OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../resources/testharness.js"></script> | |
3 <script src="../resources/testharnessreport.js"></script> | |
4 <script> | |
5 var reloadTestSuccess = false; | |
6 </script> | |
7 | |
8 <script> | |
9 if (window.internals) { | |
10 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlow Connections(true); | |
11 internals.setNetworkStateNotifierTestOnly(true); | |
12 internals.setNetworkConnectionInfo('cellular2g', 1.0); | |
13 internals.evictAllResources(); | |
14 | |
15 window.addEventListener('beforeunload', function() { | |
16 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOn SlowConnections(false); | |
17 internals.setNetworkStateNotifierTestOnly(false); | |
18 // Remove localStorage items , just in case they haven't been | |
jkarlin
2016/04/18 14:00:43
s/ ,/,/
shivanisha
2016/04/18 17:03:38
done.
| |
19 // already removed, due to test failure. | |
20 window.localStorage.removeItem("blocked-on-first-load"); | |
21 window.localStorage.removeItem("successful-on-first-reload"); | |
22 }, false); | |
23 } | |
24 | |
25 var crossOrigin = 'http://localhost:8000'; | |
26 var filePath = '/loading/resources/js-loaded.js?reload'; | |
27 | |
28 // First time the script will be blocked and onError will reload the page. | |
29 // On reload the script should not be blocked | |
jkarlin
2016/04/18 14:00:43
Missing period
shivanisha
2016/04/18 17:03:38
Added.
| |
30 // This tests does 2 reloads: first reload will bypass the cache and | |
jkarlin
2016/04/18 14:00:43
This sentence is rough. How about, "This tests two
shivanisha
2016/04/18 17:03:38
Updated.
| |
31 // the second reload will not. | |
32 // Script should not be blocked in both cases. | |
jkarlin
2016/04/18 14:00:43
s/Script/The script/
shivanisha
2016/04/18 17:03:38
done.
| |
33 src = crossOrigin + filePath; | |
34 document.write('<scr' + 'ipt src="' + src + '" onload="succTest()" onError=" errTest()"></scr' + 'ipt>'); | |
35 | |
36 function succTest() { | |
37 if (window.localStorage.getItem("blocked-on-first-load") == "true") { | |
38 window.localStorage.removeItem("blocked-on-first-load"); | |
39 window.localStorage.setItem("successful-on-first-reload", "true") | |
40 internals.forceReload(true); | |
41 } | |
42 | |
43 else if (window.localStorage.getItem("successful-on-first-reload") == "t rue") { | |
44 window.localStorage.removeItem("successful-on-first-reload"); | |
45 reloadTestSuccess=true; | |
46 } | |
47 } | |
48 | |
49 function errTest() { | |
50 window.localStorage.setItem("blocked-on-first-load", "true") | |
jkarlin
2016/04/18 14:00:43
How do you know this was the first load that faile
shivanisha
2016/04/18 17:20:51
Updated.
| |
51 if (window.internals) { | |
52 internals.forceReload(false); | |
53 } | |
54 } | |
55 | |
56 </script> | |
57 | |
58 <script> | |
59 test(function () { | |
60 assert_true(reloadTestSuccess); | |
61 }, "cross origin doc.written scripts are not blocked in a page reload"); | |
62 </script> | |
OLD | NEW |