localStorage access crashes script in an iframe with third-party cookies blocked

When third-party cookies are blocked and the script runs in an iframe, any reference to `window.localStorage` or `window.sessionStorage` throws an error, which breaks the script and anything that comes after it.