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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/header-values-normalize.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/header-values-normalize.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/header-values-normalize.html
new file mode 100644
index 0000000000000000000000000000000000000000..616d83acb7ebc1b5b72246bfc52e0348590fcb06
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/headers/header-values-normalize.html
@@ -0,0 +1,72 @@
+<!doctype html>
+<meta charset=utf8>
+<meta name=timeout content=long>
+<title>Header value normalizing test</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+for(let i = 0; i < 0x21; i++) {
+ let fail = false,
+ strip = false
+
+ // REMOVE 0x0B/0x0C exception once https://github.com/w3c/wptserve/issues/111 is fixed
+ if(i === 0x0B || i === 0x0C)
+ continue
+
+ if(i === 0) {
+ fail = true
+ }
+
+ if(i === 0x09 || i === 0x0A || i === 0x0D || i === 0x20) {
+ strip = true
+ }
+
+ let url = "../resources/inspect-headers.py?headers=val1|val2|val3",
+ val = String.fromCharCode(i),
+ expectedVal = strip ? "" : val,
+ val1 = val,
+ expectedVal1 = expectedVal,
+ val2 = "x" + val,
+ expectedVal2 = "x" + expectedVal,
+ val3 = val + "x",
+ expectedVal3 = expectedVal + "x"
+
+ async_test((t) => {
+ let xhr = new XMLHttpRequest()
+ xhr.open("POST", url)
+ if(fail) {
+ assert_throws("SyntaxError", () => xhr.setRequestHeader("val1", val1))
+ assert_throws("SyntaxError", () => xhr.setRequestHeader("val2", val2))
+ assert_throws("SyntaxError", () => xhr.setRequestHeader("val3", val3))
+ t.done()
+ } else {
+ xhr.setRequestHeader("val1", val1)
+ xhr.setRequestHeader("val2", val2)
+ xhr.setRequestHeader("val3", val3)
+ xhr.onload = t.step_func_done(() => {
+ assert_equals(xhr.getResponseHeader("x-request-val1"), expectedVal1)
+ assert_equals(xhr.getResponseHeader("x-request-val2"), expectedVal2)
+ assert_equals(xhr.getResponseHeader("x-request-val3"), expectedVal3)
+ })
+ xhr.send()
+ }
+ }, "XMLHttpRequest with value " + encodeURI(val))
+
+ promise_test((t) => {
+ if(fail) {
+ return Promise.all([
+ promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val1": val1} })),
+ promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val2": val2} })),
+ promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val3": val3} }))
+ ])
+ } else {
+ return fetch(url, { headers: {"val1": val1, "val2": val2, "val3": val3} }).then((res) => {
+ assert_equals(res.headers.get("x-request-val1"), expectedVal1)
+ assert_equals(res.headers.get("x-request-val2"), expectedVal2)
+ assert_equals(res.headers.get("x-request-val3"), expectedVal3)
+ })
+ }
+ }, "fetch() with value " + encodeURI(val))
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698