mirror of
https://github.com/servo/servo.git
synced 2025-08-18 03:45:33 +01:00
Update web-platform-tests to revision b'b6f6bf16fe6069aed53d28af86a79b8ff4963844'
This commit is contained in:
parent
0720f4f736
commit
8bfdc02dd8
590 changed files with 11442 additions and 3709 deletions
|
@ -0,0 +1,224 @@
|
|||
// META: title=Headers set-cookie special cases
|
||||
// META: global=window,worker
|
||||
|
||||
const headerList = [
|
||||
["set-cookie", "foo=bar"],
|
||||
["Set-Cookie", "fizz=buzz; domain=example.com"],
|
||||
];
|
||||
|
||||
const setCookie2HeaderList = [
|
||||
["set-cookie2", "foo2=bar2"],
|
||||
["Set-Cookie2", "fizz2=buzz2; domain=example2.com"],
|
||||
];
|
||||
|
||||
function assert_nested_array_equals(actual, expected) {
|
||||
assert_equals(actual.length, expected.length, "Array length is not equal");
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
assert_array_equals(actual[i], expected[i]);
|
||||
}
|
||||
}
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
assert_equals(
|
||||
headers.get("set-cookie"),
|
||||
"foo=bar, fizz=buzz; domain=example.com",
|
||||
);
|
||||
}, "Headers.prototype.get combines set-cookie headers in order");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie", "foo=bar"],
|
||||
["set-cookie", "fizz=buzz; domain=example.com"],
|
||||
]);
|
||||
}, "Headers iterator does not combine set-cookie headers");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(setCookie2HeaderList);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie2", "foo2=bar2, fizz2=buzz2; domain=example2.com"],
|
||||
]);
|
||||
}, "Headers iterator does not special case set-cookie2 headers");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([...headerList, ...setCookie2HeaderList]);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie", "foo=bar"],
|
||||
["set-cookie", "fizz=buzz; domain=example.com"],
|
||||
["set-cookie2", "foo2=bar2, fizz2=buzz2; domain=example2.com"],
|
||||
]);
|
||||
}, "Headers iterator does not combine set-cookie & set-cookie2 headers");
|
||||
|
||||
test(function () {
|
||||
// Values are in non alphabetic order, and the iterator should yield in the
|
||||
// headers in the exact order of the input.
|
||||
const headers = new Headers([
|
||||
["set-cookie", "z=z"],
|
||||
["set-cookie", "a=a"],
|
||||
["set-cookie", "n=n"],
|
||||
]);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie", "z=z"],
|
||||
["set-cookie", "a=a"],
|
||||
["set-cookie", "n=n"],
|
||||
]);
|
||||
}, "Headers iterator preserves set-cookie ordering");
|
||||
|
||||
test(
|
||||
function () {
|
||||
const headers = new Headers([
|
||||
["xylophone-header", "1"],
|
||||
["best-header", "2"],
|
||||
["set-cookie", "3"],
|
||||
["a-cool-header", "4"],
|
||||
["set-cookie", "5"],
|
||||
["a-cool-header", "6"],
|
||||
["best-header", "7"],
|
||||
]);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["a-cool-header", "4, 6"],
|
||||
["best-header", "2, 7"],
|
||||
["set-cookie", "3"],
|
||||
["set-cookie", "5"],
|
||||
["xylophone-header", "1"],
|
||||
]);
|
||||
},
|
||||
"Headers iterator preserves per header ordering, but sorts keys alphabetically",
|
||||
);
|
||||
|
||||
test(
|
||||
function () {
|
||||
const headers = new Headers([
|
||||
["xylophone-header", "7"],
|
||||
["best-header", "6"],
|
||||
["set-cookie", "5"],
|
||||
["a-cool-header", "4"],
|
||||
["set-cookie", "3"],
|
||||
["a-cool-header", "2"],
|
||||
["best-header", "1"],
|
||||
]);
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["a-cool-header", "4, 2"],
|
||||
["best-header", "6, 1"],
|
||||
["set-cookie", "5"],
|
||||
["set-cookie", "3"],
|
||||
["xylophone-header", "7"],
|
||||
]);
|
||||
},
|
||||
"Headers iterator preserves per header ordering, but sorts keys alphabetically (and ignores value ordering)",
|
||||
);
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([["fizz", "buzz"], ["X-Header", "test"]]);
|
||||
const iterator = headers[Symbol.iterator]();
|
||||
assert_array_equals(iterator.next().value, ["fizz", "buzz"]);
|
||||
headers.append("Set-Cookie", "a=b");
|
||||
assert_array_equals(iterator.next().value, ["set-cookie", "a=b"]);
|
||||
headers.append("Accept", "text/html");
|
||||
assert_array_equals(iterator.next().value, ["set-cookie", "a=b"]);
|
||||
assert_array_equals(iterator.next().value, ["x-header", "test"]);
|
||||
headers.append("set-cookie", "c=d");
|
||||
assert_array_equals(iterator.next().value, ["x-header", "test"]);
|
||||
assert_true(iterator.next().done);
|
||||
}, "Headers iterator is correctly updated with set-cookie changes");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
assert_true(headers.has("sEt-cOoKiE"));
|
||||
}, "Headers.prototype.has works for set-cookie");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(setCookie2HeaderList);
|
||||
headers.append("set-Cookie", "foo=bar");
|
||||
headers.append("sEt-cOoKiE", "fizz=buzz");
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie", "foo=bar"],
|
||||
["set-cookie", "fizz=buzz"],
|
||||
["set-cookie2", "foo2=bar2, fizz2=buzz2; domain=example2.com"],
|
||||
]);
|
||||
}, "Headers.prototype.append works for set-cookie");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
headers.set("set-cookie", "foo2=bar2");
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, [
|
||||
["set-cookie", "foo2=bar2"],
|
||||
]);
|
||||
}, "Headers.prototype.set works for set-cookie");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
headers.delete("set-Cookie");
|
||||
const list = [...headers];
|
||||
assert_nested_array_equals(list, []);
|
||||
}, "Headers.prototype.delete works for set-cookie");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers();
|
||||
assert_array_equals(headers.getSetCookie(), []);
|
||||
}, "Headers.prototype.getSetCookie with no headers present");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([headerList[0]]);
|
||||
assert_array_equals(headers.getSetCookie(), ["foo=bar"]);
|
||||
}, "Headers.prototype.getSetCookie with one header");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers({ "Set-Cookie": "foo=bar" });
|
||||
assert_array_equals(headers.getSetCookie(), ["foo=bar"]);
|
||||
}, "Headers.prototype.getSetCookie with one header created from an object");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers(headerList);
|
||||
assert_array_equals(headers.getSetCookie(), [
|
||||
"foo=bar",
|
||||
"fizz=buzz; domain=example.com",
|
||||
]);
|
||||
}, "Headers.prototype.getSetCookie with multiple headers");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([["set-cookie", ""]]);
|
||||
assert_array_equals(headers.getSetCookie(), [""]);
|
||||
}, "Headers.prototype.getSetCookie with an empty header");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([["set-cookie", "x"], ["set-cookie", "x"]]);
|
||||
assert_array_equals(headers.getSetCookie(), ["x", "x"]);
|
||||
}, "Headers.prototype.getSetCookie with two equal headers");
|
||||
|
||||
test(function () {
|
||||
const headers = new Headers([
|
||||
["set-cookie2", "x"],
|
||||
["set-cookie", "y"],
|
||||
["set-cookie2", "z"],
|
||||
]);
|
||||
assert_array_equals(headers.getSetCookie(), ["y"]);
|
||||
}, "Headers.prototype.getSetCookie ignores set-cookie2 headers");
|
||||
|
||||
test(function () {
|
||||
// Values are in non alphabetic order, and the iterator should yield in the
|
||||
// headers in the exact order of the input.
|
||||
const headers = new Headers([
|
||||
["set-cookie", "z=z"],
|
||||
["set-cookie", "a=a"],
|
||||
["set-cookie", "n=n"],
|
||||
]);
|
||||
assert_array_equals(headers.getSetCookie(), ["z=z", "a=a", "n=n"]);
|
||||
}, "Headers.prototype.getSetCookie preserves header ordering");
|
||||
|
||||
test(function () {
|
||||
const response = new Response();
|
||||
response.headers.append("Set-Cookie", "foo=bar");
|
||||
assert_array_equals(response.headers.getSetCookie(), []);
|
||||
response.headers.append("sEt-cOokIe", "bar=baz");
|
||||
assert_array_equals(response.headers.getSetCookie(), []);
|
||||
}, "Set-Cookie is a forbidden response header");
|
|
@ -59,6 +59,7 @@ var invalidRequestNoCorsHeaders = [
|
|||
["proxya", "KO"],
|
||||
["sec", "KO"],
|
||||
["secb", "KO"],
|
||||
["Empty-Value", ""],
|
||||
];
|
||||
|
||||
validRequestHeaders.forEach(function(header) {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
var priorities = ["high",
|
||||
"low",
|
||||
"auto"
|
||||
];
|
||||
|
||||
for (idx in priorities) {
|
||||
test(() => {
|
||||
new Request("", {priority: priorities[idx]});
|
||||
}, "new Request() with a '" + priorities[idx] + "' priority does not throw an error");
|
||||
}
|
||||
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
new Request("", {priority: 'invalid'});
|
||||
}, "a new Request() must throw a TypeError if RequestInit's priority is an invalid value");
|
||||
}, "new Request() throws a TypeError if any of RequestInit's members' values are invalid");
|
||||
|
||||
for (idx in priorities) {
|
||||
promise_test(function(t) {
|
||||
return fetch('hello.txt', { priority: priorities[idx] });
|
||||
}, "fetch() with a '" + priorities[idx] + "' priority completes successfully");
|
||||
}
|
||||
|
||||
promise_test(function(t) {
|
||||
return promise_rejects_js(t, TypeError, fetch('hello.txt', { priority: 'invalid' }));
|
||||
}, "fetch() with an invalid priority returns a rejected promise with a TypeError");
|
|
@ -26,7 +26,11 @@ var attributes = ["method",
|
|||
"duplex",
|
||||
//Request implements Body
|
||||
"bodyUsed"
|
||||
];
|
||||
];
|
||||
var internalAttributes = ["priority",
|
||||
"internalpriority",
|
||||
"blocking"
|
||||
];
|
||||
|
||||
function isReadOnly(request, attributeToCheck) {
|
||||
var defaultValue = undefined;
|
||||
|
@ -131,3 +135,9 @@ for (var idx in attributes) {
|
|||
isReadOnly(request, attributes[idx]);
|
||||
}, "Check " + attributes[idx] + " attribute");
|
||||
}
|
||||
|
||||
for (var idx in internalAttributes) {
|
||||
test(function() {
|
||||
assert_false(internalAttributes[idx] in request, "request does not expose " + internalAttributes[idx] + " attribute");
|
||||
}, "Request does not expose " + internalAttributes[idx] + " attribute");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue