Bug 664986 - Fix random timeouts in livemarks tests.

r=dietrich
This commit is contained in:
Marco Bonardo 2011-06-17 17:05:46 +02:00
parent bd19015b52
commit d128a937cb
4 changed files with 12 additions and 10 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -92,7 +92,7 @@ bmsvc.addObserver(observer, false);
// start updating livemarks
firstLoadTime = Date.now();
lmsvc.start();
lmsvc.reloadAllLivemarks();
// First
function runTest1( folderId ) {