diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 00d34568b..2ce1a52a7 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1032,6 +1032,8 @@ Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(fun this._session = this._createNewSession(data); try { yield this._session.setData(data); + // this._createNewSession() updates sessionID, which we need to store back into the doc + this._doc.setDocumentData(me._session.data.serialize()) } catch(e) { // make sure style is defined if(e instanceof Zotero.Exception.Alert && e.name === "integration.error.invalidStyle") { diff --git a/test/tests/integrationTest.js b/test/tests/integrationTest.js index 46bfea44e..80e315b16 100644 --- a/test/tests/integrationTest.js +++ b/test/tests/integrationTest.js @@ -352,10 +352,10 @@ describe("Zotero.Integration", function () { assert.isFalse(setDocumentDataSpy.called); }); - it('should not call doc.setDocumentData when document communicates for first time since restart, but has data', function* () { + it('should call doc.setDocumentData when document communicates for first time since restart to write new sessionID', function* () { Zotero.Integration.sessions = {}; yield execCommand('addEditCitation', docID); - assert.isFalse(setDocumentDataSpy.called); + assert.isTrue(setDocumentDataSpy.calledOnce); }); describe('when style used in the document does not exist', function() {