mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1335333 Fix icon handling for updates r=mossop
MozReview-Commit-ID: JWyK54Gphf8 --HG-- extra : rebase_source : 65eb8aa8a96771d366d70c7044a9c2a3c7bae9ad
This commit is contained in:
parent
415e73ad04
commit
61bc2d7d16
@ -79,6 +79,8 @@ support-files =
|
||||
browser_webext_nopermissions.xpi
|
||||
browser_webext_update1.xpi
|
||||
browser_webext_update2.xpi
|
||||
browser_webext_update_icon1.xpi
|
||||
browser_webext_update_icon2.xpi
|
||||
browser_webext_update.json
|
||||
!/image/test/mochitest/blue.png
|
||||
!/toolkit/content/tests/browser/common/mockTransfer.js
|
||||
|
@ -2,6 +2,7 @@ const {AddonManagerPrivate} = Cu.import("resource://gre/modules/AddonManager.jsm
|
||||
|
||||
const URL_BASE = "https://example.com/browser/browser/base/content/test/general";
|
||||
const ID = "update@tests.mozilla.org";
|
||||
const ID_ICON = "update_icon@tests.mozilla.org";
|
||||
|
||||
function promiseInstallAddon(url) {
|
||||
return AddonManager.getInstallForURL(url, null, "application/x-xpinstall")
|
||||
@ -84,7 +85,8 @@ add_task(function setup() {
|
||||
]});
|
||||
});
|
||||
|
||||
add_task(function* test_background_update() {
|
||||
// Helper function to test background updates.
|
||||
function* backgroundUpdateTest(url, id, checkIconFn) {
|
||||
yield SpecialPowers.pushPrefEnv({set: [
|
||||
// Turn on background updates
|
||||
["extensions.update.enabled", true],
|
||||
@ -94,7 +96,7 @@ add_task(function* test_background_update() {
|
||||
]});
|
||||
|
||||
// Install version 1.0 of the test extension
|
||||
let addon = yield promiseInstallAddon(`${URL_BASE}/browser_webext_update1.xpi`);
|
||||
let addon = yield promiseInstallAddon(url);
|
||||
|
||||
ok(addon, "Addon was installed");
|
||||
is(getBadgeStatus(), "", "Should not start out with an addon alert badge");
|
||||
@ -129,11 +131,12 @@ add_task(function* test_background_update() {
|
||||
ok(!win.gViewController.isLoading, "about:addons view is fully loaded");
|
||||
is(win.gViewController.currentViewId, VIEW, "about:addons is at extensions list");
|
||||
|
||||
// Wait for the permission prompt and cancel it
|
||||
// Wait for the permission prompt, check the contents, then cancel the update
|
||||
let panel = yield popupPromise;
|
||||
checkIconFn(panel.getAttribute("icon"));
|
||||
panel.secondaryButton.click();
|
||||
|
||||
addon = yield AddonManager.getAddonByID(ID);
|
||||
addon = yield AddonManager.getAddonByID(id);
|
||||
is(addon.version, "1.0", "Should still be running the old version");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
@ -187,7 +190,26 @@ add_task(function* test_background_update() {
|
||||
|
||||
addon.uninstall();
|
||||
yield SpecialPowers.popPrefEnv();
|
||||
});
|
||||
}
|
||||
|
||||
function checkDefaultIcon(icon) {
|
||||
is(icon, "chrome://mozapps/skin/extensions/extensionGeneric.svg",
|
||||
"Popup has the default extension icon");
|
||||
}
|
||||
|
||||
add_task(() => backgroundUpdateTest(`${URL_BASE}/browser_webext_update1.xpi`,
|
||||
ID, checkDefaultIcon));
|
||||
|
||||
function checkNonDefaultIcon(icon) {
|
||||
// The icon should come from the extension, don't bother with the precise
|
||||
// path, just make sure we've got a jar url pointing to the right path
|
||||
// inside the jar.
|
||||
ok(icon.startsWith("jar:file://"), "Icon is a jar url");
|
||||
ok(icon.endsWith("/icon.png"), "Icon is icon.png inside a jar");
|
||||
}
|
||||
|
||||
add_task(() => backgroundUpdateTest(`${URL_BASE}/browser_webext_update_icon1.xpi`,
|
||||
ID_ICON, checkNonDefaultIcon));
|
||||
|
||||
// Helper function to test a specific scenario for interactive updates.
|
||||
// `checkFn` is a callable that triggers a check for updates.
|
||||
|
@ -13,6 +13,20 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"update_icon@tests.mozilla.org": {
|
||||
"updates": [
|
||||
{
|
||||
"version": "2.0",
|
||||
"update_link": "https://example.com/browser/browser/base/content/test/general/browser_webext_update_icon2.xpi",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"strict_min_version": "1",
|
||||
"advisory_max_version": "55.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -92,7 +92,7 @@ this.ExtensionsUI = {
|
||||
let info = {
|
||||
addon,
|
||||
permissions: addon.userPermissions,
|
||||
icon: addon.iconURL || DEFAULT_EXTENSION_ICON,
|
||||
icon: addon.iconURL,
|
||||
type: "sideload",
|
||||
};
|
||||
this.showAddonsManager(browser, info).then(answer => {
|
||||
@ -101,6 +101,7 @@ this.ExtensionsUI = {
|
||||
},
|
||||
|
||||
showUpdate(browser, info) {
|
||||
info.icon = info.addon.iconURL;
|
||||
info.type = "update";
|
||||
this.showAddonsManager(browser, info).then(answer => {
|
||||
if (answer) {
|
||||
@ -268,7 +269,7 @@ this.ExtensionsUI = {
|
||||
|
||||
let popupOptions = {
|
||||
hideClose: true,
|
||||
popupIconURL: info.icon,
|
||||
popupIconURL: info.icon || DEFAULT_EXTENSION_ICON,
|
||||
persistent: true,
|
||||
|
||||
eventCallback(topic) {
|
||||
|
Loading…
Reference in New Issue
Block a user