Merge pull request #10424 from Snuffleupagus/issue-6847

Accept non-matching document fingerprints, in `PDFHistory`, when the viewer is reloaded (issue 6847)
This commit is contained in:
Tim van der Meij 2019-01-06 19:08:03 +01:00 committed by GitHub
commit af31b980b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,7 @@ class PDFHistory {
this._destination = null;
this._position = null;
if (!this._isValidState(state) || resetHistory) {
if (!this._isValidState(state, /* checkReload = */ true) || resetHistory) {
let { hash, page, rotation, } = parseCurrentHash(this.linkService);
if (!hash || reInitialized || resetHistory) {
@ -359,14 +359,27 @@ class PDFHistory {
/**
* @private
*/
_isValidState(state) {
_isValidState(state, checkReload = false) {
if (!state) {
return false;
}
if (state.fingerprint !== this.fingerprint) {
// This should only occur in viewers with support for opening more than
// one PDF document, e.g. the GENERIC viewer.
return false;
if (checkReload) {
// Potentially accept the history entry, even if the fingerprints don't
// match, when the viewer was reloaded (see issue 6847).
if (typeof state.fingerprint !== 'string' ||
state.fingerprint.length !== this.fingerprint.length) {
return false;
}
const [perfEntry] = performance.getEntriesByType('navigation');
if (!perfEntry || perfEntry.type !== 'reload') {
return false;
}
} else {
// This should only occur in viewers with support for opening more than
// one PDF document, e.g. the GENERIC viewer.
return false;
}
}
if (!Number.isInteger(state.uid) || state.uid < 0) {
return false;