diff --git a/browser/components/readinglist/SQLiteStore.jsm b/browser/components/readinglist/SQLiteStore.jsm index aefc8361b1b..8777aa9ee72 100644 --- a/browser/components/readinglist/SQLiteStore.jsm +++ b/browser/components/readinglist/SQLiteStore.jsm @@ -126,11 +126,16 @@ this.SQLiteStore.prototype = { /** * Call this when you're done with the store. Don't use it afterward. */ - destroy: Task.async(function* () { - let conn = yield this._connectionPromise; - yield conn.close(); - this._connectionPromise = Promise.reject("Store destroyed"); - }), + destroy() { + if (!this._destroyPromise) { + this._destroyPromise = Task.spawn(function* () { + let conn = yield this._connectionPromise; + yield conn.close(); + this._connectionPromise = Promise.reject("Store destroyed"); + }.bind(this)); + } + return this._destroyPromise; + }, /** * Creates the database connection if it hasn't been created already. diff --git a/browser/components/readinglist/test/xpcshell/test_ReadingList.js b/browser/components/readinglist/test/xpcshell/test_ReadingList.js index 092cee719e9..00bc3a04b5a 100644 --- a/browser/components/readinglist/test/xpcshell/test_ReadingList.js +++ b/browser/components/readinglist/test/xpcshell/test_ReadingList.js @@ -21,7 +21,9 @@ add_task(function* prepare() { gList = ReadingList; Assert.ok(gList); gDBFile.append(gList._store.pathRelativeToProfileDir); - do_register_cleanup(() => { + do_register_cleanup(function* () { + // Wait for the list's store to close its connection to the database. + yield gList.destroy(); if (gDBFile.exists()) { gDBFile.remove(true); } diff --git a/browser/components/readinglist/test/xpcshell/test_SQLiteStore.js b/browser/components/readinglist/test/xpcshell/test_SQLiteStore.js index 998eba6428d..0a39085f9d2 100644 --- a/browser/components/readinglist/test/xpcshell/test_SQLiteStore.js +++ b/browser/components/readinglist/test/xpcshell/test_SQLiteStore.js @@ -23,7 +23,11 @@ add_task(function* prepare() { } } removeDB(); - do_register_cleanup(removeDB); + do_register_cleanup(function* () { + // Wait for the store to close its connection to the database. + yield gStore.destroy(); + removeDB(); + }); gStore = new SQLiteStore(dbFile.path); diff --git a/browser/components/readinglist/test/xpcshell/xpcshell.ini b/browser/components/readinglist/test/xpcshell/xpcshell.ini index c172cf0acf0..f89f63d8999 100644 --- a/browser/components/readinglist/test/xpcshell/xpcshell.ini +++ b/browser/components/readinglist/test/xpcshell/xpcshell.ini @@ -2,6 +2,6 @@ head = head.js firefox-appdir = browser -;[test_ReadingList.js] +[test_ReadingList.js] [test_scheduler.js] -;[test_SQLiteStore.js] +[test_SQLiteStore.js]