Bug 1506546 - Refactor listAddons call sites. r=yulia

Adapt to the new returned value of listAddons
and also always call it from RootFront instead of DebuggerClient.
Fix the spec in order to expose reload on the front (it was a miss from a previous patch).

MozReview-Commit-ID: AQ5EOQEqnxX

Depends on D12575

Differential Revision: https://phabricator.services.mozilla.com/D12576

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-11-27 19:17:48 +00:00
Родитель cca3ec2d57
Коммит 2118292883
4 изменённых файлов: 7 добавлений и 18 удалений

Просмотреть файл

@ -80,10 +80,7 @@ var onConnectionReady = async function([aType, aTraits]) {
let addons = [];
try {
const response = await gClient.listAddons();
if (!response.error && response.addons.length > 0) {
addons = response.addons;
}
addons = await gClient.mainRoot.listAddons();
} catch (e) {
// listAddons throws if the runtime doesn't support addons
}
@ -163,7 +160,7 @@ var onConnectionReady = async function([aType, aTraits]) {
function buildAddonLink(addon, parent) {
const a = document.createElement("a");
a.onclick = async function() {
openToolbox(addon, true, "webconsole");
openToolbox(null, true, "webconsole", addon);
};
a.textContent = addon.name;

Просмотреть файл

@ -18,7 +18,7 @@ add_task(async function testReloadExitedAddon() {
// Retrieve the current list of addons to be notified of the next list update.
// We will also call listAddons every time we receive the event "addonListChanged" for
// the same reason.
await client.listAddons();
await client.mainRoot.listAddons();
info("Install the addon");
const addonFile = do_get_file("addons/web-extension", false);
@ -56,5 +56,5 @@ async function expectAddonListChanged(client, predicate) {
const onAddonListChanged = client.mainRoot.once("addonListChanged");
await predicate();
await onAddonListChanged;
await client.listAddons();
await client.mainRoot.listAddons();
}

Просмотреть файл

@ -29,10 +29,10 @@ add_task(async function testSuccessfulInstall() {
// The returned object is currently not a proper actor.
equal(installedAddon.actor, false);
const addonList = await client.listAddons();
ok(addonList && addonList.addons && addonList.addons.map(a => a.name),
const addonList = await client.mainRoot.listAddons();
ok(addonList && addonList.map(a => a.name),
"Received list of add-ons");
const addon = addonList.addons.filter(a => a.id === installedAddon.id)[0];
const addon = addonList.find(a => a.id === installedAddon.id);
ok(addon, "Test add-on appeared in root install list");
await close(client);

Просмотреть файл

@ -344,14 +344,6 @@ DebuggerClient.prototype = {
return this.mainRoot.listTabs(options);
},
/*
* This function exists only to preserve DebuggerClient's interface;
* new code should say 'client.mainRoot.listAddons()'.
*/
listAddons: function() {
return this.mainRoot.listAddons();
},
getTab: function(filter) {
return this.mainRoot.getTab(filter);
},