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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/loading/resources/testreload.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/resources/testreload.js b/third_party/WebKit/LayoutTests/http/tests/loading/resources/testreload.js
new file mode 100644
index 0000000000000000000000000000000000000000..ba7a13079bbc57f79ca4110581c686f948a71159
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/loading/resources/testreload.js
@@ -0,0 +1,44 @@
+// 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
+// same for first load and for reload.
+
jkarlin 2016/04/14 18:24:39 Thanks for making this file! Nicer to review it on
+if (window.internals) {
+ internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(true);
+ internals.setNetworkStateNotifierTestOnly(true);
+ internals.setNetworkConnectionInfo('cellular2g', 1.0);
+ internals.evictAllResources();
+
+ window.addEventListener('beforeunload', function() {
+ internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(false);
+ internals.setNetworkStateNotifierTestOnly(false);
+ }, false);
+}
+
+var crossOrigin = 'http://localhost:8000';
+var filePath = '/loading/resources/js-loaded.js';
+var jsLoaded = false;
+var loadSuccess = false;
+var loadBlockedFirst = false;
+
+// First time the script will be blocked and onError will reload the page.
+// On reload the script should not be blocked and thus the subsequent
+// asserts in the calling html page will be true.
+// forceReload with true sets the reload to bypass the cache while false
+// sets the reload to use the cache.
+src = crossOrigin + filePath;
+document.write('<scr' + 'ipt src="' + src + '" onload="succTest()" onError="errTest()"></scr' + 'ipt>');
+
+function succTest() {
+ 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
+ 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.
+ loadBlockedFirst=true;
+ }
+
+ loadSuccess=true;
+}
+
+function errTest() {
+ window.localStorage.setItem("blocked-on-first-load", "true")
+ if (window.internals) {
+ internals.forceReload(reloadFromCache);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698