Yes as far I have seen the way to grant request access to storage api is to ask for user gesture in iframe, but even I am unable to get the pop-up as well as when initating user gesture and calling the requeststorageaccess() fn through the button click in iframe , its still denying the storage access to third party cookies.
this https://webkit.org/blog/8124/introducing-storage-access-api/ article suggest to use iframe for requesting storage access if doesn't have access.
I have tried it in this way but its not working , if someone could help .... the third party cookie is shown as expired in safari , so in order to request storage access for it we needed user gesture in iframe
<script>
function onLoginClicked() {
document.requestStorageAccess().then(() => {
console.log('Access granted: Safe to access storage now');
settingCookie();
}).catch(e => {
console.log("access denied")
});
}
function settingCookie() {
document.cookie = "lastname=kumar";
console.log(document.cookie);
}
if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
document.addEventListener("DOMContentLoaded", () => {
document.hasStorageAccess().then(access => {
if (access) {
console.log('has access');
settingCookie();
} else {
console.log('no access')
}
});
});
}
else {
console.log('not safari browser')
}
It's because it's basically broken.
FireFox has also implemented the Storage Access API and it works as documented.
For Safari you can kind of make it work by doing the following:
After all of this, the page in the iframe will only have access if the url doesn't change at all. If anything changes - another subpage or even a change in query string params will force the page to request access again.
This is ridiculous. For use we use Iframes a part of cross-domain authentication scheme so it is completely unusable in Safari, but works in every other browser on the planet. Makes me wish for the days IE.
Safari has 12% of the market share because it's on all apple devices -- otherwise I would recommend that company refuse to support it at all.