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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/conditional-get.html

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 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 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Request ETag</title>
6 <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7 <script src="/resources/testharness.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script src="/common/utils.js"></script>
10 </head>
11 <body>
12 <script>
13 promise_test(function() {
14 var cacheBuster = token(); // ensures first request is uncached
15 var url = "../resources/cache.py?v=" + cacheBuster;
16 var etag;
17
18 // make the first request
19 return fetch(url).then(function(response) {
20 // ensure we're getting the regular, uncached response
21 assert_equals(response.status, 200);
22 assert_equals(response.headers.get("X-HTTP-STATUS"), null)
23
24 return response.text(); // consuming the body, just to be safe
25 }).then(function(body) {
26 // make a second request
27 return fetch(url);
28 }).then(function(response) {
29 // while the server responds with 304 if our browser sent the correct
30 // If-None-Match request header, at the JavaScript level this surfaces
31 // as 200
32 assert_equals(response.status, 200);
33 assert_equals(response.headers.get("X-HTTP-STATUS"), "304")
34
35 etag = response.headers.get("ETag")
36
37 return response.text(); // consuming the body, just to be safe
38 }).then(function(body) {
39 // make a third request, explicitly setting If-None-Match request header
40 var headers = { "If-None-Match": etag }
41 return fetch(url, { headers: headers })
42 }).then(function(response) {
43 // 304 now surfaces thanks to the explicit If-None-Match request header
44 assert_equals(response.status, 304);
45 });
46 }, "Testing conditional GET with ETags");
47
48 done();
49 </script>
50 </body>
51 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698