diff --git a/browser/components/places/tests/unit/head_bookmarks.js b/browser/components/places/tests/unit/head_bookmarks.js index 7113c1eaa26..8eafc649848 100644 --- a/browser/components/places/tests/unit/head_bookmarks.js +++ b/browser/components/places/tests/unit/head_bookmarks.js @@ -329,3 +329,15 @@ function flush_main_thread_events() while (tm.mainThread.hasPendingEvents()) tm.mainThread.processNextEvent(false); } + +// These tests are known to randomly fail due to bug 507790 when database +// flushes are active, so we turn off syncing for them. +let randomFailingSyncTests = [ + "test_browserGlue_smartBookmarks.js", +]; +let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName; +if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) { + print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component."); + let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver); + sync.observe(null, "places-debug-stop-sync", null); +} diff --git a/toolkit/components/places/src/nsPlacesDBFlush.js b/toolkit/components/places/src/nsPlacesDBFlush.js index ee1afd99208..fdb74c16a27 100644 --- a/toolkit/components/places/src/nsPlacesDBFlush.js +++ b/toolkit/components/places/src/nsPlacesDBFlush.js @@ -50,6 +50,8 @@ const Cu = Components.utils; const kQuitApplication = "quit-application"; const kSyncFinished = "places-sync-finished"; +const kDebugStopSync = "places-debug-stop-sync"; +const kDebugStartSync = "places-debug-start-sync"; const kSyncPrefName = "places.syncDBTableIntervalInSecs"; const kDefaultSyncInterval = 120; @@ -108,6 +110,8 @@ function nsPlacesDBFlush() this._os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); this._os.addObserver(this, kQuitApplication, false); + this._os.addObserver(this, kDebugStopSync, false); + this._os.addObserver(this, kDebugStartSync, false); let (pb2 = this._prefs.QueryInterface(Ci.nsIPrefBranch2)) { pb2.addObserver(kSyncPrefName, this, false); @@ -147,6 +151,9 @@ nsPlacesDBFlush.prototype = { { if (aTopic == kQuitApplication) { this._os.removeObserver(this, kQuitApplication); + this._os.removeObserver(this, kDebugStopSync); + this._os.removeObserver(this, kDebugStartSync); + let (pb2 = this._prefs.QueryInterface(Ci.nsIPrefBranch2)) { pb2.removeObserver(kSyncPrefName, this); pb2.removeObserver(kExpireDaysPrefName, this); @@ -195,6 +202,13 @@ nsPlacesDBFlush.prototype = { if (this._expireDays <= 0) this._expireDays = kDefaultExpireDays; } + else if (aTopic == kDebugStopSync) { + this._syncStopped = true; + } + else if (aTopic == kDebugStartSync) { + if (_syncStopped in this) + delete this._syncStopped; + } }, ////////////////////////////////////////////////////////////////////////////// @@ -338,7 +352,7 @@ nsPlacesDBFlush.prototype = { _flushWithQueries: function DBFlush_flushWithQueries(aQueryNames) { // No need to do extra work if we are in batch mode - if (this._inBatchMode) + if (this._inBatchMode || this._syncStopped) return; let statements = []; diff --git a/toolkit/components/places/tests/bookmarks/head_bookmarks.js b/toolkit/components/places/tests/bookmarks/head_bookmarks.js index 5c7bc422cb9..f530e16d65f 100644 --- a/toolkit/components/places/tests/bookmarks/head_bookmarks.js +++ b/toolkit/components/places/tests/bookmarks/head_bookmarks.js @@ -164,3 +164,19 @@ function flush_main_thread_events() while (tm.mainThread.hasPendingEvents()) tm.mainThread.processNextEvent(false); } + +// These tests are known to randomly fail due to bug 507790 when database +// flushes are active, so we turn off syncing for them. +let randomFailingSyncTests = [ + "test_384228.js", + "test_395593.js", + "test_405938_restore_queries.js", + "test_423515_forceCopyShortcuts.js", + "test_448584.js", +]; +let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName; +if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) { + print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component."); + let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver); + sync.observe(null, "places-debug-stop-sync", null); +} diff --git a/toolkit/components/places/tests/queries/head_queries.js b/toolkit/components/places/tests/queries/head_queries.js index e0e5845a93d..f74420617a7 100644 --- a/toolkit/components/places/tests/queries/head_queries.js +++ b/toolkit/components/places/tests/queries/head_queries.js @@ -562,3 +562,15 @@ function flush_main_thread_events() while (tm.mainThread.hasPendingEvents()) tm.mainThread.processNextEvent(false); } + +// These tests are known to randomly fail due to bug 507790 when database +// flushes are active, so we turn off syncing for them. +let randomFailingSyncTests = [ + " test_results-as-visits.js", +]; +let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName; +if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) { + print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component."); + let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver); + sync.observe(null, "places-debug-stop-sync", null); +} diff --git a/toolkit/components/places/tests/queries/test_results-as-visit.js b/toolkit/components/places/tests/queries/test_results-as-visit.js index 11aac6e055f..f9bd435f6b4 100644 --- a/toolkit/components/places/tests/queries/test_results-as-visit.js +++ b/toolkit/components/places/tests/queries/test_results-as-visit.js @@ -64,9 +64,6 @@ function createTestData() { * This test will test Queries that use relative search terms and URI options */ function run_test() { - /* Temporarly disabled till we figure out what's up. See Bug 511860 */ - return; - createTestData(); populateDB(testData); var query = histsvc.getNewQuery(); diff --git a/toolkit/components/places/tests/unit/head_bookmarks.js b/toolkit/components/places/tests/unit/head_bookmarks.js index 80be47862e8..3c1f47677b8 100644 --- a/toolkit/components/places/tests/unit/head_bookmarks.js +++ b/toolkit/components/places/tests/unit/head_bookmarks.js @@ -206,3 +206,19 @@ function flush_main_thread_events() while (tm.mainThread.hasPendingEvents()) tm.mainThread.processNextEvent(false); } + +// These tests are known to randomly fail due to bug 507790 when database +// flushes are active, so we turn off syncing for them. +let randomFailingSyncTests = [ + "test_annotations.js", + "test_multi_word_tags.js", + "test_removeVisitsByTimeframe.js", + "test_tagging.js", + "test_utils_getURLsForContainerNode.js", +]; +let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName; +if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) { + print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component."); + let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver); + sync.observe(null, "places-debug-stop-sync", null); +}