+++ /dev/null
-# CachingFix
-
-This WebExtension Experiment helps with cache-related cleanup tasks when
-disabling, uninstalling or updating the add-on.
-
-## Usage
-
-Copy the experiment into your add-on and add it to your manifest.json:
-```
-{
- "experiment_apis": {
- "ex_cachingfix": {
- "schema": "experiments/cachingfix/api.json",
- "parent": {
- "scopes": ["addon_parent"],
- "paths": [["ex_cachingfix"]],
- "script": "experiments/cachingfix/parent.js",
- "events": ["startup"]
- }
- }
- }
-}
-```
-
-After adding the experiment, you no longer need to unload JSMs loaded from
-the WebExtension's rootURI (file://- or jar://-URLs) or invalidate the
-startup cache by hand. You do not need to invoke the API in any way, the
-experiment is activated automatically.
+++ /dev/null
-[
- {
- "namespace": "ex_cachingfix",
- "description": "This experiment automatically unloads all other experiment's JSMs and clears caches to enable correct update behavior. It does not need to get called in any way, just including it is sufficient."
- }
-]
+++ /dev/null
-{
- "experiment_apis": {
- "ex_cachingfix": {
- "schema": "experiments/cachingfix/api.json",
- "parent": {
- "scopes": ["addon_parent"],
- "paths": [["ex_cachingfix"]],
- "script": "experiments/cachingfix/parent.js",
- "events": ["startup"]
- }
- }
- }
-}
+++ /dev/null
-var ex_cachingfix = class extends ExtensionCommon.ExtensionAPI {
- onStartup() {
- // we're not actually interested in startup, we need the event only
- // to ensure this experiment gets loaded.
- }
- onShutdown(isAppShutdown) {
- if (isAppShutdown) {
- return; // the application gets unloaded anyway
- }
- // Unload JSMs of this add-on
- const Cu = Components.utils;
- const rootURI = this.extension.rootURI.spec;
- for (let module of Cu.loadedModules) {
- if (module.startsWith(rootURI)) {
- Cu.unload(module);
- }
- }
- // Clear caches that could prevent upgrades from working properly
- const Services = globalThis.Services ||
- ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
- Services.obs.notifyObservers(null, "startupcache-invalidate", null);
- }
- getAPI(context) {
- return {ex_cachingfix: {}};
- }
-};