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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/header-values-normalize.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 <meta charset=utf8>
3 <meta name=timeout content=long>
4 <title>Header value normalizing test</title>
5 <script src=/resources/testharness.js></script>
6 <script src=/resources/testharnessreport.js></script>
7 <div id=log></div>
8 <script>
9 for(let i = 0; i < 0x21; i++) {
10 let fail = false,
11 strip = false
12
13 // REMOVE 0x0B/0x0C exception once https://github.com/w3c/wptserve/issues/111 is fixed
14 if(i === 0x0B || i === 0x0C)
15 continue
16
17 if(i === 0) {
18 fail = true
19 }
20
21 if(i === 0x09 || i === 0x0A || i === 0x0D || i === 0x20) {
22 strip = true
23 }
24
25 let url = "../resources/inspect-headers.py?headers=val1|val2|val3",
26 val = String.fromCharCode(i),
27 expectedVal = strip ? "" : val,
28 val1 = val,
29 expectedVal1 = expectedVal,
30 val2 = "x" + val,
31 expectedVal2 = "x" + expectedVal,
32 val3 = val + "x",
33 expectedVal3 = expectedVal + "x"
34
35 async_test((t) => {
36 let xhr = new XMLHttpRequest()
37 xhr.open("POST", url)
38 if(fail) {
39 assert_throws("SyntaxError", () => xhr.setRequestHeader("val1", val1))
40 assert_throws("SyntaxError", () => xhr.setRequestHeader("val2", val2))
41 assert_throws("SyntaxError", () => xhr.setRequestHeader("val3", val3))
42 t.done()
43 } else {
44 xhr.setRequestHeader("val1", val1)
45 xhr.setRequestHeader("val2", val2)
46 xhr.setRequestHeader("val3", val3)
47 xhr.onload = t.step_func_done(() => {
48 assert_equals(xhr.getResponseHeader("x-request-val1"), expectedVal1)
49 assert_equals(xhr.getResponseHeader("x-request-val2"), expectedVal2)
50 assert_equals(xhr.getResponseHeader("x-request-val3"), expectedVal3)
51 })
52 xhr.send()
53 }
54 }, "XMLHttpRequest with value " + encodeURI(val))
55
56 promise_test((t) => {
57 if(fail) {
58 return Promise.all([
59 promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"va l1": val1} })),
60 promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"va l2": val2} })),
61 promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"va l3": val3} }))
62 ])
63 } else {
64 return fetch(url, { headers: {"val1": val1, "val2": val2, "val3": val3} }) .then((res) => {
65 assert_equals(res.headers.get("x-request-val1"), expectedVal1)
66 assert_equals(res.headers.get("x-request-val2"), expectedVal2)
67 assert_equals(res.headers.get("x-request-val3"), expectedVal3)
68 })
69 }
70 }, "fetch() with value " + encodeURI(val))
71 }
72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698