From 27713f9454e3fe138f8d0a6e49e32dcbe21ffa7c Mon Sep 17 00:00:00 2001
From: Jonas Jenwald <jonas.jenwald@gmail.com>
Date: Thu, 4 Jun 2015 13:58:45 +0200
Subject: [PATCH] Ensure that PDFHistory does not incorrectly replace the
 initial document hash (issue 6079)

This is fallout from PR 5971; fixes 6079.
---
 web/viewer.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/web/viewer.js b/web/viewer.js
index ae8a334ed..a3db3b471 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -799,8 +799,12 @@ var PDFViewerApplication = {
           window.history.replaceState(null, '');
         }
         self.pdfHistory.initialize(self.documentFingerprint);
-        self.initialDestination = self.pdfHistory.initialDestination;
-        self.initialBookmark = self.pdfHistory.initialBookmark;
+
+        if (self.pdfHistory.initialDestination) {
+          self.initialDestination = self.pdfHistory.initialDestination;
+        } else if (self.pdfHistory.initialBookmark) {
+          self.initialBookmark = self.pdfHistory.initialBookmark;
+        }
       }
 
       store.initializedPromise.then(function resolved() {