Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/loading/resources/testreload.js

Issue 1883873002: Do not block document.written scripts in page reloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback incorporated Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // This script sets the flags for blocking doc.write script and then tests the
jkarlin 2016/04/14 18:24:39 File should be named test-reload.js
shivanisha 2016/04/14 19:15:44 done
2 // same for first load and for reload.
3
jkarlin 2016/04/14 18:24:39 Thanks for making this file! Nicer to review it on
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 }, false);
14 }
15
16 var crossOrigin = 'http://localhost:8000';
17 var filePath = '/loading/resources/js-loaded.js';
18 var jsLoaded = false;
19 var loadSuccess = false;
20 var loadBlockedFirst = false;
21
22 // First time the script will be blocked and onError will reload the page.
23 // On reload the script should not be blocked and thus the subsequent
24 // asserts in the calling html page will be true.
25 // forceReload with true sets the reload to bypass the cache while false
26 // sets the reload to use the cache.
27 src = crossOrigin + filePath;
28 document.write('<scr' + 'ipt src="' + src + '" onload="succTest()" onError="errT est()"></scr' + 'ipt>');
29
30 function succTest() {
31 if (window.localStorage.getItem("blocked-on-first-load") == "true") {
jkarlin 2016/04/14 18:24:39 Use a different item name for each test so they do
shivanisha 2016/04/14 19:15:44 I have changed this file such that both reloads no
32 window.localStorage.clear();
jkarlin 2016/04/14 18:24:38 localStorage is storage per-origin. So if other te
shivanisha 2016/04/14 19:15:45 done.
33 loadBlockedFirst=true;
34 }
35
36 loadSuccess=true;
37 }
38
39 function errTest() {
40 window.localStorage.setItem("blocked-on-first-load", "true")
41 if (window.internals) {
42 internals.forceReload(reloadFromCache);
43 }
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698