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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-structure.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 structure</title>
6 <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7 <meta name="author" title="Canon Research France" href="https://www.crf.cano n.fr">
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 </head>
11 <body>
12 <script>
13 var request = new Request("");
14 var methods = ["clone",
15 //Request implements Body
16 "arrayBuffer",
17 "blob",
18 "formData",
19 "json",
20 "text"
21 ];
22 var attributes = ["method",
23 "url",
24 "headers",
25 "type",
26 "destination",
27 "referrer",
28 "referrerPolicy",
29 "mode",
30 "credentials",
31 "cache",
32 "redirect",
33 "integrity",
34 //Request implements Body
35 "bodyUsed"
36 ];
37
38 function IsreadOnly(request, attributeToCheck) {
39 var defaultValue = undefined;
40 var newValue = undefined;
41 switch (attributeToCheck) {
42 case "method":
43 defaultValue = "GET";
44 newValue = "POST";
45 break;
46
47 case "url":
48 //default value is base url
49 //i.e http://web-platform.test:8000/fetch/api/request-structure.html
50 newValue = "http://url.test";
51 break;
52
53 case "headers":
54 request.headers = new Headers ({"name":"value"});
55 assert_false(request.headers.has("name"), "Headers attribute is read only");
56 return;
57 break;
58
59 case "type":
60 defaultValue = "";
61 newValue = "style";
62 break;
63
64 case "destination":
65 defaultValue = "";
66 newValue = "worker";
67 break;
68
69 case "referrer":
70 defaultValue = "about:client";
71 newValue = "http://url.test";
72 break;
73
74 case "referrerPolicy":
75 defaultValue = "";
76 newValue = "unsafe-url";
77 break;
78
79 case "mode":
80 defaultValue = "cors";
81 newValue = "navigate";
82 break;
83
84 case "credentials":
85 defaultValue = "omit";
86 newValue = "cors";
87 break;
88
89 case "cache":
90 defaultValue = "default";
91 newValue = "reload";
92 break;
93
94 case "redirect":
95 defaultValue = "follow";
96 newValue = "manual";
97 break;
98
99 case "integrity":
100 newValue = "CannotWriteIntegrity";
101 break;
102
103 case "bodyUsed":
104 defaultValue = false;
105 newValue = true;
106 break;
107
108 default:
109 return;
110 }
111
112 request[attributeToCheck] = newValue;
113 if (defaultValue === undefined)
114 assert_not_equals(request[attributeToCheck], newValue, "Attribute " + attributeToCheck + " is read only");
115 else
116 assert_equals(request[attributeToCheck], defaultValue,
117 "Attribute " + attributeToCheck + " is read only. Default value is " + defaultValue);
118 }
119
120 for (var idx in methods) {
121 test(function() {
122 assert_true(methods[idx] in request, "request has " + methods[idx] + " method");
123 }, "Request has " + methods[idx] + " method");
124 }
125
126 for (var idx in attributes) {
127 test(function() {
128 assert_true(attributes[idx] in request, "request has " + attributes[id x] + " attribute");
129 IsreadOnly(request, attributes[idx]);
130 }, "Check " + attributes[idx] + " attribute");
131 }
132 </script>
133 </body>
134 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698