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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-init-001.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>Response init: simple cases</title>
6 <meta name="help" href="https://fetch.spec.whatwg.org/#response">
7 <meta name="help" href="https://fetch.spec.whatwg.org/#concept-response">
8 <meta name="author" title="Canon Research France" href="https://www.crf.cano n.fr">
9 <script src="/resources/testharness.js"></script>
10 <script src="/resources/testharnessreport.js"></script>
11 </head>
12 <body>
13 <script>
14 var defaultValues = { "type" : "default",
15 "url" : "",
16 "ok" : true,
17 "status" : 200,
18 "statusText" : "OK",
19 "body" : null
20 };
21
22 var statusCodes = { "givenValues" : [200, 300, 400, 500, 599],
23 "expectedValues" : [200, 300, 400, 500, 599]
24 };
25 var statusTexts = { "givenValues" : ["OK", "with space", String.fromCharCo de(0x80)],
26 "expectedValues" : ["OK", "with space", String.fromCharCo de(0x80)]
27 };
28 var initValuesDict = { "status" : statusCodes,
29 "statusText" : statusTexts
30 };
31
32 function isOkStatus(status) {
33 return 200 <= status && 299 >= status;
34 }
35
36 var response = new Response();
37 for (var attributeName in defaultValues) {
38 test(function() {
39 var expectedValue = defaultValues[attributeName];
40 assert_equals(response[attributeName], expectedValue,
41 "Expect default response." + attributeName + " is " + expectedValue) ;
42 }, "Check default value for " + attributeName + " attribute");
43 }
44
45 for (var attributeName in initValuesDict)
46 test(function() {
47 var valuesToTest = initValuesDict[attributeName];
48 for (var valueIdx in valuesToTest["givenValues"]) {
49 var givenValue = valuesToTest["givenValues"][valueIdx];
50 var expectedValue = valuesToTest["expectedValues"][valueIdx];
51 var responseInit = {};
52 responseInit[attributeName] = givenValue;
53 var response = new Response("", responseInit);
54 assert_equals(response[attributeName], expectedValue,
55 "Expect response." + attributeName + " is " + expectedValue +
56 " when initialized with " + givenValue);
57 assert_equals(response.ok, isOkStatus(response.status),
58 "Expect response.ok is " + isOkStatus(response.status));
59 }
60 }, "Check " + attributeName + " init values and associated getter");
61 </script>
62 </body>
63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698