Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ext/fetch): add Headers#getSetCookie #13542

Merged
merged 4 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ext/fetch/20_headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class Headers {
* @param {string} name
*/
delete(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'delete' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
Expand All @@ -333,6 +334,7 @@ class Headers {
* @param {string} name
*/
get(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'get' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
Expand All @@ -345,10 +347,25 @@ class Headers {
return getHeader(list, name);
}

getSetCookie() {
webidl.assertBranded(this, HeadersPrototype);
const list = this[_headerList];

const entries = [];
for (let i = 0; i < list.length; i++) {
if (byteLowerCase(list[i][0]) === "set-cookie") {
ArrayPrototypePush(entries, list[i][1]);
}
}

return entries;
}

/**
* @param {string} name
*/
has(name) {
webidl.assertBranded(this, HeadersPrototype);
const prefix = "Failed to execute 'has' on 'Headers'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters["ByteString"](name, prefix, "Argument 1");
Expand Down
20 changes: 0 additions & 20 deletions tools/wpt/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4041,25 +4041,9 @@
"headers-record.any.worker.html": true,
"headers-structure.any.worker.html": true,
"header-setcookie.any.html": [
"Headers.prototype.getSetCookie with no headers present",
"Headers.prototype.getSetCookie with one header",
"Headers.prototype.getSetCookie with one header created from an object",
"Headers.prototype.getSetCookie with multiple headers",
"Headers.prototype.getSetCookie with an empty header",
"Headers.prototype.getSetCookie with two equal headers",
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
"Headers.prototype.getSetCookie preserves header ordering",
"Set-Cookie is a forbidden response header"
],
"header-setcookie.any.worker.html": [
"Headers.prototype.getSetCookie with no headers present",
"Headers.prototype.getSetCookie with one header",
"Headers.prototype.getSetCookie with one header created from an object",
"Headers.prototype.getSetCookie with multiple headers",
"Headers.prototype.getSetCookie with an empty header",
"Headers.prototype.getSetCookie with two equal headers",
"Headers.prototype.getSetCookie ignores set-cookie2 headers",
"Headers.prototype.getSetCookie preserves header ordering",
"Set-Cookie is a forbidden response header"
]
},
Expand Down Expand Up @@ -4890,8 +4874,6 @@
]
},
"idlharness.any.html": [
"Headers interface: operation getSetCookie()",
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
"Request interface: attribute destination",
"Request interface: attribute referrer",
"Request interface: attribute referrerPolicy",
Expand Down Expand Up @@ -4923,8 +4905,6 @@
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
],
"idlharness.any.worker.html": [
"Headers interface: operation getSetCookie()",
"Headers interface: new Headers() must inherit property \"getSetCookie()\" with the proper type",
"Request interface: attribute destination",
"Request interface: attribute referrer",
"Request interface: attribute referrerPolicy",
Expand Down