Chromium Code Reviews| 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..91163fb9fa12d4044eaba63e470c655227752c67 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html |
| @@ -0,0 +1,62 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script> |
| + var reloadTestSuccess = false; |
| +</script> |
| + |
| +<script> |
| + 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 |
|
jkarlin
2016/04/18 14:00:43
s/ ,/,/
shivanisha
2016/04/18 17:03:38
done.
|
| + // 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?reload'; |
| + |
| + // First time the script will be blocked and onError will reload the page. |
| + // On reload the script should not be blocked |
|
jkarlin
2016/04/18 14:00:43
Missing period
shivanisha
2016/04/18 17:03:38
Added.
|
| + // This tests does 2 reloads: first reload will bypass the cache and |
|
jkarlin
2016/04/18 14:00:43
This sentence is rough. How about, "This tests two
shivanisha
2016/04/18 17:03:38
Updated.
|
| + // the second reload will not. |
| + // Script should not be blocked in both cases. |
|
jkarlin
2016/04/18 14:00:43
s/Script/The script/
shivanisha
2016/04/18 17:03:38
done.
|
| + 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") |
|
jkarlin
2016/04/18 14:00:43
How do you know this was the first load that faile
shivanisha
2016/04/18 17:20:51
Updated.
|
| + if (window.internals) { |
| + internals.forceReload(false); |
| + } |
| +} |
| + |
| +</script> |
| + |
| +<script> |
| + test(function () { |
| + assert_true(reloadTestSuccess); |
| + }, "cross origin doc.written scripts are not blocked in a page reload"); |
| +</script> |