mirror of https://github.com/OpenVidu/openvidu.git
Tolerate inaccessible localStorage
When reading from localStorage, treat security exceptions like absent values. This supports running in third-party contexts when cross-origin cookies are blocked by the browser.pull/816/head
parent
918bf0ae6d
commit
566e52f1dd
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue