Bug 1103439 - Add a function to clear both chrome and nonchrome image caches. r=tn
authorSeth Fowler <seth@mozilla.com>
Mon, 24 Nov 2014 23:42:44 -0800
changeset 217443 faa77ca026ea5330fda1f9b5b9a76410f63dcd95
parent 217442 5a5ae0ef5714d58b8f7b05e95d561a7ca39f2515
child 217444 bb51e79ff4fa929f851817d78d0c7ed310100a0f
push id27882
push userryanvm@gmail.com
push dateTue, 25 Nov 2014 21:56:56 +0000
treeherdermozilla-central@ced1402861b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1103439
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1103439 - Add a function to clear both chrome and nonchrome image caches. r=tn
image/test/mochitest/animationPolling.js
image/test/mochitest/imgutils.js
image/test/mochitest/test_animSVGImage.html
image/test/mochitest/test_animSVGImage2.html
image/test/mochitest/test_has_transparency.html
image/test/mochitest/test_removal_ondecode.html
image/test/mochitest/test_removal_onload.html
image/test/mochitest/test_synchronized_animation.html
--- a/image/test/mochitest/animationPolling.js
+++ b/image/test/mochitest/animationPolling.js
@@ -75,17 +75,17 @@ function failTest()
  *        chain tests together, so they are all finished exactly once.
  * @returns {AnimationTest}
  */
 function AnimationTest(pollFreq, timeout, referenceElementId, imageElementId,
                        debugElementId, cleanId, srcAttr, xulTest, closeFunc)
 {
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   this.wereFailures = false;
   this.pollFreq = pollFreq;
   this.timeout = timeout;
   this.imageElementId = imageElementId;
   this.referenceElementId = referenceElementId;
 
   if (!document.getElementById(referenceElementId)) {
--- a/image/test/mochitest/imgutils.js
+++ b/image/test/mochitest/imgutils.js
@@ -1,14 +1,24 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 // Helper file for shared image functionality
 // 
 // Note that this is use by tests elsewhere in the source tree. When in doubt,
 // check mxr before removing or changing functionality.
 
+// Helper function to clear both the content and chrome image caches
+function clearAllImageCaches()
+{
+  var tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
+                             .getService(SpecialPowers.Ci.imgITools);
+  var imageCache = tools.getImgCacheForDocument(window.document);
+  imageCache.clearCache(true);  // true=chrome
+  imageCache.clearCache(false); // false=content
+}
+
 // Helper function to clear the image cache of content images
 function clearImageCache()
 {
   var tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
                              .getService(SpecialPowers.Ci.imgITools);
   var imageCache = tools.getImgCacheForDocument(window.document);
   imageCache.clearCache(false); // true=chrome, false=content
 }
--- a/image/test/mochitest/test_animSVGImage.html
+++ b/image/test/mochitest/test_animSVGImage.html
@@ -85,17 +85,17 @@ function cleanUpAndFinish() {
   gIsTestFinished = true;
 }
 
 function main() {
   takeReferenceSnapshot();
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   setTimeout(myOnStopFrame, 1);
 
   // kick off image-loading! myOnStopFrame handles the rest.
   gImg.setAttribute("src", "lime-anim-100x100.svg");
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
--- a/image/test/mochitest/test_animSVGImage2.html
+++ b/image/test/mochitest/test_animSVGImage2.html
@@ -98,17 +98,17 @@ function main() {
   gMyDecoderObserver =
     Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
       .createScriptedObserver(observer);
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.addObserver(gMyDecoderObserver);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   // kick off image-loading! myOnStopFrame handles the rest.
   gImg.setAttribute("src", "lime-anim-100x100-2.svg");
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
--- a/image/test/mochitest/test_has_transparency.html
+++ b/image/test/mochitest/test_has_transparency.html
@@ -139,17 +139,17 @@ function main() {
   gMyDecoderObserver =
     Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
       .createScriptedObserver(observer);
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.addObserver(gMyDecoderObserver);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   // Load the first image.
   loadNext();
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
--- a/image/test/mochitest/test_removal_ondecode.html
+++ b/image/test/mochitest/test_removal_ondecode.html
@@ -104,17 +104,17 @@ function main() {
   gMyDecoderObserver =
     Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
       .createScriptedObserver(observer);
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.addObserver(gMyDecoderObserver);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   // kick off image-loading! myOnStopFrame handles the rest.
   gImg.setAttribute("src", gFiles.next());
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
--- a/image/test/mochitest/test_removal_onload.html
+++ b/image/test/mochitest/test_removal_onload.html
@@ -104,17 +104,17 @@ function main() {
   gMyDecoderObserver =
     Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
       .createScriptedObserver(observer);
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.addObserver(gMyDecoderObserver);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   // kick off image-loading! myOnStopFrame handles the rest.
   gImg.setAttribute("src", gFiles.next());
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
--- a/image/test/mochitest/test_synchronized_animation.html
+++ b/image/test/mochitest/test_synchronized_animation.html
@@ -101,17 +101,17 @@ function main() {
   // Create and customize decoder observer
   var obs = new ImageDecoderObserverStub();
   obs.frameUpdate = frameUpdate;
 
   gOuter = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools).createScriptedObserver(obs);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
-  clearImageCache();
+  clearAllImageCaches();
 
   // These are two copies of the same image; hence, they have the same frame rate.
   gImg1.src = "animated1.gif";
   gImg2.src = "animated2.gif";
 
   // Wait for each image to load.
   gImg1.addEventListener('load', waitForLoadAndTest(gImg1));
   gImg2.addEventListener('load', waitForLoadAndTest(gImg2));