Description
What happened?
Due to this issue, we're using the workaround suggested here to delete partioned cookies.
This workaround used to work, but recently stopped.
This broke some time between Aug 27, 2024 (runtime 126 or 127) and 3/20/2025 (runtime 134)
Seems like this API is broken now:
https://chromedevtools.github.io/devtools-protocol/tot/Storage/#method-clearDataForOrigin
If we can't reliably use this workaround, then it's important for our app to have #4669 fixed
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
136.0.3227.0-canary, 134
SDK Version
3116.0
Framework
Winforms
Operating System
Windows 11
OS Version
26100.3476
Repro steps
Download the WinForms WebView2 sample app and build for .net 8 (to get access to System.Text.Json)
In BrowserForm.cs, change the HandleWebMessage
to:
async void HandleWebMessage(CoreWebView2WebMessageReceivedEventArgs args, CoreWebView2Frame frame = null)
{
if (args.WebMessageAsJson.Contains("AAA"))
{
var cm = this.webView2Control.CoreWebView2.CookieManager;
Dictionary<string, string> clearDataParams = new Dictionary<string, string>() {
{ "origin", "" },
{ "storageTypes", "cookies" }
};
foreach (CoreWebView2Cookie cookie in await cm.GetCookiesAsync(null))
{
if (cookie.Domain == "the-domain-you're-test")
{
cm.DeleteCookie(cookie);
clearDataParams["origin"] = new UriBuilder(cookie.IsSecure ? "https" : "http", cookie.Domain, -1, cookie.Path).Uri.ToString();
await this.webView2Control.CoreWebView2.CallDevToolsProtocolMethodAsync("Storage.clearDataForOrigin", JsonSerializer.Serialize(clearDataParams));
}
}
}
}
- start app
- Select Scenario menu item and click Web Message
- Open devtools and replace the frame with some site that sets a partioned cookie
- Then run the code
window.chrome.webview.postMessage("AAA")
- You can set a breakpoint and see that the deletion code is running
- Go to Application -> Cookies -> third party site and notice that the cookie hasn't been deleted
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Regression in newer Runtime
Last working version (if regression)
127