1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 import { BaseAction } from "resource://normandy/actions/BaseAction.sys.mjs";
9 ChromeUtils.defineESModuleGetters(lazy, {
10 ActionSchemas: "resource://normandy/actions/schemas/index.sys.mjs",
11 AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
12 AddonRollouts: "resource://normandy/lib/AddonRollouts.sys.mjs",
13 TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
14 TelemetryEvents: "resource://normandy/lib/TelemetryEvents.sys.mjs",
17 export class AddonRollbackAction extends BaseAction {
19 return lazy.ActionSchemas["addon-rollback"];
23 const { rolloutSlug } = recipe.arguments;
24 const rollout = await lazy.AddonRollouts.get(rolloutSlug);
27 this.log.debug(`Rollback ${rolloutSlug} not applicable, skipping`);
31 switch (rollout.state) {
32 case lazy.AddonRollouts.STATE_ACTIVE: {
33 await lazy.AddonRollouts.update({
35 state: lazy.AddonRollouts.STATE_ROLLED_BACK,
38 const addon = await lazy.AddonManager.getAddonByID(rollout.addonId);
41 await addon.uninstall();
43 lazy.TelemetryEvents.sendEvent(
48 reason: "uninstall-failed",
55 `Could not uninstall addon ${rollout.addonId} for rollback ${rolloutSlug}: it is not installed.`
59 lazy.TelemetryEvents.sendEvent(
67 lazy.TelemetryEnvironment.setExperimentInactive(rolloutSlug);
71 case lazy.AddonRollouts.STATE_ROLLED_BACK: {
77 `Unexpected state when rolling back ${rolloutSlug}: ${rollout.state}`