From 4ee3f575f6fc5fe0e2b6573e8a8d9c94c863d49e Mon Sep 17 00:00:00 2001 From: 2shiori17 <98276492+2shiori17@users.noreply.github.com> Date: Sun, 5 Mar 2023 00:52:19 +0900 Subject: [PATCH] Implement Headers.prototype.getSetCookie --- components/script/dom/headers.rs | 10 ++++++ components/script/dom/webidls/Headers.webidl | 1 + .../api/headers/header-setcookie.any.js.ini | 36 ------------------- 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 03fecd79c5a..c2ae32e4079 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -155,6 +155,16 @@ impl HeadersMethods for Headers { .map(|v| ByteString::new(v.as_bytes().to_vec()))) } + // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie + fn GetSetCookie(&self) -> Vec { + self.header_list + .borrow() + .get_all("Set-Cookie") + .iter() + .map(|v| ByteString::new(v.as_bytes().to_vec())) + .collect() + } + // https://fetch.spec.whatwg.org/#dom-headers-has fn Has(&self, name: ByteString) -> Fallible { // Step 1 diff --git a/components/script/dom/webidls/Headers.webidl b/components/script/dom/webidls/Headers.webidl index 16e35060b90..5def3e7011e 100644 --- a/components/script/dom/webidls/Headers.webidl +++ b/components/script/dom/webidls/Headers.webidl @@ -15,6 +15,7 @@ interface Headers { undefined delete(ByteString name); [Throws] ByteString? get(ByteString name); + sequence getSetCookie(); [Throws] boolean has(ByteString name); [Throws] diff --git a/tests/wpt/metadata/fetch/api/headers/header-setcookie.any.js.ini b/tests/wpt/metadata/fetch/api/headers/header-setcookie.any.js.ini index 73ccab628cd..bf12e514657 100644 --- a/tests/wpt/metadata/fetch/api/headers/header-setcookie.any.js.ini +++ b/tests/wpt/metadata/fetch/api/headers/header-setcookie.any.js.ini @@ -23,33 +23,15 @@ [Headers.prototype.append works for set-cookie] expected: FAIL - [Headers.prototype.getSetCookie with no headers present] - expected: FAIL - - [Headers.prototype.getSetCookie with one header] - expected: FAIL - - [Headers.prototype.getSetCookie with one header created from an object] - expected: FAIL - [Headers.prototype.getSetCookie with multiple headers] expected: FAIL - [Headers.prototype.getSetCookie with an empty header] - expected: FAIL - [Headers.prototype.getSetCookie with two equal headers] expected: FAIL - [Headers.prototype.getSetCookie ignores set-cookie2 headers] - expected: FAIL - [Headers.prototype.getSetCookie preserves header ordering] expected: FAIL - [Set-Cookie is a forbidden response header] - expected: FAIL - [Headers iterator is correctly updated with set-cookie changes #2] expected: FAIL @@ -79,33 +61,15 @@ [Headers.prototype.append works for set-cookie] expected: FAIL - [Headers.prototype.getSetCookie with no headers present] - expected: FAIL - - [Headers.prototype.getSetCookie with one header] - expected: FAIL - - [Headers.prototype.getSetCookie with one header created from an object] - expected: FAIL - [Headers.prototype.getSetCookie with multiple headers] expected: FAIL - [Headers.prototype.getSetCookie with an empty header] - expected: FAIL - [Headers.prototype.getSetCookie with two equal headers] expected: FAIL - [Headers.prototype.getSetCookie ignores set-cookie2 headers] - expected: FAIL - [Headers.prototype.getSetCookie preserves header ordering] expected: FAIL - [Set-Cookie is a forbidden response header] - expected: FAIL - [Headers iterator is correctly updated with set-cookie changes #2] expected: FAIL