From 574677d5a24e8a8b874bb671ee128aa4cb723d36 Mon Sep 17 00:00:00 2001 From: Andrew Swan Date: Thu, 7 Feb 2019 20:47:14 +0000 Subject: [PATCH] Bug 1524325 Remove AddonEvent.needsRestart r=bzbarsky,kmag We haven't supported addons that require restarts in some time and a bunch of the underlying support for this flag is already gone from the addons manager. The mozAddonManager api is one of the last vestiges, this patch rips it out. Differential Revision: https://phabricator.services.mozilla.com/D18745 --HG-- extra : moz-landing-system : lando --- dom/webidl/AddonEvent.webidl | 2 - toolkit/mozapps/extensions/addonManager.js | 22 ++++----- .../browser/browser_webapi_addon_listener.js | 46 ++++--------------- .../test/browser/browser_webapi_enable.js | 8 ++-- 4 files changed, 25 insertions(+), 53 deletions(-) diff --git a/dom/webidl/AddonEvent.webidl b/dom/webidl/AddonEvent.webidl index 235f81ec22eb..1ec8ec1b23fc 100644 --- a/dom/webidl/AddonEvent.webidl +++ b/dom/webidl/AddonEvent.webidl @@ -2,11 +2,9 @@ Constructor(DOMString type, AddonEventInit eventInitDict)] interface AddonEvent : Event { readonly attribute DOMString id; - readonly attribute boolean needsRestart; }; dictionary AddonEventInit : EventInit { required DOMString id; - required boolean needsRestart; }; diff --git a/toolkit/mozapps/extensions/addonManager.js b/toolkit/mozapps/extensions/addonManager.js index c79e9bcd0d6d..0298961b2f28 100644 --- a/toolkit/mozapps/extensions/addonManager.js +++ b/toolkit/mozapps/extensions/addonManager.js @@ -158,19 +158,19 @@ amManager.prototype = { _addAddonListener(target) { if (!this.addonListeners.has(target)) { - let handler = (event, id, needsRestart) => { - target.sendAsyncMessage(MSG_ADDON_EVENT, {event, id, needsRestart}); + let handler = (event, id) => { + target.sendAsyncMessage(MSG_ADDON_EVENT, {event, id}); }; let listener = { - onEnabling: (addon, needsRestart) => handler("onEnabling", addon.id, needsRestart), - onEnabled: (addon) => handler("onEnabled", addon.id, false), - onDisabling: (addon, needsRestart) => handler("onDisabling", addon.id, needsRestart), - onDisabled: (addon) => handler("onDisabled", addon.id, false), - onInstalling: (addon, needsRestart) => handler("onInstalling", addon.id, needsRestart), - onInstalled: (addon) => handler("onInstalled", addon.id, false), - onUninstalling: (addon, needsRestart) => handler("onUninstalling", addon.id, needsRestart), - onUninstalled: (addon) => handler("onUninstalled", addon.id, false), - onOperationCancelled: (addon) => handler("onOperationCancelled", addon.id, false), + onEnabling: addon => handler("onEnabling", addon.id), + onEnabled: addon => handler("onEnabled", addon.id), + onDisabling: addon => handler("onDisabling", addon.id), + onDisabled: addon => handler("onDisabled", addon.id), + onInstalling: addon => handler("onInstalling", addon.id), + onInstalled: addon => handler("onInstalled", addon.id), + onUninstalling: addon => handler("onUninstalling", addon.id), + onUninstalled: addon => handler("onUninstalled", addon.id), + onOperationCancelled: addon => handler("onOperationCancelled", addon.id), }; this.addonListeners.set(target, listener); AddonManager.addAddonListener(listener); diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js index 5910c09946fd..b821c9b8e365 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js +++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_addon_listener.js @@ -14,18 +14,12 @@ async function getListenerEvents(browser) { return result.split("\n").map(JSON.parse); } -const RESTART_DISABLED_ID = "restart_disabled@tests.mozilla.org"; const RESTARTLESS_ID = "restartless@tests.mozilla.org"; const INSTALL_ID = "install@tests.mozilla.org"; const CANCEL_ID = "cancel@tests.mozilla.org"; let provider = new MockProvider(false); provider.createAddons([ - { - id: RESTART_DISABLED_ID, - name: "Disabled add-on that requires restart", - userDisabled: true, - }, { id: RESTARTLESS_ID, name: "Restartless add-on", @@ -37,26 +31,6 @@ provider.createAddons([ }, ]); -// Test enable of add-on requiring restart -add_task(async function test_enable() { - await BrowserTestUtils.withNewTab(TESTPAGE, async function(browser) { - let addon = await promiseAddonByID(RESTART_DISABLED_ID); - is(addon.userDisabled, true, "addon is disabled"); - - // enable it - await addon.enable(); - is(addon.userDisabled, false, "addon was enabled successfully"); - - let events = await getListenerEvents(browser); - - // Just a single onEnabling since restart is needed to complete - let expected = [ - {id: RESTART_DISABLED_ID, needsRestart: true, event: "onEnabling"}, - ]; - Assert.deepEqual(events, expected, "Got expected enable event"); - }); -}); - // Test enable/disable events for restartless add_task(async function test_restartless() { await BrowserTestUtils.withNewTab(TESTPAGE, async function(browser) { @@ -73,10 +47,10 @@ add_task(async function test_restartless() { let events = await getListenerEvents(browser); let expected = [ - {id: RESTARTLESS_ID, needsRestart: false, event: "onDisabling"}, - {id: RESTARTLESS_ID, needsRestart: false, event: "onDisabled"}, - {id: RESTARTLESS_ID, needsRestart: false, event: "onEnabling"}, - {id: RESTARTLESS_ID, needsRestart: false, event: "onEnabled"}, + {id: RESTARTLESS_ID, event: "onDisabling"}, + {id: RESTARTLESS_ID, event: "onDisabled"}, + {id: RESTARTLESS_ID, event: "onEnabling"}, + {id: RESTARTLESS_ID, event: "onEnabled"}, ]; Assert.deepEqual(events, expected, "Got expected disable/enable events"); }); @@ -102,8 +76,8 @@ add_task(async function test_restartless() { let events = await getListenerEvents(browser); let expected = [ - {id: INSTALL_ID, needsRestart: false, event: "onInstalling"}, - {id: INSTALL_ID, needsRestart: false, event: "onInstalled"}, + {id: INSTALL_ID, event: "onInstalling"}, + {id: INSTALL_ID, event: "onInstalled"}, ]; Assert.deepEqual(events, expected, "Got expected install events"); }); @@ -119,8 +93,8 @@ add_task(async function test_uninstall() { let events = await getListenerEvents(browser); let expected = [ - {id: RESTARTLESS_ID, needsRestart: false, event: "onUninstalling"}, - {id: RESTARTLESS_ID, needsRestart: false, event: "onUninstalled"}, + {id: RESTARTLESS_ID, event: "onUninstalling"}, + {id: RESTARTLESS_ID, event: "onUninstalled"}, ]; Assert.deepEqual(events, expected, "Got expected uninstall events"); }); @@ -136,13 +110,13 @@ add_task(async function test_cancel() { let events = await getListenerEvents(browser); let expected = [ - {id: CANCEL_ID, needsRestart: true, event: "onUninstalling"}, + {id: CANCEL_ID, event: "onUninstalling"}, ]; Assert.deepEqual(events, expected, "Got expected uninstalling event"); addon.cancelUninstall(); events = await getListenerEvents(browser); - expected.push({id: CANCEL_ID, needsRestart: false, event: "onOperationCancelled"}); + expected.push({id: CANCEL_ID, event: "onOperationCancelled"}); Assert.deepEqual(events, expected, "Got expected cancel event"); }); }); diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js index de6d414df324..5cf007f516d5 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js +++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_enable.js @@ -40,8 +40,8 @@ add_task(async function() { let events = await getListenerEvents(browser); let expected = [ - {id: ID, needsRestart: false, event: "onDisabling"}, - {id: ID, needsRestart: false, event: "onDisabled"}, + {id: ID, event: "onDisabling"}, + {id: ID, event: "onDisabled"}, ]; Assert.deepEqual(events, expected, "Got expected disable events"); @@ -54,8 +54,8 @@ add_task(async function() { events = await getListenerEvents(browser); expected = expected.concat([ - {id: ID, needsRestart: false, event: "onEnabling"}, - {id: ID, needsRestart: false, event: "onEnabled"}, + {id: ID, event: "onEnabling"}, + {id: ID, event: "onEnabled"}, ]); Assert.deepEqual(events, expected, "Got expected enable events"); });