Skip to content

Commit d8e8e60

Browse files
feat(ext/fetch): add Headers#getSetCookie (#13542)
Spec change: whatwg/fetch#1346 Tests: web-platform-tests/wpt#31442 (ran against this PR and they all pass) --------- Co-authored-by: Bartek Iwańczuk <[email protected]>
1 parent 0ddfd5d commit d8e8e60

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

ext/fetch/20_headers.js

+17
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class Headers {
308308
* @param {string} name
309309
*/
310310
delete(name) {
311+
webidl.assertBranded(this, HeadersPrototype);
311312
const prefix = "Failed to execute 'delete' on 'Headers'";
312313
webidl.requiredArguments(arguments.length, 1, prefix);
313314
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
@@ -333,6 +334,7 @@ class Headers {
333334
* @param {string} name
334335
*/
335336
get(name) {
337+
webidl.assertBranded(this, HeadersPrototype);
336338
const prefix = "Failed to execute 'get' on 'Headers'";
337339
webidl.requiredArguments(arguments.length, 1, prefix);
338340
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
@@ -345,10 +347,25 @@ class Headers {
345347
return getHeader(list, name);
346348
}
347349

350+
getSetCookie() {
351+
webidl.assertBranded(this, HeadersPrototype);
352+
const list = this[_headerList];
353+
354+
const entries = [];
355+
for (let i = 0; i < list.length; i++) {
356+
if (byteLowerCase(list[i][0]) === "set-cookie") {
357+
ArrayPrototypePush(entries, list[i][1]);
358+
}
359+
}
360+
361+
return entries;
362+
}
363+
348364
/**
349365
* @param {string} name
350366
*/
351367
has(name) {
368+
webidl.assertBranded(this, HeadersPrototype);
352369
const prefix = "Failed to execute 'has' on 'Headers'";
353370
webidl.requiredArguments(arguments.length, 1, prefix);
354371
name = webidl.converters["ByteString"](name, prefix, "Argument 1");

tools/wpt/expectation.json

-20
Original file line numberDiff line numberDiff line change
@@ -4041,25 +4041,9 @@
40414041
"headers-record.any.worker.html": true,
40424042
"headers-structure.any.worker.html": true,
40434043
"header-setcookie.any.html": [
4044-
"Headers.prototype.getSetCookie with no headers present",
4045-
"Headers.prototype.getSetCookie with one header",
4046-
"Headers.prototype.getSetCookie with one header created from an object",
4047-
"Headers.prototype.getSetCookie with multiple headers",
4048-
"Headers.prototype.getSetCookie with an empty header",
4049-
"Headers.prototype.getSetCookie with two equal headers",
4050-
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
4051-
"Headers.prototype.getSetCookie preserves header ordering",
40524044
"Set-Cookie is a forbidden response header"
40534045
],
40544046
"header-setcookie.any.worker.html": [
4055-
"Headers.prototype.getSetCookie with no headers present",
4056-
"Headers.prototype.getSetCookie with one header",
4057-
"Headers.prototype.getSetCookie with one header created from an object",
4058-
"Headers.prototype.getSetCookie with multiple headers",
4059-
"Headers.prototype.getSetCookie with an empty header",
4060-
"Headers.prototype.getSetCookie with two equal headers",
4061-
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
4062-
"Headers.prototype.getSetCookie preserves header ordering",
40634047
"Set-Cookie is a forbidden response header"
40644048
]
40654049
},
@@ -4890,8 +4874,6 @@
48904874
]
48914875
},
48924876
"idlharness.any.html": [
4893-
"Headers interface: operation getSetCookie()",
4894-
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
48954877
"Request interface: attribute destination",
48964878
"Request interface: attribute referrer",
48974879
"Request interface: attribute referrerPolicy",
@@ -4923,8 +4905,6 @@
49234905
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
49244906
],
49254907
"idlharness.any.worker.html": [
4926-
"Headers interface: operation getSetCookie()",
4927-
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
49284908
"Request interface: attribute destination",
49294909
"Request interface: attribute referrer",
49304910
"Request interface: attribute referrerPolicy",

0 commit comments

Comments
 (0)