Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #5860: Add window.caches blocking when cookie blocking is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
cuba authored and iccub committed Aug 15, 2022
1 parent d31187d commit 41d2705
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Client/Frontend/UserContent/UserScripts/CookieControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ if (Object.getOwnPropertyDescriptor(window, 'sessionStorage')) {
},
});
}

(() => {
// Access to caches should be denied when user has blocked all Cookies.
const makeFailingPromiseFunction = () => {
return function () {
return Promise.reject(
new DOMException('An attempt was made to break through the security policy of the user agent.')
)
}
}

// We need to check that window.caches is defined as this API was only added in iOS 15
// Later on we can probably remove this check.
if (window.caches !== undefined) {
window.CacheStorage.prototype.match = makeFailingPromiseFunction()
window.CacheStorage.prototype.has = makeFailingPromiseFunction()
window.CacheStorage.prototype.delete = makeFailingPromiseFunction()
window.CacheStorage.prototype.open = makeFailingPromiseFunction()
window.CacheStorage.prototype.keys = makeFailingPromiseFunction()
}
})()

0 comments on commit 41d2705

Please sign in to comment.