Catch error when the creation of localStorage polyfill fails in the generic viewer

This commit is contained in:
Jonas Jenwald 2014-04-29 10:49:08 +02:00
parent e62f18c975
commit 8bb19fac2d

View File

@ -547,13 +547,20 @@ if (typeof PDFJS === 'undefined') {
return;
}
} catch (e) { }
window.localStorage = {
data: Object.create(null),
getItem: function (key) {
return this.data[key];
},
setItem: function (key, value) {
this.data[key] = value;
}
};
// When the generic viewer is used in Firefox the following code will fail
// when the preference 'network.cookie.lifetimePolicy' is set to 1,
// see Mozilla bug 365772.
try {
window.localStorage = {
data: Object.create(null),
getItem: function (key) {
return this.data[key];
},
setItem: function (key, value) {
this.data[key] = value;
}
};
} catch (e) {
console.log('Unable to create polyfill for localStorage');
}
})();