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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload.html

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 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script>
5 var reloadTestSuccess = false;
6 </script>
7
8 <script>
9 test(function () {
10 assert_true(window.internals !== null);
11 }, "window.internals is required for the test to run");
12
13 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConn ections(true);
14 internals.setNetworkStateNotifierTestOnly(true);
15 internals.setNetworkConnectionInfo('cellular2g', 1.0);
16 internals.evictAllResources();
17
18 window.addEventListener('beforeunload', function() {
19 internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlow Connections(false);
20 internals.setNetworkStateNotifierTestOnly(false);
21 // Remove localStorage items, just in case they haven't been
22 // already removed, due to test failure.
23 if (window.localStorage.getItem("errorCount") !== null) {
24 window.localStorage.removeItem("errorCount");
25 }
26
27 if (window.localStorage.getItem("successCount") !== null) {
28 window.localStorage.removeItem("successCount");
29 }
30 }, false);
31
32 if (window.localStorage.getItem("errorCount") === null) {
33 window.localStorage.setItem("errorCount", 0);
34 }
35
36 if (window.localStorage.getItem("successCount") === null) {
37 window.localStorage.setItem("successCount", 0);
38 }
39
40 var crossOrigin = 'http://localhost:8000';
41 var filePath = '/loading/resources/js-loaded.js?reload';
42
43 // First time the script will be blocked and onError will reload the page.
44 // On reload the script should not be blocked.
45 // This tests two types of reload, one with and one without cache bypass.
46 // The script should not be blocked in both cases.
47 src = crossOrigin + filePath;
48 document.write('<scr' + 'ipt src="' + src + '" onload="test(successTest,\'Lo ad Success\')" onError="test(errorTest,\'Load Error\')"></scr' + 'ipt>');
49
50 var successTest = function() {
51 assert_equals(+window.localStorage.getItem("errorCount"),1,"errorCount i s not one");
jkarlin 2016/04/19 11:00:34 What does the + do before window? You use it below
jkarlin 2016/04/19 14:23:59 no need for the comment
shivanisha 2016/04/20 14:14:00 This is to convert string "1" to integer 1. Remove
52
53 var successCount = +window.localStorage.getItem("successCount");
54 assert_greater_than_equal(successCount,0,"successCount is not >= zero");
jkarlin 2016/04/19 11:00:35 spaces between parameters
jkarlin 2016/04/19 14:23:59 no need for the comment
shivanisha 2016/04/20 14:13:59 Added spaces. removed comment.
55
56 if (successCount == 0)
57 {
58 window.localStorage.setItem("successCount", 1);
59 internals.forceReload(true);
60 return;
61 }
62
63 // This code path will only be followed for the second reload.
jkarlin 2016/04/19 11:00:34 Comment not necessary, the assert makes that clear
shivanisha 2016/04/20 14:13:59 removed.
64 assert_equals(successCount, 1, "successCount is not one");
jkarlin 2016/04/19 14:23:59 The comment "successCount is not one" doesn't conv
shivanisha 2016/04/20 14:13:59 Agree the comments are redundant. done.
65 window.localStorage.removeItem("errorCount");
66 window.localStorage.removeItem("successCount");
67 reloadTestSuccess=true;
68 }
69
70 var errorTest = function() {
71 assert_equals(+window.localStorage.getItem("errorCount"),0,"errorCount i s not zero");
jkarlin 2016/04/19 11:00:35 spaces between parameters
jkarlin 2016/04/19 14:23:59 no need for the comment
shivanisha 2016/04/20 14:14:00 done.
72 assert_equals(+window.localStorage.getItem("successCount"),0,"successCou nt is not zero");
jkarlin 2016/04/19 11:00:35 spaces between parameters
jkarlin 2016/04/19 14:23:59 no need for the comment
shivanisha 2016/04/20 14:14:00 done.
73 window.localStorage.setItem("errorCount", 1);
74 internals.forceReload(false);
75 }
76
77 </script>
78
79 <script>
80 test(function () {
81 assert_true(reloadTestSuccess);
82 }, "cross origin doc.written scripts are not blocked in a page reload");
83 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698