Index: third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html b/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f4d03d2f633c1f5e32305518b4c9c5fe57127e26 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html |
@@ -0,0 +1,82 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+ var reloadTestSuccess = false; |
+</script> |
+ |
+<script> |
+ test(function () { |
+ assert_true(window.internals !== null); |
+ }, "window.internals is required for the test to run"); |
+ |
+ 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. |
+ if (window.localStorage.getItem("errorCount") !== null) { |
+ window.localStorage.removeItem("errorCount"); |
+ } |
+ |
+ if (window.localStorage.getItem("successCount") !== null) { |
+ window.localStorage.removeItem("successCount"); |
+ } |
+ }, false); |
+ |
+ if (window.localStorage.getItem("errorCount") === null) { |
+ window.localStorage.setItem("errorCount", 0); |
+ } |
+ |
+ if (window.localStorage.getItem("successCount") === null) { |
+ window.localStorage.setItem("successCount", 0); |
+ } |
+ |
+ var crossOrigin = 'http://localhost:8000'; |
+ var filePath = '/loading/resources/js-loaded.js?reload'; |
+ |
+ // First time the script will be blocked and onError will reload the page. |
+ // On reload the script should not be blocked. |
+ // This tests two types of reload, one with and one without cache bypass. |
+ // The script should not be blocked in both cases. |
+ src = crossOrigin + filePath; |
+ document.write('<scr' + 'ipt src="' + src + '" onload="test(successTest,\'Load Success\')" onError="test(errorTest,\'Load Error\')"></scr' + 'ipt>'); |
+ |
+ var successTest = function() { |
+ assert_equals(+window.localStorage.getItem("errorCount"), 1); |
+ |
+ var successCount = +window.localStorage.getItem("successCount"); |
+ assert_greater_than_equal(successCount, 0); |
+ |
+ if (successCount == 0) |
+ { |
+ window.localStorage.setItem("successCount", 1); |
+ internals.forceReload(true); |
+ return; |
+ } |
+ |
+ assert_equals(successCount, 1); |
+ window.localStorage.removeItem("errorCount"); |
+ window.localStorage.removeItem("successCount"); |
+ reloadTestSuccess=true; |
+ } |
+ |
+ var errorTest = function() { |
+ assert_equals(+window.localStorage.getItem("errorCount"), 0); |
+ assert_equals(+window.localStorage.getItem("successCount"), 0); |
+ window.localStorage.setItem("errorCount", 1); |
+ internals.forceReload(false); |
+ } |
+ |
+</script> |
+ |
+<script> |
+ test(function () { |
+ assert_true(reloadTestSuccess); |
+ }, "cross origin doc.written scripts are not blocked in a page reload"); |
+</script> |