Bug 863319 - Improve assertions in browser_image mochitest. r=joe

--HG--
extra : rebase_source : bf323152a21613bf20d1ff2456520346bf1460b1
This commit is contained in:
Seth Fowler 2013-04-19 13:47:36 -07:00
parent fec6f36234
commit eaf7d57113

View File

@ -58,7 +58,8 @@ function testBFCache() {
gTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); gTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
gTimer.initWithCallback(function() { gTimer.initWithCallback(function() {
// Might have a few stray frames, until other page totally loads // Might have a few stray frames, until other page totally loads
is(gImage.framesNotified == gFrames, true, "Must have not animated in bfcache!"); var additionalFrames = gImage.framesNotified - gFrames;
is(additionalFrames == 0, true, "Must have not animated in bfcache! Got " + additionalFrames + " additional frames");
goer.next(); goer.next();
}, 4000, Ci.nsITimer.TYPE_ONE_SHOT); // 4 seconds - expect 40 frames }, 4000, Ci.nsITimer.TYPE_ONE_SHOT); // 4 seconds - expect 40 frames
}, 0, Ci.nsITimer.TYPE_ONE_SHOT); // delay of 0 - wait for next event loop }, 0, Ci.nsITimer.TYPE_ONE_SHOT); // delay of 0 - wait for next event loop
@ -91,7 +92,8 @@ function testBFCache() {
div.innerHTML += '<img src="animated2.gif" id="img3">'; div.innerHTML += '<img src="animated2.gif" id="img3">';
actOnMozImage(doc, "img3", function(image) { actOnMozImage(doc, "img3", function(image) {
is(Math.abs(image.framesNotified - gImage.framesNotified)/gImage.framesNotified < 0.5, true, is(Math.abs(image.framesNotified - gImage.framesNotified)/gImage.framesNotified < 0.5, true,
"Must have also animated the background image, and essentially the same # of frames"); "Must have also animated the background image, and essentially the same # of frames. " +
"Regular image got " + gImage.framesNotified + " frames but background image got " + image.framesNotified);
}); });
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();