mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 06:38:07 +02:00
Stop sending the unused options
parameter to various download-methods in the viewer
The `options` handling, for the download-methods, was originally added in PR 16391 and became obsolete in PR 17771. This fixes failures, in mozilla-central tests, which appeared after landing PR 18527.
This commit is contained in:
parent
a372bf8f4d
commit
ecbd660609
4 changed files with 11 additions and 23 deletions
26
web/app.js
26
web/app.js
|
@ -1109,22 +1109,17 @@ const PDFViewerApplication = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
async download(options = {}) {
|
async download() {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = await this.pdfDocument.getData();
|
data = await this.pdfDocument.getData();
|
||||||
} catch {
|
} catch {
|
||||||
// When the PDF document isn't ready, simply download using the URL.
|
// When the PDF document isn't ready, simply download using the URL.
|
||||||
}
|
}
|
||||||
this.downloadManager.download(
|
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
|
||||||
data,
|
|
||||||
this._downloadUrl,
|
|
||||||
this._docFilename,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async save(options = {}) {
|
async save() {
|
||||||
if (this._saveInProgress) {
|
if (this._saveInProgress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1133,16 +1128,11 @@ const PDFViewerApplication = {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await this.pdfDocument.saveDocument();
|
const data = await this.pdfDocument.saveDocument();
|
||||||
this.downloadManager.download(
|
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
|
||||||
data,
|
|
||||||
this._downloadUrl,
|
|
||||||
this._docFilename,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
// When the PDF document isn't ready, fallback to a "regular" download.
|
// When the PDF document isn't ready, fallback to a "regular" download.
|
||||||
console.error(`Error when saving the document: ${reason.message}`);
|
console.error(`Error when saving the document: ${reason.message}`);
|
||||||
await this.download(options);
|
await this.download();
|
||||||
} finally {
|
} finally {
|
||||||
await this.pdfScriptingManager.dispatchDidSave();
|
await this.pdfScriptingManager.dispatchDidSave();
|
||||||
this._saveInProgress = false;
|
this._saveInProgress = false;
|
||||||
|
@ -1159,7 +1149,7 @@ const PDFViewerApplication = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async downloadOrSave(options = {}) {
|
async downloadOrSave() {
|
||||||
// In the Firefox case, this method MUST always trigger a download.
|
// In the Firefox case, this method MUST always trigger a download.
|
||||||
// When the user is closing a modified and unsaved document, we display a
|
// When the user is closing a modified and unsaved document, we display a
|
||||||
// prompt asking for saving or not. In case they save, we must wait for
|
// prompt asking for saving or not. In case they save, we must wait for
|
||||||
|
@ -1169,8 +1159,8 @@ const PDFViewerApplication = {
|
||||||
const { classList } = this.appConfig.appContainer;
|
const { classList } = this.appConfig.appContainer;
|
||||||
classList.add("wait");
|
classList.add("wait");
|
||||||
await (this.pdfDocument?.annotationStorage.size > 0
|
await (this.pdfDocument?.annotationStorage.size > 0
|
||||||
? this.save(options)
|
? this.save()
|
||||||
: this.download(options));
|
: this.download());
|
||||||
classList.remove("wait");
|
classList.remove("wait");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ class DownloadManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
download(data, url, filename, _options) {
|
download(data, url, filename) {
|
||||||
let blobUrl;
|
let blobUrl;
|
||||||
if (data) {
|
if (data) {
|
||||||
blobUrl = URL.createObjectURL(
|
blobUrl = URL.createObjectURL(
|
||||||
|
|
|
@ -133,7 +133,7 @@ class DownloadManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
download(data, url, filename, options = {}) {
|
download(data, url, filename) {
|
||||||
const blobUrl = data
|
const blobUrl = data
|
||||||
? URL.createObjectURL(new Blob([data], { type: "application/pdf" }))
|
? URL.createObjectURL(new Blob([data], { type: "application/pdf" }))
|
||||||
: null;
|
: null;
|
||||||
|
@ -142,7 +142,6 @@ class DownloadManager {
|
||||||
blobUrl,
|
blobUrl,
|
||||||
originalUrl: url,
|
originalUrl: url,
|
||||||
filename,
|
filename,
|
||||||
options,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,9 +156,8 @@ class IDownloadManager {
|
||||||
* @param {Uint8Array} data
|
* @param {Uint8Array} data
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {string} filename
|
* @param {string} filename
|
||||||
* @param {Object} [options]
|
|
||||||
*/
|
*/
|
||||||
download(data, url, filename, options) {}
|
download(data, url, filename) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue