From 3e82b6a5bbc82a0b01df637f134fab75a59eb282 Mon Sep 17 00:00:00 2001 From: Doug Thayer Date: Tue, 7 Nov 2017 15:48:02 -0800 Subject: [PATCH] Bug 1413989 - include Timer.jsm in MigrationUtils.jsm r=MattN setTimeout was previously undefined. Created a test specifically for MigrationUtils, since trying to test this through an actual Chrome migration path seemed trickier and more fragile. MozReview-Commit-ID: 33U7ZzzG1CC --HG-- extra : rebase_source : 0399d9bc768d8eb7451fbb75ec3282f903cdb4ad --- .../components/migration/MigrationUtils.jsm | 2 ++ .../unit/test_MigrationUtils_timedRetry.js | 26 +++++++++++++++++++ .../migration/tests/unit/xpcshell.ini | 1 + 3 files changed, 29 insertions(+) create mode 100644 browser/components/migration/tests/unit/test_MigrationUtils_timedRetry.js diff --git a/browser/components/migration/MigrationUtils.jsm b/browser/components/migration/MigrationUtils.jsm index a48a2549ef01..4bb31f51558f 100644 --- a/browser/components/migration/MigrationUtils.jsm +++ b/browser/components/migration/MigrationUtils.jsm @@ -35,6 +35,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch", "resource://gre/modules/TelemetryStopwatch.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry", "resource://gre/modules/WindowsRegistry.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "setTimeout", + "resource://gre/modules/Timer.jsm"); var gMigrators = null; var gProfileStartup = null; diff --git a/browser/components/migration/tests/unit/test_MigrationUtils_timedRetry.js b/browser/components/migration/tests/unit/test_MigrationUtils_timedRetry.js new file mode 100644 index 000000000000..d55528d02597 --- /dev/null +++ b/browser/components/migration/tests/unit/test_MigrationUtils_timedRetry.js @@ -0,0 +1,26 @@ +"use strict"; + +XPCOMUtils.defineLazyModuleGetter(this, "OS", + "resource://gre/modules/osfile.jsm"); + +let tmpFile = FileUtils.getDir("TmpD", [], true); +let dbConn; + +add_task(async function setup() { + tmpFile.append("TestDB"); + dbConn = await Sqlite.openConnection({ path: tmpFile.path }); + + do_register_cleanup(() => { + dbConn.close(); + OS.File.remove(tmpFile.path); + }); +}); + +add_task(async function testgetRowsFromDBWithoutLocksRetries() { + let promise = MigrationUtils.getRowsFromDBWithoutLocks(tmpFile.path, + "Temp DB", + "SELECT * FROM moz_temp_table") + await new Promise(resolve => do_timeout(50, resolve)); + dbConn.execute("CREATE TABLE moz_temp_table (id INTEGER PRIMARY KEY)"); + await promise; +}); diff --git a/browser/components/migration/tests/unit/xpcshell.ini b/browser/components/migration/tests/unit/xpcshell.ini index 67ee7c1db5d3..4fc70386220b 100644 --- a/browser/components/migration/tests/unit/xpcshell.ini +++ b/browser/components/migration/tests/unit/xpcshell.ini @@ -23,5 +23,6 @@ skip-if = !(os == "win" && bits == 64) # bug 1392396 skip-if = os != "win" [test_IE7_passwords.js] skip-if = os != "win" +[test_MigrationUtils_timedRetry.js] [test_Safari_bookmarks.js] skip-if = os != "mac"