From ca8e3ea06f368a66596dafdaf1dda510c4e64651 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 22 Nov 2013 11:49:16 +0100 Subject: [PATCH] [PDFHistory] Fix "Warning: Unhandled rejection: [Exception... "The operation is insecure."" when opening local file --- web/pdf_history.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/web/pdf_history.js b/web/pdf_history.js index c85954ede..86874f786 100644 --- a/web/pdf_history.js +++ b/web/pdf_history.js @@ -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;