Firefox 54 compatibility: File.createFromFileName() returns a promise
This commit is contained in:
parent
a3eea03a38
commit
1b8704f133
3 changed files with 14 additions and 3 deletions
|
@ -521,6 +521,10 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
|||
file.append(item.key + '.zip');
|
||||
Components.utils.importGlobalProperties(["File"]);
|
||||
file = File.createFromFileName ? File.createFromFileName(file.path) : new File(file);
|
||||
// File.createFromFileName() returns a Promise in Fx54+
|
||||
if (file.then) {
|
||||
file = yield file;
|
||||
}
|
||||
|
||||
var uri = this._getItemURI(item);
|
||||
|
||||
|
|
|
@ -613,6 +613,10 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = {
|
|||
|
||||
Components.utils.importGlobalProperties(["File"]);
|
||||
file = File.createFromFileName ? File.createFromFileName(file.path) : new File(file);
|
||||
// File.createFromFileName() returns a Promise in Fx54+
|
||||
if (file.then) {
|
||||
file = yield file;
|
||||
}
|
||||
|
||||
var blob = new Blob([params.prefix, file, params.suffix]);
|
||||
|
||||
|
|
|
@ -275,6 +275,11 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
|
|||
var suffix1 = Zotero.Utilities.randomString();
|
||||
var uploadKey1 = Zotero.Utilities.randomString(32, 'abcdef0123456789');
|
||||
|
||||
let file1Blob = File.createFromFileName ? File.createFromFileName(file1.path) : new File(file1);
|
||||
if (file1Blob.then) {
|
||||
file1Blob = yield file1Blob;
|
||||
}
|
||||
|
||||
// HTML file with auxiliary image
|
||||
var file2 = OS.Path.join(getTestDataDirectory().path, 'snapshot', 'index.html');
|
||||
var parentItem = yield createDataObject('item');
|
||||
|
@ -397,9 +402,7 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
|
|||
(new Blob(
|
||||
[
|
||||
prefix1,
|
||||
File.createFromFileName
|
||||
? File.createFromFileName(file1.path)
|
||||
: new File(file1),
|
||||
file1Blob,
|
||||
suffix1
|
||||
]
|
||||
).size)
|
||||
|
|
Loading…
Reference in a new issue