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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/loading/resources/test-reload.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: Simplified tests, Used js-loaded with a different query parameter than other tests. 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/test-reload.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/resources/test-reload.js b/third_party/WebKit/LayoutTests/http/tests/loading/resources/test-reload.js
new file mode 100644
index 0000000000000000000000000000000000000000..def32a9ab0ec967b31fa835384ee608a9fcd6d3d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/loading/resources/test-reload.js
@@ -0,0 +1,49 @@
+// This script sets the flags for blocking doc.write script and then tests the
+// same for first load and for reload.
+
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.
+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);
+ // Remove localStorage items , just in case they haven't been
+ // already removed due to test failure.
+ window.localStorage.removeItem("blocked-on-first-load");
+ window.localStorage.removeItem("successful-on-first-reload");
+ }, false);
+}
+
+var crossOrigin = 'http://localhost:8000';
+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.
+
+// 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") {
+ window.localStorage.removeItem("blocked-on-first-load");
+ window.localStorage.setItem("successful-on-first-reload", "true")
+ internals.forceReload(true);
+ }
+
+ else if (window.localStorage.getItem("successful-on-first-reload") == "true") {
+ window.localStorage.removeItem("successful-on-first-reload");
+ reloadTestSuccess=true;
+ }
+}
+
+function errTest() {
+ window.localStorage.setItem("blocked-on-first-load", "true")
+ if (window.internals) {
+ internals.forceReload(false);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698