diff --git a/chrome/content/zotero/collectionTree.jsx b/chrome/content/zotero/collectionTree.jsx index 7350cd6db8..bd35b1a6ea 100644 --- a/chrome/content/zotero/collectionTree.jsx +++ b/chrome/content/zotero/collectionTree.jsx @@ -1749,19 +1749,17 @@ var CollectionTree = class CollectionTree extends LibraryTree { } return true; } - else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') { + else if (dataType == 'application/x-moz-file') { if (treeRow.isSearch() || treeRow.isPublications()) { return false; } - if (dataType == 'application/x-moz-file') { - // Don't allow folder drag - if (data[0].isDirectory()) { - return false; - } - // Don't allow drop if no permissions - if (!treeRow.filesEditable) { - return false; - } + // Don't allow folder drag + if (data[0].isDirectory()) { + return false; + } + // Don't allow drop if no permissions + if (!treeRow.filesEditable) { + return false; } return true; @@ -2388,9 +2386,9 @@ var CollectionTree = class CollectionTree extends LibraryTree { }.bind(this)); } } - else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') { + else if (dataType == 'application/x-moz-file') { // See note in onDragOver() above - if (dataType == 'application/x-moz-file' && Zotero.isMac) { + if (Zotero.isMac) { if (event.metaKey) { if (event.altKey) { dropEffect = 'link'; @@ -2415,20 +2413,7 @@ var CollectionTree = class CollectionTree extends LibraryTree { for (var i=0; i 1; for (var i=0; i { // Don't run recognize on every file Zotero.Prefs.set('autoRecognizeFiles', false); @@ -1150,10 +1132,6 @@ describe("Zotero.ItemTree", function () { }); after(function* () { - var defer = Zotero.Promise.defer(); - httpd.stop(() => defer.resolve()); - yield defer.promise; - Zotero.Prefs.clear('autoRecognizeFiles'); Zotero.Prefs.clear('autoRenameFiles'); Zotero.Prefs.clear('autoRenameFiles.linked'); @@ -1256,10 +1234,13 @@ describe("Zotero.ItemTree", function () { ); }); - it("should create a stored top-level attachment when a URL is dragged", async function () { + it("should create a stored top-level attachment when a file URI is dragged", async function () { var promise = itemsView.waitForSelect(); + var pdfFile = getTestDataDirectory(); + pdfFile.append('test.pdf'); + var pdfURL = Services.io.newFileURI(pdfFile).spec; - drop(0, -1, { + await drop(0, -1, { dropEffect: 'copy', effectAllowed: 'copy', types: ['text/x-moz-url'], @@ -1269,25 +1250,28 @@ describe("Zotero.ItemTree", function () { } }, mozItemCount: 1, - }) + }); await promise; var item = itemsView.getSelectedItems()[0]; - assert.equal(item.getField('url'), pdfURL); + assert.equal(item.getField('url'), ''); assert.equal( - ((await Zotero.File.getBinaryContentsAsync(await item.getFilePathAsync()))), - ((await Zotero.File.getBinaryContentsAsync(pdfPath))) + (await Zotero.File.getBinaryContentsAsync(await item.getFilePathAsync())), + (await Zotero.File.getBinaryContentsAsync(pdfFile)) ); }); - it("should create a stored child attachment when a URL is dragged", async function () { + it("should create a stored child attachment when a file URI is dragged", async function () { var view = zp.itemsView; var parentItem = await createDataObject('item'); var parentRow = view.getRowIndexByID(parentItem.id); var promise = waitForItemEvent('add'); + var pdfFile = getTestDataDirectory(); + pdfFile.append('test.pdf'); + var pdfURL = Services.io.newFileURI(pdfFile).spec; - drop(parentRow, 0, { + await drop(parentRow, 0, { dropEffect: 'copy', effectAllowed: 'copy', types: ['text/x-moz-url'], @@ -1297,15 +1281,15 @@ describe("Zotero.ItemTree", function () { } }, mozItemCount: 1, - }) + }); var itemIDs = await promise; var item = Zotero.Items.get(itemIDs[0]); assert.equal(item.parentItemID, parentItem.id); - assert.equal(item.getField('url'), pdfURL); + assert.equal(item.getField('url'), ''); assert.equal( - ((await Zotero.File.getBinaryContentsAsync(await item.getFilePathAsync()))), - ((await Zotero.File.getBinaryContentsAsync(pdfPath))) + (await Zotero.File.getBinaryContentsAsync(await item.getFilePathAsync())), + (await Zotero.File.getBinaryContentsAsync(pdfFile)) ); }); @@ -1337,16 +1321,19 @@ describe("Zotero.ItemTree", function () { } ); + var file = getTestDataDirectory(); + file.append('test.pdf'); + drop(0, -1, { dropEffect: 'copy', effectAllowed: 'copy', - types: ['text/x-moz-url'], - getData: function (type) { - if (type == 'text/x-moz-url') { - return pdfURL; - } - }, + types: ['application/x-moz-file'], mozItemCount: 1, + mozGetDataAt: function (type, i) { + if (type == 'application/x-moz-file' && i == 0) { + return file; + } + } }) // Wait for attachment item @@ -1390,13 +1377,16 @@ describe("Zotero.ItemTree", function () { } ); + var file = getTestDataDirectory(); + file.append('test.pdf'); + drop(0, -1, { dropEffect: 'copy', effectAllowed: 'copy', - types: ['text/x-moz-url'], - getData: function (type) { - if (type == 'text/x-moz-url') { - return pdfURL; + types: ['application/x-moz-file'], + mozGetDataAt: function (type) { + if (type == 'application/x-moz-file') { + return file; } }, mozItemCount: 2,