File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -533,10 +533,19 @@ declare global {
533533}
534534
535535// Only set `Glean` values whenever running inside of a browser.
536- if (
537- typeof window !== "undefined" &&
538- typeof window . sessionStorage !== "undefined"
539- ) {
536+ // When cookies/localStorage/sessionStorage are disabled (at least in Firefox
537+ // and Chrome), an access attempt on the window.sessionStorage property will
538+ // throw an error ("The operation is insecure." in Firefox).
539+ // So try-catch is needed here.
540+ let hasStorage = false ;
541+ try {
542+ hasStorage = typeof window !== "undefined" &&
543+ typeof window . sessionStorage !== "undefined" ;
544+ } catch ( e ) {
545+ console . error ( "No session storage available" , e ) ;
546+ }
547+
548+ if ( hasStorage ) {
540549 window . Glean = {
541550 setLogPings : ( flag : boolean ) => {
542551 setDebugOptionInSessionStorage ( DebugOption . LogPings , flag ) ;
You can’t perform that action at this time.
0 commit comments