Bug 1440073 - Clear images from cache to fix --verify testing of browser_no_mcb_for_loopback.js r?johannh draft
authorJonathan Kingston <jkt@mozilla.com>
Thu, 22 Feb 2018 14:07:44 +0000
changeset 759452 b449754574b52f84f6fe3793d4ad465860636d41
parent 758472 2b1e9910c6038b71c8dec54180f0aaafcb7d7a69
push id100353
push userbmo:jkt@mozilla.com
push dateSat, 24 Feb 2018 12:03:53 +0000
reviewersjohannh
bugs1440073
milestone60.0a1
Bug 1440073 - Clear images from cache to fix --verify testing of browser_no_mcb_for_loopback.js r?johannh MozReview-Commit-ID: 4z8aJizVUNm
browser/base/content/test/siteIdentity/browser_no_mcb_for_loopback.js
--- a/browser/base/content/test/siteIdentity/browser_no_mcb_for_loopback.js
+++ b/browser/base/content/test/siteIdentity/browser_no_mcb_for_loopback.js
@@ -19,17 +19,26 @@ if (!gMultiProcessBrowser) {
 const TEST_URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://example.com") + "test_no_mcb_for_loopback.html";
 
 const LOOPBACK_PNG_URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://127.0.0.1:8888") + "moz.png";
 
 const PREF_BLOCK_DISPLAY = "security.mixed_content.block_display_content";
 const PREF_UPGRADE_DISPLAY = "security.mixed_content.upgrade_display_content";
 const PREF_BLOCK_ACTIVE = "security.mixed_content.block_active_content";
 
+function clearAllImageCaches() {
+  let tools = Cc["@mozilla.org/image/tools;1"]
+                .getService(Ci.imgITools);
+  let imageCache = tools.getImgCacheForDocument(window.document);
+  imageCache.clearCache(true); // true=chrome
+  imageCache.clearCache(false); // false=content
+}
+
 registerCleanupFunction(function() {
+  clearAllImageCaches();
   Services.prefs.clearUserPref(PREF_BLOCK_DISPLAY);
   Services.prefs.clearUserPref(PREF_UPGRADE_DISPLAY);
   Services.prefs.clearUserPref(PREF_BLOCK_ACTIVE);
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function allowLoopbackMixedContent() {
   Services.prefs.setBoolPref(PREF_BLOCK_DISPLAY, true);