Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // This script sets the flags for blocking doc.write script and then tests the | |
| 2 // same for first load and for reload. | |
| 3 | |
|
jkarlin
2016/04/15 11:21:26
Now that both tests are in this one js file, can y
shivanisha
2016/04/15 16:37:30
done.
| |
| 4 if (window.internals) { | |
| 5 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConn ections(true); | |
| 6 internals.setNetworkStateNotifierTestOnly(true); | |
| 7 internals.setNetworkConnectionInfo('cellular2g', 1.0); | |
| 8 internals.evictAllResources(); | |
| 9 | |
| 10 window.addEventListener('beforeunload', function() { | |
| 11 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlow Connections(false); | |
| 12 internals.setNetworkStateNotifierTestOnly(false); | |
| 13 // Remove localStorage items , just in case they haven't been | |
| 14 // already removed due to test failure. | |
| 15 window.localStorage.removeItem("blocked-on-first-load"); | |
| 16 window.localStorage.removeItem("successful-on-first-reload"); | |
| 17 }, false); | |
| 18 } | |
| 19 | |
| 20 var crossOrigin = 'http://localhost:8000'; | |
| 21 var filePath = '/loading/resources/js-loaded.js?10'; | |
|
jkarlin
2016/04/15 11:21:26
if you need each test to have a cache query, you m
shivanisha
2016/04/15 16:37:30
Good idea. Modified existing tests as well.
| |
| 22 | |
| 23 // First time the script will be blocked and onError will reload the page. | |
| 24 // On reload the script should not be blocked and thus the subsequent | |
| 25 // asserts in the calling html page will be true. | |
| 26 // forceReload with true sets the reload to bypass the cache while false | |
| 27 // sets the reload to use the cache. | |
| 28 src = crossOrigin + filePath; | |
| 29 document.write('<scr' + 'ipt src="' + src + '" onload="succTest()" onError="errT est()"></scr' + 'ipt>'); | |
| 30 | |
| 31 function succTest() { | |
| 32 if (window.localStorage.getItem("blocked-on-first-load") == "true") { | |
| 33 window.localStorage.removeItem("blocked-on-first-load"); | |
| 34 window.localStorage.setItem("successful-on-first-reload", "true") | |
| 35 internals.forceReload(true); | |
| 36 } | |
| 37 | |
| 38 else if (window.localStorage.getItem("successful-on-first-reload") == "true" ) { | |
| 39 window.localStorage.removeItem("successful-on-first-reload"); | |
| 40 reloadTestSuccess=true; | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 function errTest() { | |
| 45 window.localStorage.setItem("blocked-on-first-load", "true") | |
| 46 if (window.internals) { | |
| 47 internals.forceReload(false); | |
| 48 } | |
| 49 } | |
| OLD | NEW |