Skip to content

Conversation

@estefysc
Copy link
Contributor

Add support for parsing and processing the Clear-Site-Data HTTP response header per W3C specification. This causes the navigation.https.html WPT test to go from timeout to pass.

Implemented:

  • Storage clearing (origin-scoped): LocalStorage, SessionStorage, IndexedDB, ServiceWorkers, Caches
  • Cookie clearing (global - CookieJar lacks domain-scoped API)
  • Header parsing for "cache", "cookies", "storage", "*" directives

Not implemented:

  • Cache clearing (no API available)
  • ExecutionContexts/reload

Testing:
WPT test clear-site-data/navigation.https.html passes via browser runner (./Meta/ladybird.py).

page.client().page_did_set_cookie(url, cookie.value(), Cookie::Source::Http); // FIXME: Determine cookie source correctly
}

// https://www.w3.org/TR/clear-site-data/#parsing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you first make sure your using the editor's draft of this spec?
I.e. https://w3c.github.io/webappsec-clear-site-data/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

void WebContentClient::did_clear_all_cookies(URL::URL url)
{
(void)url;
Application::cookie_jar().expire_cookies_accessed_since(UnixDateTime::from_seconds_since_epoch(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't thoroughly looked at this patch, but this caught my eye - I really do not want a single site sending a Clear-Site-Data header to delete all of my cookies.

Imagine github.com sending this header and suddenly you're logged out of youtube.com.

Copy link
Contributor Author

@estefysc estefysc Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I understand that. I was trying to stay within scope for this PR (added the fixme noting per origin clearing needed to be implemented). If it's no problem, then I can implement the per origin clearing before resubmitting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should definitely not clear everything; please update the PR to do this per origin instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@estefysc
Copy link
Contributor Author

I am resubmitting with code that clears cookies per origin and with the editor's draft url for the spec.

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Nov 27, 2025
@github-actions
Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Nov 28, 2025
Add support for parsing and processing the Clear-Site-Data HTTP
response header per W3C specification. This causes the
navigation.https.html WPT test to go from timeout to pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants