Skip to content

Commit

Permalink
Merge pull request #816 from semmel/semmel-inaccessible-localStorage
Browse files Browse the repository at this point in the history
Tolerate inaccessible localStorage
  • Loading branch information
pabloFuente authored Aug 21, 2023
2 parents 918bf0a + 566e52f commit 2f20014
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ export class WebRtcStats {
}

public initWebRtcStats(): void {
const webrtcObj = localStorage.getItem(this.STATS_ITEM_NAME);
let webrtcObj = null;
// When cross-site (aka third-party) cookies are blocked by the browser,
// accessing localStorage in a third-party iframe throws a DOMException.
try {
webrtcObj = localStorage.getItem(this.STATS_ITEM_NAME);
}
catch(e){}

if (!!webrtcObj) {
this.webRtcStatsEnabled = true;
Expand Down

0 comments on commit 2f20014

Please sign in to comment.