Skip to content

Commit

Permalink
Fix recognizer dialog with multiple tests
Browse files Browse the repository at this point in the history
Do cleanup on 'unload' rather than 'close' (which is limited to a click
on the close button and doesn't get called for win.close()) and clear
the queue after each test.
  • Loading branch information
dstillman committed Mar 1, 2018
1 parent 757709c commit f99038f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions chrome/content/zotero/recognizePDFDialog.js
Expand Up @@ -51,14 +51,7 @@ var Zotero_RecognizePDF_Dialog = new function () {
};

function close() {
if (!_progressWindow) return;
Zotero.RecognizePDF.removeListener('rowadded');
Zotero.RecognizePDF.removeListener('rowupdated');
Zotero.RecognizePDF.removeListener('rowdeleted');
_progressWindow.close();
_progressWindow = null;
_progressIndicator = null;
_rowIDs = [];
}

function _getImageByStatus(status) {
Expand Down Expand Up @@ -143,7 +136,15 @@ var Zotero_RecognizePDF_Dialog = new function () {
close();
}
});
_progressWindow.addEventListener('close', close.bind(this), false);

_progressWindow.addEventListener('unload', function () {
Zotero.RecognizePDF.removeListener('rowadded');
Zotero.RecognizePDF.removeListener('rowupdated');
Zotero.RecognizePDF.removeListener('rowdeleted');
_progressWindow = null;
_progressIndicator = null;
_rowIDs = [];
});

_updateProgress();

Expand Down
1 change: 1 addition & 0 deletions test/tests/recognizePDFTest.js
Expand Up @@ -19,6 +19,7 @@ describe("PDF Recognition", function() {
for(let win of getWindows("chrome://zotero/content/recognizePDFDialog.xul")) {
win.close();
}
Zotero.RecognizePDF.cancel();
});

after(function() {
Expand Down

0 comments on commit f99038f

Please sign in to comment.