From 57ebfd6dff5efe3bdb1a488a07e5efb4aaeb4ea4 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Wed, 11 Mar 2015 12:51:00 -0400 Subject: [PATCH] Bug 1140389 - Fix test_SQLiteStore.js and test_ReadingList.js failures on Windows due to NS_ERROR_FILE_IS_LOCKED. r=Unfocused --- browser/components/readinglist/SQLiteStore.jsm | 15 ++++++++++----- .../readinglist/test/xpcshell/test_ReadingList.js | 4 +++- .../readinglist/test/xpcshell/test_SQLiteStore.js | 6 +++++- .../readinglist/test/xpcshell/xpcshell.ini | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) 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]