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

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

Issue 59043006: Avoid reusing XMLHttpRequest resources during document load. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 <html>
3 <head>
4 <title>Synchronous XMLHttpRequest and caching</title>
5 </head>
6 <body>
7 <script src="../resources/testharness.js"></script>
8 <script src="../resources/testharnessreport.js"></script>
9 <script type="text/javascript">
10
11 // Test what caching XMLHttpRequest performs when issuing
12 // sync requests over various verbs and with various
13 // kinds of query portions. Without any cache control
14 // headers.
15 var verbs = [ "GET",
16 "PUT",
17 "POST",
18 "DELETE",
19 "OPTIONS",
20 "PROPFIND"];
21
22 var query_kinds = [
23 {query: "'?random'",
24 name: "constant query",
25 // The list of verbs we expect the request not to be repeated for.
26 should_cache: []},
27 {query: "",
28 name: "no query",
29 should_cache: []},
30 {query: "'?' + (Math.random() + Date.now()).toString()",
31 name: "unique query string",
32 should_cache: []},
33 {query: "'?'",
34 name: "empty query",
35 should_cache: []}];
36
37 var base_url = "resources/echo-random.php";
38
39 for (var i = 0; i < verbs.length; i++) {
40 var verb = verbs[i];
41 for (var j = 0; j < query_kinds.length; j++) {
42 var q1 = eval(query_kinds[j].query) || "";
43
44 var request_url1 = base_url + q1;
45 var xhr1 = new XMLHttpRequest;
46 xhr1.open(verb, request_url1, false);
47 xhr1.send();
48 var result1 = xhr1.responseText;
49
50 var xhr2 = new XMLHttpRequest();
51 var q2 = eval(query_kinds[j].query) || "";
52 var request_url2 = base_url + q2;
53 xhr2.open(verb, request_url2, false);
54 xhr2.send();
55 var result2 = xhr2.responseText;
56
57 test(function () {
58 if (query_kinds[j].should_cache.indexOf(verb) >= 0)
59 assert_true(result1 === result2);
60 else
61 assert_false(result1 === result2);
62 }, "Test repeated sync requests using verb '" + verb + " with " + query_ kinds[j].name);
63 }
64 }
65 </script>
66 </body>
67 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698