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

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/sync-repeated-and-caching.html

Issue 150103005: Reduce scope (and running time) of sync-repeated-and-caching test. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/xmlhttprequest/sync-repeated-and-caching-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Synchronous XMLHttpRequest and caching during document load</title> 4 <title>Synchronous XMLHttpRequest and caching during document load</title>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script src="../resources/testharness.js"></script> 7 <script src="../resources/testharness.js"></script>
8 <script src="../resources/testharnessreport.js"></script> 8 <script src="../resources/testharnessreport.js"></script>
9 <script type="text/javascript"> 9 <script type="text/javascript">
10 10
11 // Test what caching XMLHttpRequest performs when issuing 11 // Test what caching XMLHttpRequest performs when issuing sync
12 // sync requests over various verbs and with various 12 // requests over various verbs and with various kinds of query
13 // kinds of query portions. Without any cache control 13 // portions. Without any cache control headers.
14 // headers. 14 var verbs = [ "GET", "POST" ];
15 var verbs = [ "GET",
16 "PUT",
17 "POST",
18 "PROPFIND"];
19 15
20 var query_kinds = [ 16 var query_kinds = [
21 {query: "'?random'", 17 {query: "'?random'",
22 name: "constant query", 18 name: "constant query"},
23 // The list of verbs we expect the request not to be repeated for.
24 should_cache: []},
25 {query: "", 19 {query: "",
26 name: "no query", 20 name: "no query"},
27 should_cache: []},
28 {query: "'?' + (Math.random() + Date.now()).toString()", 21 {query: "'?' + (Math.random() + Date.now()).toString()",
29 name: "unique query string", 22 name: "unique query string"}];
30 should_cache: []},
31 {query: "'?'",
32 name: "empty query",
33 should_cache: []}];
34 23
35 var base_url = "resources/echo-random.php"; 24 var base_url = "resources/echo-random.php";
36 25
26 function fetchSyncTextResponse(verb, url) {
27 var xhr = new XMLHttpRequest();
28 xhr.open(verb, url, false);
29 xhr.send();
30 return xhr.responseText;
31 }
32
37 function runTest() { 33 function runTest() {
38 for (var i = 0; i < verbs.length; i++) { 34 for (var i = 0; i < verbs.length; i++) {
39 var verb = verbs[i]; 35 var verb = verbs[i];
40 for (var j = 0; j < query_kinds.length; j++) { 36 for (var j = 0; j < query_kinds.length; j++) {
41 var q1 = eval(query_kinds[j].query) || "";
42
43 var request_url1 = base_url + q1;
44 var xhr1 = new XMLHttpRequest;
45 xhr1.open(verb, request_url1, false);
46 xhr1.send();
47 var result1 = xhr1.responseText;
48
49 var xhr2 = new XMLHttpRequest();
50 var q2 = eval(query_kinds[j].query) || "";
51 var request_url2 = base_url + q2;
52 xhr2.open(verb, request_url2, false);
53 xhr2.send();
54 var result2 = xhr2.responseText;
55
56 test(function () { 37 test(function () {
57 if (query_kinds[j].should_cache.indexOf(verb) >= 0) 38 var q1 = eval(query_kinds[j].query) || "";
58 assert_true(result1 === result2); 39 var q2 = eval(query_kinds[j].query) || "";
59 else 40 var result1 = fetchSyncTextResponse(verb, base_url + q1);
60 assert_false(result1 === result2); 41 var result2 = fetchSyncTextResponse(verb, base_url + q2);
61 }, "Test repeated sync requests using verb '" + verb + " with " + qu ery_kinds[j].name); 42 assert_false(result1 === result2);
43 }, "Test repeated sync requests using verb '" + verb + "' with " + q uery_kinds[j].name);
62 } 44 }
63 } 45 }
64 } 46 }
65 47
66 test(runTest, document.title); 48 test(runTest, document.title);
67 </script> 49 </script>
68 <div id="log"></div>
69 </body> 50 </body>
70 </html> 51 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/xmlhttprequest/sync-repeated-and-caching-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698