From d128a937cb829a5523f1d8cad4a218a256028a54 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 17 Jun 2011 17:05:46 +0200 Subject: [PATCH] Bug 664986 - Fix random timeouts in livemarks tests. r=dietrich --- toolkit/components/places/nsLivemarkService.js | 14 ++++++++------ toolkit/components/places/tests/chrome/Makefile.in | 3 +-- .../components/places/tests/chrome/test_303567.xul | 3 ++- .../components/places/tests/chrome/test_329534.xul | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/toolkit/components/places/nsLivemarkService.js b/toolkit/components/places/nsLivemarkService.js index ea7e0afadd59..57377a2c9c1d 100644 --- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -203,13 +203,16 @@ LivemarkService.prototype = { // We try to distribute the load of the livemark update. // load gLimitCount Livemarks per gDelayTime sec. _updatedLivemarks: [], - _checkAllLivemarks: function LS__checkAllLivemarks() { + _forceUpdate: false, + _checkAllLivemarks: function LS__checkAllLivemarks(aForceUpdate) { + if (aForceUpdate && !this._forceUpdate) + this._forceUpdate = true; let updateCount = 0; for each (let livemark in this._livemarks) { if (this._updatedLivemarks.indexOf(livemark.folderId) == -1) { this._updatedLivemarks.push(livemark.folderId); // Check if livemarks are expired, update if needed. - if (livemark.updateChildren()) { + if (livemark.updateChildren(this._forceUpdate)) { if (++updateCount == gLimitCount) { break; } @@ -221,6 +224,7 @@ LivemarkService.prototype = { if (this._updatedLivemarks.length >= Object.keys(this._livemarks).length) { // All livemarks are up-to-date, sleep until next period. this._updatedLivemarks.length = 0; + this._forceUpdate = false; refresh_time = Math.min(Math.floor(gExpiration / 4), MAX_REFRESH_TIME); } this._newTimer(refresh_time); @@ -326,9 +330,7 @@ LivemarkService.prototype = { }, reloadAllLivemarks: function LS_reloadAllLivemarks() { - for each (let livemark in this._livemarks) { - livemark.updateChildren(true); - } + this._checkAllLivemarks(true); }, reloadLivemarkFolder: function LS_reloadLivemarkFolder(aFolderId) { @@ -603,7 +605,7 @@ Livemark.prototype = { // If we can't get the idle time, assume the user is not idle. try { let idleTime = idle.idleTime; - if (idleTime > IDLE_TIMELIMIT) { + if (idleTime > IDLE_TIMELIMIT && !aForceUpdate) { this.locked = false; return false; } diff --git a/toolkit/components/places/tests/chrome/Makefile.in b/toolkit/components/places/tests/chrome/Makefile.in index ab2d95648a51..66fea3547be1 100644 --- a/toolkit/components/places/tests/chrome/Makefile.in +++ b/toolkit/components/places/tests/chrome/Makefile.in @@ -60,10 +60,9 @@ _CHROME_FILES = \ test_341972a.xul \ test_favicon_annotations.xul \ test_303567.xul \ + test_381357.xul \ $(NULL) -# test_381357.xul is disabled for now because of bug 561007. See also bug 624549. - libs:: $(_HTTP_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/toolkit/components/places/tests/chrome/test_303567.xul b/toolkit/components/places/tests/chrome/test_303567.xul index b07bc70858ff..985bf14ceb64 100644 --- a/toolkit/components/places/tests/chrome/test_303567.xul +++ b/toolkit/components/places/tests/chrome/test_303567.xul @@ -82,10 +82,11 @@ function runTest() observer.expectedFeedURI = livemark.feedURI; observer.expectedChildren = livemark.urls.length; - livemark.id = PlacesUtils.livemarks.createLivemark( + livemark.id = PlacesUtils.livemarks.createLivemarkFolderOnly( PlacesUtils.toolbarFolderId, "foo", livemark.siteURI, livemark.feedURI, PlacesUtils.bookmarks.DEFAULT_INDEX ); + PlacesUtils.livemarks.reloadLivemarkFolder(livemark.id); yield; diff --git a/toolkit/components/places/tests/chrome/test_329534.xul b/toolkit/components/places/tests/chrome/test_329534.xul index 0982cdb3ab92..f93210f6118d 100644 --- a/toolkit/components/places/tests/chrome/test_329534.xul +++ b/toolkit/components/places/tests/chrome/test_329534.xul @@ -92,7 +92,7 @@ bmsvc.addObserver(observer, false); // start updating livemarks firstLoadTime = Date.now(); -lmsvc.start(); +lmsvc.reloadAllLivemarks(); // First function runTest1( folderId ) {