[PDFHistory] Fix "Warning: Unhandled rejection: [Exception... "The operation is insecure."" when opening local file

This commit is contained in:
Jonas Jenwald 2013-11-22 11:49:16 +01:00
parent 5ecb407ca7
commit ca8e3ea06f

View File

@ -65,8 +65,7 @@ var PDFHistory = {
// is opened in the web viewer.
this.reInitialized = true;
}
window.history.replaceState({ fingerprint: this.fingerprint }, '',
document.URL);
this._pushOrReplaceState({ fingerprint: this.fingerprint }, true);
}
var self = this;
@ -131,6 +130,21 @@ var PDFHistory = {
state.target && state.target.hash) ? true : false;
},
_pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj,
replace) {
// In Firefox, 'urlParam' needs to be undefined in order to prevent issues
// when local files are opened.
var urlParam;
//#if (GENERIC || CHROME)
urlParam = document.URL;
//#endif
if (replace) {
window.history.replaceState(stateObj, '', urlParam);
} else {
window.history.pushState(stateObj, '', urlParam);
}
},
get isHashChangeUnlocked() {
if (!this.initialized) {
return true;
@ -291,11 +305,8 @@ var PDFHistory = {
this._pushToHistory(previousParams, false, replacePrevious);
}
}
if (overwrite || this.uid === 0) {
window.history.replaceState(this._stateObj(params), '', document.URL);
} else {
window.history.pushState(this._stateObj(params), '', document.URL);
}
this._pushOrReplaceState(this._stateObj(params),
(overwrite || this.uid === 0));
this.currentUid = this.uid++;
this.current = params;
this.updatePreviousBookmark = true;