diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index 217dca83325f..37ca77ff7b5a 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -70,6 +70,7 @@ #include "nsDocShell.h" #include "nsIException.h" #include "VsyncSource.h" +#include "imgLoader.h" #ifdef XP_UNIX # include @@ -1611,6 +1612,15 @@ void ChromeUtils::ClearScriptCache(GlobalObject&, : Nothing()); } +void ChromeUtils::ClearResourceCache(GlobalObject&, + const Optional& aChrome) { + Maybe chrome = aChrome.WasPassed() ? Some(aChrome.Value()) : Nothing(); + SharedStyleSheetCache::Clear(chrome); + SharedScriptCache::Clear(chrome); + imgLoader::PrivateBrowsingLoader()->ClearCache(chrome); + imgLoader::NormalLoader()->ClearCache(chrome); +} + #define PROCTYPE_TO_WEBIDL_CASE(_procType, _webidl) \ case mozilla::ProcType::_procType: \ return WebIDLProcType::_webidl diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index 08de82abc14b..29fbcfabfb8a 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -216,6 +216,9 @@ class ChromeUtils { static void ClearScriptCache(GlobalObject& aGlobal, const Optional& aChrome); + static void ClearResourceCache(GlobalObject& aGlobal, + const Optional& aChrome); + static void SetPerfStatsCollectionMask(GlobalObject& aGlobal, uint64_t aMask); static already_AddRefed CollectPerfStats(GlobalObject& aGlobal, diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index 8495459f9849..6eabcf6354b2 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -269,6 +269,15 @@ namespace ChromeUtils { */ undefined clearScriptCache(optional boolean chrome); + /** + * Clears the entire resource cache (stylesheets, JavaScripts, and images). + * + * If chrome parameter is passed and true, this clears chrome cache. + * If chrome parameter is passed and false, this clears content cache. + * If chrome parameter is not passed, this clears all cache. + */ + undefined clearResourceCache(optional boolean chrome); + /** * Clears the Messaging Layer Security state by schemeless site. * This includes associated state-partitioned cache.