MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
449 stars 53 forks source link

Third Party Cookies being blocked #2958

Closed RusselRillema closed 1 year ago

RusselRillema commented 1 year ago

Description WebView2 appears to be blocking Third Party Cookies. We are using WebView2 to load up the HTML pasted below. I believe the internals of tv.js have changed and now store 3rd party cookies as we have started getting the following error in WebView2 "Failed to read the 'localStorage' property from 'Window': Access is denied for this document."

If you save this HTML to a file and load it in a web browser it works fine however if we Block third-party cookies in the browser we get the same error mentioned above.

This leads me to believe WebView2 must be blocking these Third Party Cookies

Version SDK: 1.0.1418.22 (did also test on 1.0.1466-prerelease) Framework: WinForms OS: Win11

Repro Steps Load the below html in a webview2 control (it does not finish loading as the above mentioned exception is throw) Save the below html to an html file Load the html file in a standard web browser (i.e., chrome) - assuming "Allow all cookies" is selected in chrome it will work Set Block third-party cookies and refresh the page. In the console window the same exception will be thrown

HTML file content

sinand99 commented 1 year ago

I have the same issue. I can't render any widget from tradingview inside currrent WebView2. It was working fine until now, I think something has changed with the latest version.

error

As RusselRillema said, this error happens when third party cookies are disabled. Why is webview2 blocking third party cookies by default? I can't find any setting to enable it in code.

My app is broken now and I need a solution urgently!!!

RusselRillema commented 1 year ago

Hi @sinand99 Yes, this is exactly what we are experiencing. We also have a production application that is now not working because of this. If you do find any work arounds you are using in the meantime please let me know.

@peiche-jessica, if you need any additional information or testing done please let me know. I'll be happy to do anything I can to get this resolved asap

Cheers

peiche-jessica commented 1 year ago

Hello @RusselRillema, could you please share the WebView2 runtime version before/after you observe that the third-party cookies being blocked?

RusselRillema commented 1 year ago

Hi @peiche-jessica Thanks so much for getting back to us. The runtime I have installed is 107.0.1418.42 (I did not change this during the testing)

It seems like TradingView have updated their tv.js script to not require these 3rd party cookies anymore so unfortunately it's a little more difficult to reproduce now but I do believe this is still an issue in WebView2 and I am nervous if 3rd party cookies are required in the future we'll be back without a working product :/

Please let me know if you need anything further from my end. Cheers

muhamedRadwan commented 1 year ago

any update on that?

peiche-jessica commented 1 year ago

@RusselRillema AFAIK we don't explicitly block third party cookies by default. Although Tracking Prevention is by default on Balanced mode. Could it be related to your scenario? Also, I understand that TradingView may have updated their code. Have you experienced this with other site as well? It seems a TradingView login is required to repro with the provided HTML content.

@muhamedRadwan If you've also experienced this, could you please share a repro?

xu-ms commented 1 year ago

@RusselRillema I try another website to test 3rd party cookies, and it is work.

@muhamedRadwan If you've same error, could you please share a repro then I can test that.

RusselRillema commented 1 year ago

Unfortunately I can't find another way to reproduce the issue either. I don't know if Tracking Prevention could have caused it. It seems unlikely but I really don't know what the internals of TradingView were trying to do that caused that cookie error.

For my part I am happy to close the issue and I'll reopen it if I find another scenario where I am getting the same error.

Unless @sinand99 or @muhamedRadwan have any input on the matter?

xu-ms commented 1 year ago

Will close this issue. If there is still an issue, please reactivate it.