commit 1b8704f1334002ff4d1fb27cfd88d26d082c347c
parent a3eea03a38da31783342da8a1fea3fed70c796b4
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 22 May 2017 06:04:27 -0400
Firefox 54 compatibility: File.createFromFileName() returns a promise
Diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js
@@ -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);
diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js
@@ -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]);
diff --git a/test/tests/zfsTest.js b/test/tests/zfsTest.js
@@ -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)