Closed Bug 2069948 Opened 2 months ago Closed 2 months ago

cookieStore.delete() doesn't respect given domain

Categories

(Core :: Networking: Cookies, defect)

Firefox 156
defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: bugzilla.memmie, Assigned: baku)

References

Details

Attachments

(1 external file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:156.0) Gecko/20100101 Firefox/156.0

Steps to reproduce:

  1. go on https://www.example.com/
  2. execute the following code :
await cookieStore.set({name: "a", value: "example.com", domain: "example.com"});
await cookieStore.set({name: "a", value: "www.example.com", domain: "www.example.com"});
await cookieStore.set({name: "a", value: "null", domain: null});
for(let i = 3; i-- > 0;) await cookieStore.delete({name: "a", domain: "www.example.com"});// twice
const actual = (await cookieStore.getAll()).map(c => `${c.name}=${c.value}`).join("; ");
const expected = "a=example.com; a=null";
console.assert(actual === expected, actual, expected); 

Actual results:

Got an assertion fail exception:

Assertion failed: <empty string> a=example.com; a=null

All cookies are deleted.

It look likes the domain is ignored, and it is already known.

Expected results:

No assertion fail. Only subdomain cookie should be deleted.

We should be able to delete cookie on subdomain, but not all cookies availables.
That what we can do with document.cookie API:

document.cookie = `a=example.com; Secure; Domain=example.com`;
document.cookie = `a=www.example.com; Secure; Domain=www.example.com`;
document.cookie = `a=null; Secure`;
for(let i = 3; i-- > 0;) document.cookie = `a=; Secure; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Domain=www.example.com`;
const actual = document.cookie;
const expected = "a=example.com; a=null";
console.assert(actual === expected, actual, expected); 

The Bugbug bot thinks this bug should belong to the 'Core::Networking: Cookies' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Networking: Cookies
Product: Firefox → Core
Assignee: nobody → amarchesini
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Backed out for causing wpt failures
Backout Link
Push with failures
Failure Log
Failure line TEST-UNEXPECTED-FAIL | /cookiestore/httponly_cookies.https.window.html | HttpOnly cookies are not observed - assert_equals: HttpOnly cookie we wrote using HTTP in cookie jar is invisible to script expected (undefined) undefined but got (string) "uppercase=cookie-value"

Flags: needinfo?(amarchesini)
Attachment #9639667 - Attachment description: Bug 2069948 - Do not let cookieStore.delete() remove cookies set on a parent domain → Bug 2069948 - Make cookieStore.delete() remove only the cookie it targets
Flags: needinfo?(amarchesini)
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/62602 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

:baku did you want to nominate this for 158 release notes?

Flags: needinfo?(amarchesini)

No. it was simply a bug.

Flags: needinfo?(amarchesini)
See Also: → 1929973
QA Whiteboard: [qa-triage-done-c159/b158]
Blocks: 1929973
See Also: 1929973 →
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: