mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1563062 Part 1: Remove tests of old about:addons r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D36693 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2579f3d685
commit
3bf625aa4d
@ -29,5 +29,4 @@ skip-if = !e10s
|
||||
[browser_permissions_unsigned.js]
|
||||
skip-if = require_signing
|
||||
[browser_update_checkForUpdates.js]
|
||||
[browser_update_findUpdates.js]
|
||||
[browser_update_interactive_noprompt.js]
|
||||
|
@ -38,33 +38,17 @@ function promiseEvent(eventEmitter, event) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getAddonElement(managerWindow, addonId) {
|
||||
if (managerWindow.useHtmlViews) {
|
||||
// about:addons is using the new HTML page.
|
||||
function getAddonElement(managerWindow, addonId) {
|
||||
const { contentDocument: doc } = managerWindow.document.getElementById(
|
||||
"html-view-browser"
|
||||
);
|
||||
const card = await BrowserTestUtils.waitForCondition(
|
||||
return BrowserTestUtils.waitForCondition(
|
||||
() => doc.querySelector(`addon-card[addon-id="${addonId}"]`),
|
||||
`Found entry for sideload extension addon "${addonId}" in HTML about:addons`
|
||||
);
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
// about:addons is using the XUL-based views.
|
||||
let list = managerWindow.document.getElementById("addon-list");
|
||||
// Make sure XBL bindings are applied
|
||||
list.clientHeight;
|
||||
const item = Array.from(list.children).find(_item => _item.value == addonId);
|
||||
ok(item, "Found entry for sideloaded extension in about:addons");
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
function assertDisabledSideloadedAddonElement(managerWindow, addonElement) {
|
||||
if (managerWindow.useHtmlViews) {
|
||||
// about:addons is using the new HTML page.
|
||||
const doc = addonElement.ownerDocument;
|
||||
const enableBtn = addonElement.querySelector('[action="toggle-disabled"]');
|
||||
is(
|
||||
@ -72,38 +56,18 @@ function assertDisabledSideloadedAddonElement(managerWindow, addonElement) {
|
||||
"enable-addon-button",
|
||||
"The button has the enable label"
|
||||
);
|
||||
} else {
|
||||
addonElement.scrollIntoView({ behavior: "instant" });
|
||||
ok(
|
||||
BrowserTestUtils.is_visible(addonElement._enableBtn),
|
||||
"Enable button is visible for sideloaded extension"
|
||||
);
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(addonElement._disableBtn),
|
||||
"Disable button is not visible for sideloaded extension"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function clickEnableExtension(managerWindow, addonElement) {
|
||||
if (managerWindow.useHtmlViews) {
|
||||
addonElement.querySelector('[action="toggle-disabled"]').click();
|
||||
} else {
|
||||
BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
addonElement._enableBtn,
|
||||
{},
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function test_sideloading({ useHtmlViews }) {
|
||||
add_task(async function test_sideloading() {
|
||||
const DEFAULT_ICON_URL =
|
||||
"chrome://mozapps/skin/extensions/extensionGeneric.svg";
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", useHtmlViews],
|
||||
["xpinstall.signatures.required", false],
|
||||
["extensions.autoDisableScopes", 15],
|
||||
["extensions.ui.ignoreUnsigned", true],
|
||||
@ -436,12 +400,4 @@ async function test_sideloading({ useHtmlViews }) {
|
||||
expectedEventsAddon2.length,
|
||||
"Got the expected number of telemetry events for addon2"
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function test_xul_aboutaddons_sideloading() {
|
||||
await test_sideloading({ useHtmlViews: false });
|
||||
});
|
||||
|
||||
add_task(async function test_html_aboutaddons_sideloading() {
|
||||
await test_sideloading({ useHtmlViews: true });
|
||||
});
|
||||
|
@ -13,29 +13,5 @@ function checkAll(win) {
|
||||
}
|
||||
|
||||
// Test "Check for Updates" with both auto-update settings
|
||||
async function test_check_for_updates() {
|
||||
info("Test 'Check for Updates' with auto-update true");
|
||||
await interactiveUpdateTest(true, checkAll);
|
||||
info("Test 'Check for Updates' with auto-update false");
|
||||
await interactiveUpdateTest(false, checkAll);
|
||||
}
|
||||
|
||||
add_task(async function test_xul_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
await test_check_for_updates();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_html_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
await test_check_for_updates();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
add_task(() => interactiveUpdateTest(true, checkAll));
|
||||
add_task(() => interactiveUpdateTest(false, checkAll));
|
||||
|
@ -1,32 +0,0 @@
|
||||
// Invoke an invidual extension's "Find Updates" menu item
|
||||
function checkOne(win, addon) {
|
||||
win.gViewController.doCommand("cmd_findItemUpdates", addon);
|
||||
}
|
||||
|
||||
// Test "Find Updates" with both auto-update settings
|
||||
async function test_find_updates() {
|
||||
info("Test 'Find Updates' with auto-update true");
|
||||
await interactiveUpdateTest(true, checkOne);
|
||||
info("Test 'Find Updates' with auto-update false");
|
||||
await interactiveUpdateTest(false, checkOne);
|
||||
}
|
||||
|
||||
add_task(async function test_xul_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
await test_find_updates();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_html_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
await test_find_updates();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
@ -470,8 +470,6 @@ async function interactiveUpdateTest(autoUpdate, checkFn) {
|
||||
if (manualUpdatePromise) {
|
||||
await manualUpdatePromise;
|
||||
|
||||
if (win.useHtmlViews) {
|
||||
// about:addons is using the new HTML views.
|
||||
const availableUpdates = win.document.getElementById(
|
||||
"updates-manualUpdatesFound-btn"
|
||||
);
|
||||
@ -480,19 +478,9 @@ async function interactiveUpdateTest(autoUpdate, checkFn) {
|
||||
let card = await BrowserTestUtils.waitForCondition(() => {
|
||||
return doc.querySelector(`addon-card[addon-id="${ID}"]`);
|
||||
}, `Wait addon card for "${ID}"`);
|
||||
let updateBtn = card.querySelector(
|
||||
'panel-item[action="install-update"]'
|
||||
);
|
||||
let updateBtn = card.querySelector('panel-item[action="install-update"]');
|
||||
ok(updateBtn, `Found update button for "${ID}"`);
|
||||
updateBtn.click();
|
||||
} else {
|
||||
// about:addons is still using the legacy XUL views.
|
||||
let list = win.document.getElementById("addon-list");
|
||||
// Make sure we have XBL bindings
|
||||
list.clientHeight;
|
||||
let item = list.itemChildren.find(_item => _item.value == ID);
|
||||
EventUtils.synthesizeMouseAtCenter(item._updateBtn, {}, win);
|
||||
}
|
||||
}
|
||||
|
||||
return { promise };
|
||||
|
@ -11,8 +11,6 @@ function restore_prefs() {
|
||||
registerCleanupFunction(restore_prefs);
|
||||
|
||||
async function assert_flash_locked_status(win, locked, expectedLabelText) {
|
||||
if (win.useHtmlViews) {
|
||||
// Tests while running on HTML about:addons page.
|
||||
let addonCard = await BrowserTestUtils.waitForCondition(async () => {
|
||||
let doc = win.getHtmlBrowser().contentDocument;
|
||||
await win.htmlBrowserLoaded;
|
||||
@ -46,28 +44,6 @@ async function assert_flash_locked_status(win, locked, expectedLabelText) {
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Tests while running on XUL about:addons page.
|
||||
let list = win.document.getElementById("addon-list");
|
||||
let flashEntry = await BrowserTestUtils.waitForCondition(() => {
|
||||
return list.getElementsByAttribute("name", "Shockwave Flash")[0];
|
||||
}, "Get XUL about:addons entry for flash plugin");
|
||||
let dropDown = win.document.getAnonymousElementByAttribute(
|
||||
flashEntry,
|
||||
"anonid",
|
||||
"state-menulist"
|
||||
);
|
||||
is(
|
||||
dropDown.label,
|
||||
expectedLabelText,
|
||||
"Flash setting text should match the expected value"
|
||||
);
|
||||
is(
|
||||
dropDown.disabled,
|
||||
locked,
|
||||
"Flash controls disabled state should match policy locked state"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function test_flash_status({ expectedLabelText, locked }) {
|
||||
@ -94,13 +70,10 @@ add_task(async function test_enabled() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextAskToActivate,
|
||||
locked: false,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
@ -115,13 +88,10 @@ add_task(async function test_enabled_locked() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextAskToActivate,
|
||||
locked: true,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
@ -135,13 +105,10 @@ add_task(async function test_disabled() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextNeverActivate,
|
||||
locked: false,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
@ -156,13 +123,10 @@ add_task(async function test_disabled_locked() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextNeverActivate,
|
||||
locked: true,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
@ -174,13 +138,10 @@ add_task(async function test_ask() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextAskToActivate,
|
||||
locked: false,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
@ -194,13 +155,10 @@ add_task(async function test_ask_locked() {
|
||||
},
|
||||
});
|
||||
|
||||
const testCase = () =>
|
||||
test_flash_status({
|
||||
await test_flash_status({
|
||||
expectedLabelText: labelTextAskToActivate,
|
||||
locked: true,
|
||||
});
|
||||
await testOnAboutAddonsType("XUL", testCase);
|
||||
await testOnAboutAddonsType("HTML", testCase);
|
||||
|
||||
restore_prefs();
|
||||
});
|
||||
|
@ -7,8 +7,6 @@ const BASE_URL =
|
||||
"http://mochi.test:8888/browser/browser/components/enterprisepolicies/tests/browser";
|
||||
|
||||
async function isExtensionLocked(win, addonID) {
|
||||
if (win.useHtmlViews) {
|
||||
// Test on HTML about:addons page.
|
||||
let addonCard = await BrowserTestUtils.waitForCondition(async () => {
|
||||
let doc = win.getHtmlBrowser().contentDocument;
|
||||
await win.htmlBrowserLoaded;
|
||||
@ -20,37 +18,6 @@ async function isExtensionLocked(win, addonID) {
|
||||
let removeBtn = addonCard.querySelector('panel-item[action="remove"]');
|
||||
ok(removeBtn.hidden, "Remove button should be hidden");
|
||||
ok(disableBtn.hidden, "Disable button should be hidden");
|
||||
} else {
|
||||
// Test on XUL about:addons page.
|
||||
const doc = win.document;
|
||||
let list = doc.getElementById("addon-list");
|
||||
let addonEntry = await BrowserTestUtils.waitForCondition(
|
||||
() => list.getElementsByAttribute("value", addonID)[0],
|
||||
`Get addon entry for "${addonID}"`
|
||||
);
|
||||
let disableBtn = doc.getAnonymousElementByAttribute(
|
||||
addonEntry,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
let removeBtn = doc.getAnonymousElementByAttribute(
|
||||
addonEntry,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
ok(removeBtn.hidden, "Remove button should be hidden");
|
||||
ok(disableBtn.hidden, "Disable button should be hidden");
|
||||
}
|
||||
}
|
||||
|
||||
// This test case will run on both the XUL and HTML about:addons views.
|
||||
async function test_addon_locked() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
const win = await BrowserOpenAddonsMgr("addons://list/extension");
|
||||
|
||||
await isExtensionLocked(win, ADDON_ID);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function test_addon_install() {
|
||||
@ -75,12 +42,13 @@ add_task(async function test_addon_install() {
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_XUL_aboutaddons_addon_locked() {
|
||||
await testOnAboutAddonsType("XUL", test_addon_locked);
|
||||
});
|
||||
add_task(async function test_addon_locked() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
const win = await BrowserOpenAddonsMgr("addons://list/extension");
|
||||
|
||||
add_task(async function test_HTML_aboutaddons_addon_locked() {
|
||||
await testOnAboutAddonsType("HTML", test_addon_locked);
|
||||
await isExtensionLocked(win, ADDON_ID);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function test_addon_reinstall() {
|
||||
|
@ -83,23 +83,3 @@ registerCleanupFunction(async function policies_headjs_finishWithCleanSlate() {
|
||||
EnterprisePolicyTesting.resetRunOnceState();
|
||||
PoliciesPrefTracker.stop();
|
||||
});
|
||||
|
||||
async function testOnAboutAddonsType(type, fn) {
|
||||
let useHtmlAboutAddons;
|
||||
switch (type) {
|
||||
case "XUL":
|
||||
useHtmlAboutAddons = false;
|
||||
break;
|
||||
case "HTML":
|
||||
useHtmlAboutAddons = true;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown about:addons type ${type}`);
|
||||
}
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", useHtmlAboutAddons]],
|
||||
});
|
||||
info(`Run tests on ${type} about:addons`);
|
||||
await fn();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
|
@ -12,12 +12,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
||||
"extensions.abuseReport.enabled",
|
||||
false
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"HTML_ABOUTADDONS_ENABLED",
|
||||
"extensions.htmlaboutaddons.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
let extData = {
|
||||
manifest: {
|
||||
@ -208,7 +202,7 @@ add_task(async function browseraction_contextmenu_manage_extension() {
|
||||
);
|
||||
is(
|
||||
reportExtension.hidden,
|
||||
!ABUSE_REPORT_ENABLED || !HTML_ABOUTADDONS_ENABLED || !visible,
|
||||
!ABUSE_REPORT_ENABLED || !visible,
|
||||
`Report Extension should be ${expected}`
|
||||
);
|
||||
is(
|
||||
@ -234,7 +228,7 @@ add_task(async function browseraction_contextmenu_manage_extension() {
|
||||
);
|
||||
await closeChromeContextMenu(menuId, manageExtension, win);
|
||||
let managerWindow = (await addonManagerPromise).linkedBrowser.contentWindow;
|
||||
if (managerWindow.useHtmlViews) {
|
||||
|
||||
// Check the UI to make sure that the correct view is loaded.
|
||||
is(
|
||||
managerWindow.gViewController.currentViewId,
|
||||
@ -244,11 +238,6 @@ add_task(async function browseraction_contextmenu_manage_extension() {
|
||||
// In HTML about:addons, the default view does not show the inline
|
||||
// options browser, so we should not receive an "options-loaded" event.
|
||||
// (if we do, the test will fail due to the unexpected message).
|
||||
} else {
|
||||
info("Waiting for inline options page in XUL about:addons");
|
||||
// In XUL about:addons, the inline options page is shown by default.
|
||||
await extension.awaitMessage("options-loaded");
|
||||
}
|
||||
|
||||
info(
|
||||
`Remove the opened tab, and await customize mode to be restored if necessary`
|
||||
@ -575,10 +564,7 @@ add_task(async function browseraction_contextmenu_remove_extension() {
|
||||
// mode enabled).
|
||||
add_task(async function browseraction_contextmenu_report_extension() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.abuseReport.enabled", true],
|
||||
],
|
||||
set: [["extensions.abuseReport.enabled", true]],
|
||||
});
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
let id = "addon_id@example.com";
|
||||
|
@ -62,7 +62,7 @@ async function loadExtension(options) {
|
||||
return extension;
|
||||
}
|
||||
|
||||
async function run_test_inline_options() {
|
||||
add_task(async function run_test_inline_options() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"http://example.com/"
|
||||
@ -256,19 +256,6 @@ async function run_test_inline_options() {
|
||||
await extension.unload();
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function test_inline_options() {
|
||||
for (let htmlEnabled of [false, true]) {
|
||||
info(
|
||||
`Test options opened inline ${htmlEnabled ? "HTML" : "XUL"} about:addons`
|
||||
);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", htmlEnabled]],
|
||||
});
|
||||
await run_test_inline_options();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_tab_options() {
|
||||
|
@ -46,10 +46,6 @@ generated-files =
|
||||
tags = blocklist
|
||||
[browser_about_debugging_link.js]
|
||||
[browser_bug523784.js]
|
||||
[browser_bug562890.js]
|
||||
skip-if = os == 'win' && !debug # Disabled on Windows opt/PGO builds due to intermittent failures (bug 1135866)
|
||||
[browser_bug562899.js]
|
||||
[browser_bug562992.js]
|
||||
[browser_bug567127.js]
|
||||
skip-if = (!debug && os == 'win') #Bug 1489496
|
||||
[browser_bug567137.js]
|
||||
@ -57,19 +53,12 @@ skip-if = (!debug && os == 'win') #Bug 1489496
|
||||
skip-if = verify
|
||||
[browser_bug572561.js]
|
||||
[browser_bug577990.js]
|
||||
[browser_bug580298.js]
|
||||
[browser_bug586574.js]
|
||||
[browser_bug587970.js]
|
||||
[browser_bug591465.js]
|
||||
skip-if = os == "linux" && !debug # Bug 1395539 - fails on multi-core
|
||||
[browser_bug591663.js]
|
||||
[browser_bug618502.js]
|
||||
[browser_bug679604.js]
|
||||
[browser_bug590347.js]
|
||||
[browser_checkAddonCompatibility.js]
|
||||
[browser_details.js]
|
||||
[browser_discovery.js]
|
||||
[browser_discovery_clientid.js]
|
||||
[browser_dragdrop.js]
|
||||
[browser_extension_sideloading_permission.js]
|
||||
[browser_file_xpi_no_process_switch.js]
|
||||
@ -96,30 +85,15 @@ skip-if = (os == 'win' && processor == 'aarch64') # aarch64 has no plugin suppor
|
||||
[browser_html_recommendations.js]
|
||||
[browser_html_updates.js]
|
||||
[browser_html_warning_messages.js]
|
||||
[browser_inlinesettings_browser.js]
|
||||
skip-if = os == 'mac' || os == 'linux' # Bug 1483347
|
||||
[browser_installssl.js]
|
||||
skip-if = verify
|
||||
[browser_interaction_telemetry.js]
|
||||
[browser_langpack_signing.js]
|
||||
[browser_legacy.js]
|
||||
[browser_legacy_pre57.js]
|
||||
[browser_list.js]
|
||||
[browser_manage_shortcuts.js]
|
||||
[browser_manage_shortcuts_hidden.js]
|
||||
[browser_manualupdates.js]
|
||||
[browser_pluginprefs.js]
|
||||
[browser_pluginprefs_is_not_disabled.js]
|
||||
[browser_plugin_enabled_state_locked.js]
|
||||
[browser_recentupdates.js]
|
||||
[browser_reinstall.js]
|
||||
[browser_sorting.js]
|
||||
[browser_sorting_plugins.js]
|
||||
[browser_tabsettings.js]
|
||||
[browser_task_next_test.js]
|
||||
[browser_theme_previews.js]
|
||||
[browser_types.js]
|
||||
[browser_uninstalling.js]
|
||||
[browser_updateid.js]
|
||||
[browser_updatessl.js]
|
||||
[browser_webapi.js]
|
||||
@ -133,8 +107,3 @@ skip-if = verify
|
||||
[browser_webext_icon.js]
|
||||
[browser_webext_incognito.js]
|
||||
[browser_webext_incognito_doorhanger_telemetry.js]
|
||||
[browser_webext_options.js]
|
||||
tags = webextensions
|
||||
skip-if = os == 'linux' || (os == 'mac' && debug) # bug 1483347
|
||||
[browser_webext_options_addon_reload.js]
|
||||
tags = webextensions
|
||||
|
@ -56,124 +56,14 @@ function resetBlocklist() {
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", _originalBlocklistURL);
|
||||
}
|
||||
|
||||
function getXULPluginUI(plugin, anonid) {
|
||||
if (
|
||||
plugin.openOrClosedShadowRoot &&
|
||||
plugin.openOrClosedShadowRoot.isUAWidget()
|
||||
) {
|
||||
return plugin.openOrClosedShadowRoot.getElementById(anonid);
|
||||
}
|
||||
return plugin.ownerDocument.getAnonymousElementByAttribute(
|
||||
plugin,
|
||||
"anonid",
|
||||
anonid
|
||||
);
|
||||
}
|
||||
|
||||
function assertPluginActiveState({
|
||||
managerWindow,
|
||||
pluginId,
|
||||
expectedActivateState,
|
||||
}) {
|
||||
let pluginEl = get_addon_element(managerWindow, pluginId);
|
||||
ok(pluginEl, `Got the about:addon entry for "${pluginId}"`);
|
||||
|
||||
if (managerWindow.useHtmlViews) {
|
||||
const pluginOptions = pluginEl.querySelector("plugin-options");
|
||||
const pluginCheckedItem = pluginOptions.querySelector(
|
||||
"panel-item[checked]"
|
||||
);
|
||||
is(
|
||||
pluginCheckedItem.getAttribute("action"),
|
||||
expectedActivateState,
|
||||
`plugin should have ${expectedActivateState} state selected`
|
||||
);
|
||||
} else {
|
||||
// Assertions for the XUL about:addons views.
|
||||
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
|
||||
let enableButton = getXULPluginUI(pluginEl, "enable-btn");
|
||||
let disableButton = getXULPluginUI(pluginEl, "disable-btn");
|
||||
is_element_hidden(enableButton, "enable button should be hidden");
|
||||
is_element_hidden(disableButton, "disable button should be hidden");
|
||||
let menu = getXULPluginUI(pluginEl, "state-menulist");
|
||||
is_element_visible(menu, "state menu should be visible");
|
||||
let activateItem = getXULPluginUI(
|
||||
pluginEl,
|
||||
`${expectedActivateState}-menuitem`
|
||||
);
|
||||
ok(
|
||||
activateItem,
|
||||
`Got a menu item for the ${expectedActivateState} plugin activate state`
|
||||
);
|
||||
is(
|
||||
menu.selectedItem,
|
||||
activateItem,
|
||||
`state menu should have '${expectedActivateState}' selected`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function setPluginActivateState({ managerWindow, pluginId, activateState }) {
|
||||
let pluginEl = get_addon_element(managerWindow, pluginId);
|
||||
ok(pluginEl, `Got the about:addon entry for "${pluginId}"`);
|
||||
|
||||
if (managerWindow.useHtmlViews) {
|
||||
// Activate plugin on the HTML about:addons views.
|
||||
let activateAction = pluginEl.querySelector(`[action="${activateState}"]`);
|
||||
ok(activateAction, `Got element for ${activateState} plugin action`);
|
||||
activateAction.click();
|
||||
} else {
|
||||
// Activate plugin on the XUL about:addons views.
|
||||
let activateItem = getXULPluginUI(pluginEl, `${activateState}-menuitem`);
|
||||
ok(
|
||||
activateItem,
|
||||
`Got a menu item for the ${activateState} plugin activate state`
|
||||
);
|
||||
let menu = getXULPluginUI(pluginEl, "state-menulist");
|
||||
menu.selectedItem = activateItem;
|
||||
activateItem.doCommand();
|
||||
}
|
||||
}
|
||||
|
||||
async function assertPluginAppDisabled({ managerWindow, pluginId }) {
|
||||
const pluginEl = get_addon_element(managerWindow, pluginId);
|
||||
ok(pluginEl, `Got the about:addon entry for "${pluginId}"`);
|
||||
|
||||
if (managerWindow.useHtmlViews) {
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = pluginEl.querySelector("plugin-options");
|
||||
pluginOptions.querySelector("panel-list").open = true;
|
||||
// tests all buttons disabled (besides the checked one and the expand action)
|
||||
// are expected to be disabled if locked is true.
|
||||
for (const item of pluginOptions.querySelectorAll(
|
||||
"panel-item:not([hidden])"
|
||||
)) {
|
||||
const actionName = item.getAttribute("action");
|
||||
if (
|
||||
!item.hasAttribute("checked") &&
|
||||
actionName !== "expand" &&
|
||||
actionName !== "preferences"
|
||||
) {
|
||||
ok(
|
||||
item.shadowRoot.querySelector("button").disabled,
|
||||
`Plugin action "${actionName}" should be disabled`
|
||||
);
|
||||
}
|
||||
}
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
} else {
|
||||
// Assertions for the XUL about:addons views.
|
||||
let menu = getXULPluginUI(pluginEl, "state-menulist");
|
||||
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
|
||||
menu = getXULPluginUI(pluginEl, "state-menulist");
|
||||
is(menu.disabled, true, "state menu should be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(pluginEl, {}, managerWindow);
|
||||
await BrowserTestUtils.waitForEvent(managerWindow.document, "ViewChanged");
|
||||
|
||||
menu = managerWindow.document.getElementById("detail-state-menulist");
|
||||
is(menu.disabled, true, "detail state menu should be disabled");
|
||||
}
|
||||
}
|
||||
|
||||
async function getTestPluginAddon() {
|
||||
@ -188,7 +78,7 @@ async function getTestPluginAddon() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function test_CTP_plugins(aboutAddonsType) {
|
||||
add_task(async function test_CTP_plugins() {
|
||||
let pluginTag = getTestPluginTag();
|
||||
pluginTag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
|
||||
let managerWindow = await open_manager("addons://list/plugin");
|
||||
@ -202,11 +92,14 @@ async function test_CTP_plugins(aboutAddonsType) {
|
||||
ok(pluginEl, `Got the about:addon entry for "${testPluginId}"`);
|
||||
|
||||
info("part3: test plugin add-on actions status");
|
||||
assertPluginActiveState({
|
||||
managerWindow,
|
||||
pluginId: testPluginId,
|
||||
expectedActivateState: "ask-to-activate",
|
||||
});
|
||||
|
||||
let pluginOptions = pluginEl.querySelector("plugin-options");
|
||||
let pluginCheckedItem = pluginOptions.querySelector("panel-item[checked]");
|
||||
is(
|
||||
pluginCheckedItem.getAttribute("action"),
|
||||
"ask-to-activate",
|
||||
"plugin should have ask-to-activate state selected"
|
||||
);
|
||||
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
@ -274,11 +167,15 @@ async function test_CTP_plugins(aboutAddonsType) {
|
||||
BrowserTestUtils.removeTab(pluginTab);
|
||||
|
||||
info("part8: test plugin state is never-activate");
|
||||
assertPluginActiveState({
|
||||
managerWindow,
|
||||
pluginId: testPluginId,
|
||||
expectedActivateState: "never-activate",
|
||||
});
|
||||
pluginEl = get_addon_element(managerWindow, testPluginId);
|
||||
|
||||
pluginOptions = pluginEl.querySelector("plugin-options");
|
||||
const pluginCheckItem = pluginOptions.querySelector("panel-item[checked]");
|
||||
is(
|
||||
pluginCheckItem.getAttribute("action"),
|
||||
"never-activate",
|
||||
"plugin should have never-activate state selected"
|
||||
);
|
||||
|
||||
info("part9: set plugin state to always-activate");
|
||||
setPluginActivateState({
|
||||
@ -330,23 +227,6 @@ async function test_CTP_plugins(aboutAddonsType) {
|
||||
|
||||
BrowserTestUtils.removeTab(pluginTab);
|
||||
await close_manager(managerWindow);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
|
||||
add_task(async function test_CTP_plugins_XUL_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await test_CTP_plugins("XUL");
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_CTP_plugins_HTML_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await test_CTP_plugins("HTML");
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_blocklisted_plugin_disabled() {
|
||||
@ -392,21 +272,33 @@ async function checkPlugins() {
|
||||
isnot(testPluginAddon, null, "Test Plug-in should exist");
|
||||
let testPluginId = testPluginAddon.id;
|
||||
|
||||
let managerWindow;
|
||||
let managerWindow = await open_manager("addons://list/plugin");
|
||||
|
||||
info("Test blocklisted plugin actions disabled in XUL about:addons");
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
managerWindow = await open_manager("addons://list/plugin");
|
||||
await assertPluginAppDisabled({ managerWindow, pluginId: testPluginId });
|
||||
await close_manager(managerWindow);
|
||||
let pluginEl = get_addon_element(managerWindow, testPluginId);
|
||||
ok(pluginEl, `Got about:addons entry for ${testPluginId}`);
|
||||
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = pluginEl.querySelector("plugin-options");
|
||||
pluginOptions.querySelector("panel-list").open = true;
|
||||
|
||||
// tests all buttons disabled (besides the checked one and the expand action)
|
||||
// are expected to be disabled if locked is true.
|
||||
for (const item of pluginOptions.querySelectorAll(
|
||||
"panel-item:not([hidden])"
|
||||
)) {
|
||||
const actionName = item.getAttribute("action");
|
||||
if (
|
||||
!item.hasAttribute("checked") &&
|
||||
actionName !== "expand" &&
|
||||
actionName !== "preferences"
|
||||
) {
|
||||
ok(
|
||||
item.shadowRoot.querySelector("button").disabled,
|
||||
`Plugin action "${actionName}" should be disabled`
|
||||
);
|
||||
}
|
||||
}
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
|
||||
info("Test blocklisted plugin actions disabled in HTML about:addons");
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
managerWindow = await open_manager("addons://list/plugin");
|
||||
await assertPluginAppDisabled({ managerWindow, pluginId: testPluginId });
|
||||
await close_manager(managerWindow);
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests the Preferences button for addons in list view
|
||||
*/
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
requestLongerTimeout(2);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
var addonPrefsURI = CHROMEROOT + "addon_prefs.xul";
|
||||
|
||||
var gProvider = new MockProvider();
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "test1@tests.mozilla.org",
|
||||
name: "Test add-on 1",
|
||||
description: "foo",
|
||||
},
|
||||
{
|
||||
id: "test2@tests.mozilla.org",
|
||||
name: "Test add-on 2",
|
||||
description: "bar",
|
||||
optionsURL: addonPrefsURI,
|
||||
},
|
||||
]);
|
||||
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
var addonList = aManager.document.getElementById("addon-list");
|
||||
for (var addonItem of addonList.childNodes) {
|
||||
if (
|
||||
addonItem.hasAttribute("name") &&
|
||||
addonItem.getAttribute("name") == "Test add-on 1"
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var prefsBtn = aManager.document.getAnonymousElementByAttribute(
|
||||
addonItem,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is(
|
||||
prefsBtn.hidden,
|
||||
true,
|
||||
"Prefs button should be hidden for addon with no optionsURL set"
|
||||
);
|
||||
|
||||
for (addonItem of addonList.childNodes) {
|
||||
if (
|
||||
addonItem.hasAttribute("name") &&
|
||||
addonItem.getAttribute("name") == "Test add-on 2"
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
prefsBtn = aManager.document.getAnonymousElementByAttribute(
|
||||
addonItem,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is(
|
||||
prefsBtn.hidden,
|
||||
true,
|
||||
"Prefs button should not be shown for addon with just an optionsURL set"
|
||||
);
|
||||
|
||||
close_manager(aManager, finish);
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Simulates quickly switching between different list views to verify that only
|
||||
// the last selected is displayed
|
||||
|
||||
const { PromiseTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/PromiseTestUtils.jsm"
|
||||
);
|
||||
|
||||
PromiseTestUtils.whitelistRejectionsGlobally(/this\._errorLink/);
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files and these test cases should be added in Bug 1552170).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
// Tests that loading a second view before the first has not finished loading
|
||||
// does not merge the results
|
||||
add_test(async function() {
|
||||
var themeCount = null;
|
||||
var pluginCount = null;
|
||||
var themeItem = gCategoryUtilities.get("theme");
|
||||
var pluginItem = gCategoryUtilities.get("plugin");
|
||||
var list = gManagerWindow.document.getElementById("addon-list");
|
||||
|
||||
await gCategoryUtilities.open(themeItem);
|
||||
themeCount = list.childNodes.length;
|
||||
ok(themeCount > 0, "Test is useless if there are no themes");
|
||||
|
||||
await gCategoryUtilities.open(pluginItem);
|
||||
pluginCount = list.childNodes.length;
|
||||
ok(pluginCount > 0, "Test is useless if there are no plugins");
|
||||
|
||||
gCategoryUtilities.open(themeItem);
|
||||
|
||||
await gCategoryUtilities.open(pluginItem);
|
||||
is(list.childNodes.length, pluginCount, "Should only see the plugins");
|
||||
|
||||
var item = list.firstChild;
|
||||
while (item) {
|
||||
is(item.getAttribute("type"), "plugin", "All items should be plugins");
|
||||
item = item.nextSibling;
|
||||
}
|
||||
|
||||
// Tests that switching to, from, to the same pane in quick succession
|
||||
// still only shows the right number of results
|
||||
|
||||
gCategoryUtilities.open(themeItem);
|
||||
gCategoryUtilities.open(pluginItem);
|
||||
await gCategoryUtilities.open(themeItem);
|
||||
is(list.childNodes.length, themeCount, "Should only see the theme");
|
||||
|
||||
item = list.firstChild;
|
||||
while (item) {
|
||||
is(item.getAttribute("type"), "theme", "All items should be theme");
|
||||
item = item.nextSibling;
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -1,74 +0,0 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* This test ensures that when the extension manager UI is open and a
|
||||
* restartless extension is installed from the web, its correct name appears
|
||||
* when the download and installation complete. See bug 562992.
|
||||
*/
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
var gInstall;
|
||||
|
||||
const EXTENSION_NAME = "Wunderbar";
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
// Create a MockInstall with a MockAddon payload and add it to the provider,
|
||||
// causing the onNewInstall event to fire, which in turn will cause a new
|
||||
// "installing" item to appear in the list of extensions.
|
||||
add_test(function() {
|
||||
let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true);
|
||||
gInstall = new MockInstall(undefined, undefined, addon);
|
||||
gInstall.addTestListener({
|
||||
onNewInstall: run_next_test,
|
||||
});
|
||||
gProvider.addInstall(gInstall);
|
||||
});
|
||||
|
||||
// Finish the install, which will cause the "installing" item to be converted
|
||||
// to an "installed" item, which should have the correct add-on name.
|
||||
add_test(function() {
|
||||
gInstall.addTestListener({
|
||||
onInstallEnded() {
|
||||
let list = gManagerWindow.document.getElementById("addon-list");
|
||||
|
||||
// To help prevent future breakage, don't assume the item is the only one
|
||||
// in the list, or that it's first in the list. Find it by name.
|
||||
for (let i = 0; i < list.itemCount; i++) {
|
||||
let item = list.getItemAtIndex(i);
|
||||
if (item.getAttribute("name") === EXTENSION_NAME) {
|
||||
ok(true, "Item with correct name found");
|
||||
run_next_test();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ok(false, "Item with correct name was not found");
|
||||
run_next_test();
|
||||
},
|
||||
});
|
||||
gInstall.install();
|
||||
});
|
@ -1,111 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that certain types of addons do not have their version number
|
||||
// displayed. This currently only includes lightweight themes.
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI (and the HTML about:addons
|
||||
// actually shows the version also on themes).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
add_task(async function test() {
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "extension@tests.mozilla.org",
|
||||
name: "Extension 1",
|
||||
type: "extension",
|
||||
version: "123",
|
||||
},
|
||||
{
|
||||
id: "theme@tests.mozilla.org",
|
||||
name: "Theme 2",
|
||||
type: "theme",
|
||||
version: "456",
|
||||
},
|
||||
{
|
||||
id: "lwtheme@personas.mozilla.org",
|
||||
name: "Persona 3",
|
||||
type: "theme",
|
||||
version: "789",
|
||||
},
|
||||
]);
|
||||
|
||||
gManagerWindow = await open_manager();
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
});
|
||||
|
||||
function get(aId) {
|
||||
return gManagerWindow.document.getElementById(aId);
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
return parent.ownerDocument.getAnonymousElementByAttribute(
|
||||
parent,
|
||||
"anonid",
|
||||
anonid
|
||||
);
|
||||
}
|
||||
|
||||
function open_details(aList, aItem, aCallback) {
|
||||
aList.ensureElementIsVisible(aItem);
|
||||
EventUtils.synthesizeMouseAtCenter(aItem, {}, gManagerWindow);
|
||||
return new Promise(resolve => wait_for_view_load(gManagerWindow, resolve));
|
||||
}
|
||||
|
||||
var check_addon_has_version = async function(aList, aName, aVersion) {
|
||||
for (let i = 0; i < aList.itemCount; i++) {
|
||||
let item = aList.getItemAtIndex(i);
|
||||
if (get_node(item, "name").textContent === aName) {
|
||||
ok(true, "Item with correct name found");
|
||||
let { version } = await get_tooltip_info(item);
|
||||
is(version, aVersion, "Item has correct version");
|
||||
return item;
|
||||
}
|
||||
}
|
||||
ok(false, "Item with correct name was not found");
|
||||
return null;
|
||||
};
|
||||
|
||||
add_task(async function() {
|
||||
await gCategoryUtilities.openType("extension");
|
||||
info("Extension");
|
||||
let list = gManagerWindow.document.getElementById("addon-list");
|
||||
let item = await check_addon_has_version(list, "Extension 1", "123");
|
||||
await open_details(list, item);
|
||||
is_element_visible(get("detail-version"), "Details view has version visible");
|
||||
is(get("detail-version").value, "123", "Details view has correct version");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
await gCategoryUtilities.openType("theme");
|
||||
info("Normal theme");
|
||||
let list = gManagerWindow.document.getElementById("addon-list");
|
||||
let item = await check_addon_has_version(list, "Theme 2", "456");
|
||||
await open_details(list, item);
|
||||
is_element_visible(get("detail-version"), "Details view has version visible");
|
||||
is(get("detail-version").value, "456", "Details view has correct version");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
await gCategoryUtilities.openType("theme");
|
||||
info("Lightweight theme");
|
||||
let list = gManagerWindow.document.getElementById("addon-list");
|
||||
// See that the version isn't displayed
|
||||
let item = await check_addon_has_version(list, "Persona 3", undefined);
|
||||
await open_details(list, item);
|
||||
is_element_hidden(get("detail-version"), "Details view has version hidden");
|
||||
// If the version element is hidden then we don't care about its value
|
||||
});
|
||||
|
||||
add_task(function end_test() {
|
||||
close_manager(gManagerWindow, finish);
|
||||
});
|
@ -1,294 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
||||
// Bug 587970 - Provide ability "Update all now" within 'Available Updates' screen
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases, "Update all now" has been deprecated
|
||||
// and not supported in HTML about:addons).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "addon 1",
|
||||
version: "1.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "addon2@tests.mozilla.org",
|
||||
name: "addon 2",
|
||||
version: "2.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "addon3@tests.mozilla.org",
|
||||
name: "addon 3",
|
||||
version: "3.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager("addons://updates/available");
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, finish);
|
||||
}
|
||||
|
||||
add_test(function() {
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
is(list.childNodes.length, 0, "Available updates list should be empty");
|
||||
|
||||
var emptyNotice = gManagerWindow.document.getElementById(
|
||||
"empty-availableUpdates-msg"
|
||||
);
|
||||
is_element_visible(emptyNotice, "Empty notice should be visible");
|
||||
|
||||
var updateSelected = gManagerWindow.document.getElementById(
|
||||
"update-selected-btn"
|
||||
);
|
||||
is_element_hidden(updateSelected, "Update Selected button should be hidden");
|
||||
|
||||
info("Adding updates");
|
||||
gProvider.createInstalls([
|
||||
{
|
||||
name: "addon 1",
|
||||
version: "1.1",
|
||||
existingAddon: gProvider.addons[0],
|
||||
},
|
||||
{
|
||||
name: "addon 2",
|
||||
version: "2.1",
|
||||
existingAddon: gProvider.addons[1],
|
||||
},
|
||||
{
|
||||
name: "addon 3",
|
||||
version: "3.1",
|
||||
existingAddon: gProvider.addons[2],
|
||||
},
|
||||
]);
|
||||
|
||||
function wait_for_refresh() {
|
||||
if (
|
||||
list.childNodes.length == 3 &&
|
||||
list.childNodes[0].mManualUpdate &&
|
||||
list.childNodes[1].mManualUpdate &&
|
||||
list.childNodes[2].mManualUpdate
|
||||
) {
|
||||
run_next_test();
|
||||
} else {
|
||||
info("Waiting for pane to refresh");
|
||||
setTimeout(wait_for_refresh, 10);
|
||||
}
|
||||
}
|
||||
info("Waiting for pane to refresh");
|
||||
setTimeout(wait_for_refresh, 10);
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
is(list.childNodes.length, 3, "Available updates list should have 2 items");
|
||||
|
||||
var item1 = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
isnot(item1, null, "Item for addon1@tests.mozilla.org should be in list");
|
||||
var item2 = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
|
||||
isnot(item2, null, "Item for addon2@tests.mozilla.org should be in list");
|
||||
var item3 = get_addon_element(gManagerWindow, "addon3@tests.mozilla.org");
|
||||
isnot(item3, null, "Item for addon3@tests.mozilla.org should be in list");
|
||||
|
||||
var emptyNotice = gManagerWindow.document.getElementById(
|
||||
"empty-availableUpdates-msg"
|
||||
);
|
||||
is_element_hidden(emptyNotice, "Empty notice should be hidden");
|
||||
|
||||
var updateSelected = gManagerWindow.document.getElementById(
|
||||
"update-selected-btn"
|
||||
);
|
||||
is_element_visible(
|
||||
updateSelected,
|
||||
"Update Selected button should be visible"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should be enabled by default"
|
||||
);
|
||||
|
||||
is(
|
||||
item1._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should be checked by default for addon1"
|
||||
);
|
||||
is(
|
||||
item2._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should be checked by default for addon2"
|
||||
);
|
||||
is(
|
||||
item3._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should be checked by default for addon3"
|
||||
);
|
||||
|
||||
info("Unchecking Include Update checkbox for addon1");
|
||||
EventUtils.synthesizeMouse(item1._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item1._includeUpdate.checked,
|
||||
false,
|
||||
"Include Update checkbox should now be be unchecked for addon1"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should still be enabled"
|
||||
);
|
||||
|
||||
info("Unchecking Include Update checkbox for addon2");
|
||||
EventUtils.synthesizeMouse(item2._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item2._includeUpdate.checked,
|
||||
false,
|
||||
"Include Update checkbox should now be be unchecked for addon2"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should still be enabled"
|
||||
);
|
||||
|
||||
info("Unchecking Include Update checkbox for addon3");
|
||||
EventUtils.synthesizeMouse(item3._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item3._includeUpdate.checked,
|
||||
false,
|
||||
"Include Update checkbox should now be be unchecked for addon3"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
true,
|
||||
"Update Selected button should now be disabled"
|
||||
);
|
||||
|
||||
info("Checking Include Update checkbox for addon2");
|
||||
EventUtils.synthesizeMouse(item2._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item2._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should now be be checked for addon2"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should now be enabled"
|
||||
);
|
||||
|
||||
info("Checking Include Update checkbox for addon3");
|
||||
EventUtils.synthesizeMouse(item3._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item3._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should now be be checked for addon3"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should now be enabled"
|
||||
);
|
||||
|
||||
var installCount = 0;
|
||||
var listener = {
|
||||
onDownloadStarted(aInstall) {
|
||||
isnot(
|
||||
aInstall.existingAddon.id,
|
||||
"addon1@tests.mozilla.org",
|
||||
"Should not have seen a download start for addon1"
|
||||
);
|
||||
},
|
||||
|
||||
onInstallEnded(aInstall) {
|
||||
if (++installCount < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
gProvider.installs[0].removeTestListener(listener);
|
||||
gProvider.installs[1].removeTestListener(listener);
|
||||
gProvider.installs[2].removeTestListener(listener);
|
||||
|
||||
// Installs are started synchronously so by the time an executeSoon is
|
||||
// executed all installs that are going to start will have started
|
||||
executeSoon(function() {
|
||||
is(
|
||||
gProvider.installs[0].state,
|
||||
AddonManager.STATE_AVAILABLE,
|
||||
"addon1 should not have been upgraded"
|
||||
);
|
||||
is(
|
||||
gProvider.installs[1].state,
|
||||
AddonManager.STATE_INSTALLED,
|
||||
"addon2 should have been upgraded"
|
||||
);
|
||||
is(
|
||||
gProvider.installs[2].state,
|
||||
AddonManager.STATE_INSTALLED,
|
||||
"addon3 should have been upgraded"
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
},
|
||||
};
|
||||
gProvider.installs[0].addTestListener(listener);
|
||||
gProvider.installs[1].addTestListener(listener);
|
||||
gProvider.installs[2].addTestListener(listener);
|
||||
info("Clicking Update Selected button");
|
||||
EventUtils.synthesizeMouseAtCenter(updateSelected, {}, gManagerWindow);
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
var updateSelected = gManagerWindow.document.getElementById(
|
||||
"update-selected-btn"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
true,
|
||||
"Update Selected button should be disabled"
|
||||
);
|
||||
|
||||
var item1 = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
isnot(item1, null, "Item for addon1@tests.mozilla.org should be in list");
|
||||
is(
|
||||
item1._includeUpdate.checked,
|
||||
false,
|
||||
"Include Update checkbox should not have changed"
|
||||
);
|
||||
|
||||
info("Checking Include Update checkbox for addon1");
|
||||
EventUtils.synthesizeMouse(item1._includeUpdate, 2, 2, {}, gManagerWindow);
|
||||
is(
|
||||
item1._includeUpdate.checked,
|
||||
true,
|
||||
"Include Update checkbox should now be be checked for addon1"
|
||||
);
|
||||
is(
|
||||
updateSelected.disabled,
|
||||
false,
|
||||
"Update Selected button should now not be disabled"
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -1,152 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Bug 590347
|
||||
// Tests if softblock notifications are exposed in preference to incompatible
|
||||
// notifications when compatibility checking is disabled
|
||||
|
||||
var gProvider;
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
||||
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
|
||||
var gVersion = Services.appinfo.version;
|
||||
|
||||
// Tested in browser_html_warning_messages.js for HTML.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
// Opens the details view of an add-on
|
||||
async function open_details(aId, aType, aCallback) {
|
||||
requestLongerTimeout(2);
|
||||
|
||||
await gCategoryUtilities.openType(aType);
|
||||
var list = gManagerWindow.document.getElementById("addon-list");
|
||||
var item = list.firstChild;
|
||||
while (item) {
|
||||
if ("mAddon" in item && item.mAddon.id == aId) {
|
||||
list.ensureElementIsVisible(item);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
item,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
item,
|
||||
{ clickCount: 2 },
|
||||
gManagerWindow
|
||||
);
|
||||
wait_for_view_load(gManagerWindow, aCallback);
|
||||
return;
|
||||
}
|
||||
item = item.nextSibling;
|
||||
}
|
||||
ok(false, "Should have found the add-on in the list");
|
||||
}
|
||||
|
||||
function get_list_view_warning_node() {
|
||||
let item = gManagerWindow.document.getElementById("addon-list").firstChild;
|
||||
let found = false;
|
||||
while (item) {
|
||||
if (item.mAddon.name == "Test add-on") {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
item = item.nextSibling;
|
||||
}
|
||||
ok(found, "Test add-on node should have been found.");
|
||||
return item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning"
|
||||
);
|
||||
}
|
||||
|
||||
function get_detail_view_warning_node(aManagerWindow) {
|
||||
if (aManagerWindow) {
|
||||
return aManagerWindow.document.getElementById("detail-warning");
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "Test add-on",
|
||||
description: "A test add-on",
|
||||
isCompatible: false,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
// Check with compatibility checking enabled
|
||||
add_test(async function() {
|
||||
await gCategoryUtilities.openType("extension");
|
||||
Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, true);
|
||||
let warning_node = get_list_view_warning_node();
|
||||
is_element_visible(warning_node, "Warning message should be visible");
|
||||
is(
|
||||
warning_node.textContent,
|
||||
"Test add-on is incompatible with " + gApp + " " + gVersion + ".",
|
||||
"Warning message should be correct"
|
||||
);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
open_details("addon1@tests.mozilla.org", "extension", function() {
|
||||
let warning_node = get_detail_view_warning_node(gManagerWindow);
|
||||
is_element_visible(warning_node, "Warning message should be visible");
|
||||
is(
|
||||
warning_node.textContent,
|
||||
"Test add-on is incompatible with " + gApp + " " + gVersion + ".",
|
||||
"Warning message should be correct"
|
||||
);
|
||||
Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Check with compatibility checking disabled
|
||||
add_test(async function() {
|
||||
await gCategoryUtilities.openType("extension");
|
||||
let warning_node = get_list_view_warning_node();
|
||||
is_element_visible(warning_node, "Warning message should be visible");
|
||||
is(
|
||||
warning_node.textContent,
|
||||
"Test add-on is known to cause security or stability issues.",
|
||||
"Warning message should be correct"
|
||||
);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
open_details("addon1@tests.mozilla.org", "extension", function() {
|
||||
let warning_node = get_detail_view_warning_node(gManagerWindow);
|
||||
is_element_visible(warning_node, "Warning message should be visible");
|
||||
is(
|
||||
warning_node.textContent,
|
||||
"Test add-on is known to cause security or stability issues.",
|
||||
"Warning message should be correct"
|
||||
);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
@ -1,171 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Test that the empty notice in the list view disappears as it should
|
||||
|
||||
// Don't use a standard list view (e.g. "extension") to ensure that the list is
|
||||
// initially empty. Don't need to worry about the list of categories displayed
|
||||
// since only the list view itself is tested.
|
||||
var VIEW_ID = "addons://list/mock-addon";
|
||||
|
||||
var LIST_ID = "addon-list";
|
||||
var EMPTY_ID = "addon-list-empty";
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
var gItem;
|
||||
|
||||
var gInstallProperties = {
|
||||
name: "Bug 591663 Mock Install",
|
||||
type: "mock-addon",
|
||||
};
|
||||
var gAddonProperties = {
|
||||
id: "test1@tests.mozilla.org",
|
||||
name: "Bug 591663 Mock Add-on",
|
||||
type: "mock-addon",
|
||||
};
|
||||
var gExtensionProperties = {
|
||||
name: "Bug 591663 Extension Install",
|
||||
type: "extension",
|
||||
};
|
||||
|
||||
// Not implemented yet on HTML about:addons (Bug 1550911).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider(true, [
|
||||
{
|
||||
id: "mock-addon",
|
||||
name: "Mock Add-ons",
|
||||
uiPriority: 4500,
|
||||
flags: AddonManager.TYPE_UI_VIEW_LIST,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager(VIEW_ID);
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, finish);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the list view is as expected
|
||||
*
|
||||
* @param aItem
|
||||
* The expected item in the list, or null if list should be empty
|
||||
*/
|
||||
function check_list(aItem) {
|
||||
// Check state of the empty notice
|
||||
let emptyNotice = gManagerWindow.document.getElementById(EMPTY_ID);
|
||||
ok(emptyNotice != null, "Should have found the empty notice");
|
||||
is(
|
||||
!emptyNotice.hidden,
|
||||
aItem == null,
|
||||
"Empty notice should be showing if list empty"
|
||||
);
|
||||
|
||||
// Check the children of the list
|
||||
let list = gManagerWindow.document.getElementById(LIST_ID);
|
||||
is(
|
||||
list.childNodes.length,
|
||||
aItem ? 1 : 0,
|
||||
"Should get expected number of items in list"
|
||||
);
|
||||
if (aItem != null) {
|
||||
let itemName = list.firstChild.getAttribute("name");
|
||||
is(itemName, aItem.name, "List item should have correct name");
|
||||
}
|
||||
}
|
||||
|
||||
// Test that the empty notice is showing and no items are showing in list
|
||||
add_test(function() {
|
||||
check_list(null);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Test that a new, non-active, install does not affect the list view
|
||||
add_test(function() {
|
||||
gItem = gProvider.createInstalls([gInstallProperties])[0];
|
||||
check_list(null);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Test that onInstallStarted properly hides empty notice and adds install to list
|
||||
add_test(function() {
|
||||
gItem.addTestListener({
|
||||
onDownloadStarted() {
|
||||
// Install type unknown until download complete
|
||||
check_list(null);
|
||||
},
|
||||
onInstallStarted() {
|
||||
check_list(gItem);
|
||||
},
|
||||
onInstallEnded() {
|
||||
check_list(gItem);
|
||||
run_next_test();
|
||||
},
|
||||
});
|
||||
|
||||
gItem.install();
|
||||
});
|
||||
|
||||
// Test that restarting the manager does not change list
|
||||
add_test(async function() {
|
||||
let aManagerWindow = await restart_manager(gManagerWindow, VIEW_ID);
|
||||
gManagerWindow = aManagerWindow;
|
||||
check_list(gItem);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Test that onInstallCancelled removes install and shows empty notice
|
||||
add_test(function() {
|
||||
gItem.cancel();
|
||||
gItem = null;
|
||||
check_list(null);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Test that add-ons of a different type do not show up in the list view
|
||||
add_test(function() {
|
||||
let extension = gProvider.createInstalls([gExtensionProperties])[0];
|
||||
check_list(null);
|
||||
|
||||
extension.addTestListener({
|
||||
onDownloadStarted() {
|
||||
check_list(null);
|
||||
},
|
||||
onInstallStarted() {
|
||||
check_list(null);
|
||||
},
|
||||
onInstallEnded() {
|
||||
check_list(null);
|
||||
extension.cancel();
|
||||
run_next_test();
|
||||
},
|
||||
});
|
||||
|
||||
extension.install();
|
||||
});
|
||||
|
||||
// Test that onExternalInstall properly hides empty notice and adds install to list
|
||||
add_test(function() {
|
||||
gItem = gProvider.createAddons([gAddonProperties])[0];
|
||||
check_list(gItem);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Test that restarting the manager does not change list
|
||||
add_test(async function() {
|
||||
let aManagerWindow = await restart_manager(gManagerWindow, VIEW_ID);
|
||||
gManagerWindow = aManagerWindow;
|
||||
check_list(gItem);
|
||||
run_next_test();
|
||||
});
|
@ -1,58 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Bug 608316 - Test that opening the manager to an add-on that doesn't exist
|
||||
// just loads the default view
|
||||
|
||||
var gCategoryUtilities;
|
||||
|
||||
// Not implemented yet on HTML about:addons (Bug 1552184), once supported
|
||||
// this test case will be included in the HTML about:addons test files.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
finish();
|
||||
}
|
||||
|
||||
add_test(async function() {
|
||||
let aManager = await open_manager("addons://detail/foo");
|
||||
gCategoryUtilities = new CategoryUtilities(aManager);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should fall back to the discovery pane"
|
||||
);
|
||||
|
||||
close_manager(aManager, run_next_test);
|
||||
});
|
||||
|
||||
// Also test that opening directly to an add-on that does exist doesn't break
|
||||
// and selects the right category
|
||||
add_test(async function() {
|
||||
new MockProvider().createAddons([
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "addon 1",
|
||||
version: "1.0",
|
||||
},
|
||||
]);
|
||||
|
||||
let aManager = await open_manager("addons://detail/addon1@tests.mozilla.org");
|
||||
gCategoryUtilities = new CategoryUtilities(aManager);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should have selected the right category"
|
||||
);
|
||||
|
||||
close_manager(aManager, run_next_test);
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -12,12 +12,8 @@ var gProvider;
|
||||
|
||||
var gLoadCompleteCallback = null;
|
||||
|
||||
// This test file is testing the old XUL disco pane.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
],
|
||||
set: [["extensions.htmlaboutaddons.discover.enabled", false]],
|
||||
});
|
||||
|
||||
var gProgressListener = {
|
||||
@ -653,22 +649,6 @@ async function bug_601442_test_elements(visible) {
|
||||
"Discover category should not be visible"
|
||||
);
|
||||
}
|
||||
|
||||
gManagerWindow.loadView("addons://list/dictionary");
|
||||
let aManager = await wait_for_view_load(gManagerWindow);
|
||||
var button = aManager.document.getElementById("discover-button-install");
|
||||
if (visible) {
|
||||
ok(
|
||||
!BrowserTestUtils.is_hidden(button),
|
||||
"Discover button should be visible!"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
BrowserTestUtils.is_hidden(button),
|
||||
"Discover button should not be visible!"
|
||||
);
|
||||
}
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
}
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { ClientID } = ChromeUtils.import("resource://gre/modules/ClientID.jsm");
|
||||
|
||||
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons is tested in
|
||||
// browser_html_discover_view_clientid.js).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
],
|
||||
});
|
||||
|
||||
function waitForHeader() {
|
||||
return new Promise(resolve => {
|
||||
let observer = (subject, topic, state) => {
|
||||
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (channel.URI.spec != MAIN_URL) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
resolve(channel.getRequestHeader("Moz-Client-Id"));
|
||||
} catch (e) {
|
||||
if (e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
|
||||
// The header was not set.
|
||||
resolve(null);
|
||||
}
|
||||
} finally {
|
||||
Services.obs.removeObserver(observer, "http-on-modify-request");
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, "http-on-modify-request");
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[PREF_DISCOVERURL, MAIN_URL],
|
||||
["datareporting.healthreport.uploadEnabled", true],
|
||||
["browser.discovery.enabled", true],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_no_private_clientid() {
|
||||
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
});
|
||||
let [header, manager] = await Promise.all([
|
||||
waitForHeader(),
|
||||
open_manager(
|
||||
"addons://discover/",
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
privateWindow
|
||||
),
|
||||
]);
|
||||
ok(PrivateBrowsingUtils.isContentWindowPrivate(manager), "window is private");
|
||||
is(header, null, "header was not set");
|
||||
await close_manager(manager);
|
||||
await BrowserTestUtils.closeWindow(privateWindow);
|
||||
});
|
||||
|
||||
add_task(async function test_clientid() {
|
||||
let clientId = await ClientID.getClientIdHash();
|
||||
ok(!!clientId, "clientId is avialable");
|
||||
let [header, manager] = await Promise.all([
|
||||
waitForHeader(),
|
||||
open_manager("addons://discover/"),
|
||||
]);
|
||||
is(header, clientId, "header was set");
|
||||
await close_manager(manager);
|
||||
});
|
@ -75,11 +75,8 @@ async function checkInstallConfirmation(...names) {
|
||||
}
|
||||
|
||||
function getViewContainer(gManagerWindow) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return gManagerWindow.document.getElementById("category-box");
|
||||
}
|
||||
return gManagerWindow.document.getElementById("view-port");
|
||||
}
|
||||
|
||||
// Simulates dropping a URL onto the manager
|
||||
add_task(async function test_drop_url() {
|
||||
|
@ -14,7 +14,6 @@ AddonTestUtils.initMochitest(this);
|
||||
|
||||
function assertDisabledSideloadedExtensionElement(managerWindow, addonElement) {
|
||||
const doc = addonElement.ownerDocument;
|
||||
if (managerWindow.useHtmlViews) {
|
||||
const toggleDisabled = addonElement.querySelector(
|
||||
'[action="toggle-disabled"]'
|
||||
);
|
||||
@ -23,25 +22,10 @@ function assertDisabledSideloadedExtensionElement(managerWindow, addonElement) {
|
||||
"enable-addon-button",
|
||||
"Addon toggle-disabled action has the enable label"
|
||||
);
|
||||
} else {
|
||||
let el = doc.getAnonymousElementByAttribute(
|
||||
addonElement,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Disable button not visible.");
|
||||
el = doc.getAnonymousElementByAttribute(
|
||||
addonElement,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
is_element_visible(el, "Enable button visible");
|
||||
}
|
||||
}
|
||||
|
||||
function assertEnabledSideloadedExtensionElement(managerWindow, addonElement) {
|
||||
const doc = addonElement.ownerDocument;
|
||||
if (managerWindow.useHtmlViews) {
|
||||
const toggleDisabled = addonElement.querySelector(
|
||||
'[action="toggle-disabled"]'
|
||||
);
|
||||
@ -50,38 +34,14 @@ function assertEnabledSideloadedExtensionElement(managerWindow, addonElement) {
|
||||
"enable-addon-button",
|
||||
"Addon toggle-disabled action has the enable label"
|
||||
);
|
||||
} else {
|
||||
let el = doc.getAnonymousElementByAttribute(
|
||||
addonElement,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Disable button not visible.");
|
||||
el = doc.getAnonymousElementByAttribute(
|
||||
addonElement,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
is_element_visible(el, "Enable button visible");
|
||||
}
|
||||
}
|
||||
|
||||
function clickEnableExtension(managerWindow, addonElement) {
|
||||
if (managerWindow.useHtmlViews) {
|
||||
addonElement.querySelector('[action="toggle-disabled"]').click();
|
||||
} else {
|
||||
const doc = addonElement.ownerDocument;
|
||||
const el = doc.getAnonymousElementByAttribute(
|
||||
addonElement,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(el, { clickCount: 1 }, managerWindow);
|
||||
}
|
||||
}
|
||||
|
||||
// Loading extension by sideloading method
|
||||
async function test_sideloaded_extension_permissions_prompt() {
|
||||
add_task(async function test_sideloaded_extension_permissions_prompt() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["xpinstall.signatures.required", false],
|
||||
@ -164,20 +124,4 @@ async function test_sideloaded_extension_permissions_prompt() {
|
||||
|
||||
await close_manager(manager);
|
||||
await addon.uninstall();
|
||||
}
|
||||
|
||||
add_task(async function test_XUL_aboutaddons_sideloaded_permissions_prompt() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await test_sideloaded_extension_permissions_prompt();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_HTML_aboutaddons_sideloaded_permissions_prompt() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await test_sideloaded_extension_permissions_prompt();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
@ -7,20 +7,15 @@
|
||||
async function loadDetail(aWindow, id) {
|
||||
let loaded = wait_for_view_load(aWindow, undefined, true);
|
||||
// Check the detail view.
|
||||
if (aWindow.useHtmlViews) {
|
||||
let browser = await aWindow.getHtmlBrowser();
|
||||
let card = browser.contentDocument.querySelector(
|
||||
`addon-card[addon-id="${id}"]`
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(card, {}, browser.contentWindow);
|
||||
} else {
|
||||
let card = aWindow.document.querySelector(`.addon.card[value="${id}"]`);
|
||||
EventUtils.synthesizeMouseAtCenter(card, {}, aWindow);
|
||||
}
|
||||
await loaded;
|
||||
}
|
||||
|
||||
async function checkCompatibility(hboxSelector, buttonSelector) {
|
||||
add_task(async function checkCompatibility() {
|
||||
info("Testing compatibility checking warning");
|
||||
|
||||
info("Setting checkCompatibility to false");
|
||||
@ -34,8 +29,12 @@ async function checkCompatibility(hboxSelector, buttonSelector) {
|
||||
await extension.startup();
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
let hbox = aWindow.document.querySelector(hboxSelector);
|
||||
let button = aWindow.document.querySelector(buttonSelector);
|
||||
let hbox = aWindow.document.querySelector(
|
||||
"#html-view .global-warning-checkcompatibility"
|
||||
);
|
||||
let button = aWindow.document.querySelector(
|
||||
"#html-view .global-warning-checkcompatibility button"
|
||||
);
|
||||
|
||||
function checkMessage(visible) {
|
||||
if (visible) {
|
||||
@ -86,9 +85,9 @@ async function checkCompatibility(hboxSelector, buttonSelector) {
|
||||
|
||||
await close_manager(aWindow);
|
||||
await extension.unload();
|
||||
}
|
||||
});
|
||||
|
||||
async function checkSecurity(hboxSelector, buttonSelector) {
|
||||
add_task(async function checkSecurity() {
|
||||
info("Testing update security checking warning");
|
||||
|
||||
var pref = "extensions.checkUpdateSecurity";
|
||||
@ -103,8 +102,12 @@ async function checkSecurity(hboxSelector, buttonSelector) {
|
||||
await extension.startup();
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
let hbox = aWindow.document.querySelector(hboxSelector);
|
||||
let button = aWindow.document.querySelector(buttonSelector);
|
||||
let hbox = aWindow.document.querySelector(
|
||||
"#html-view .global-warning-updatesecurity"
|
||||
);
|
||||
let button = aWindow.document.querySelector(
|
||||
"#html-view .global-warning-updatesecurity button"
|
||||
);
|
||||
|
||||
function checkMessage(visible) {
|
||||
if (visible) {
|
||||
@ -155,9 +158,9 @@ async function checkSecurity(hboxSelector, buttonSelector) {
|
||||
|
||||
await close_manager(aWindow);
|
||||
await extension.unload();
|
||||
}
|
||||
});
|
||||
|
||||
async function checkSafeMode(hboxSelector) {
|
||||
add_task(async function checkSafeMode() {
|
||||
info("Testing safe mode warning");
|
||||
|
||||
let id = "test-safemode@mochi.test";
|
||||
@ -168,7 +171,9 @@ async function checkSafeMode(hboxSelector) {
|
||||
await extension.startup();
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
let hbox = aWindow.document.querySelector(hboxSelector);
|
||||
let hbox = aWindow.document.querySelector(
|
||||
"#html-view .global-warning-safemode"
|
||||
);
|
||||
|
||||
function checkMessage(visible) {
|
||||
if (visible) {
|
||||
@ -202,64 +207,4 @@ async function checkSafeMode(hboxSelector) {
|
||||
|
||||
await close_manager(aWindow);
|
||||
await extension.unload();
|
||||
}
|
||||
|
||||
add_task(async function testCompatCheckXUL() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await checkCompatibility(
|
||||
"#list-view hbox.global-warning-checkcompatibility",
|
||||
"#list-view button.global-warning-checkcompatibility"
|
||||
);
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function testCompatCheckHTML() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await checkCompatibility(
|
||||
"#html-view .global-warning-checkcompatibility",
|
||||
"#html-view .global-warning-checkcompatibility button"
|
||||
);
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function testSecurityCheckXUL() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await checkSecurity(
|
||||
"#list-view hbox.global-warning-updatesecurity",
|
||||
"#list-view button.global-warning-updatesecurity"
|
||||
);
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function testSecurityCheckHTML() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await checkSecurity(
|
||||
"#html-view .global-warning-updatesecurity",
|
||||
"#html-view .global-warning-updatesecurity button"
|
||||
);
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function testSafeModeXUL() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await checkSafeMode("#list-view hbox.global-warning-safemode");
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function testSafeModeHTML() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await checkSafeMode("#html-view .global-warning-safemode");
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
@ -55,19 +55,11 @@ MockGMPInstallManager.prototype = {
|
||||
|
||||
function openDetailsView(aId) {
|
||||
let view = get_current_view(gManagerWindow);
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
Assert.equal(
|
||||
view.id,
|
||||
"html-view",
|
||||
"Should be in the list view to use this function"
|
||||
);
|
||||
} else {
|
||||
Assert.equal(
|
||||
view.id,
|
||||
"list-view",
|
||||
"Should be in the list view to use this function"
|
||||
);
|
||||
}
|
||||
|
||||
let item = get_addon_element(gManagerWindow, aId);
|
||||
Assert.ok(item, "Should have got add-on element.");
|
||||
@ -82,11 +74,7 @@ function openDetailsView(aId) {
|
||||
});
|
||||
}
|
||||
|
||||
async function initializeState({ useHtmlViews }) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", useHtmlViews]],
|
||||
});
|
||||
|
||||
async function initializeState() {
|
||||
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
|
||||
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
|
||||
|
||||
@ -163,7 +151,6 @@ async function testNotInstalledDisabled() {
|
||||
for (let addon of gMockAddons) {
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
Assert.ok(item, "Got add-on element:" + addon.id);
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
is(item.parentNode.getAttribute("section"), "1", "Should be disabled");
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = item.querySelector("plugin-options");
|
||||
@ -176,53 +163,6 @@ async function testNotInstalledDisabled() {
|
||||
"Plugin state should be never-activate"
|
||||
);
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
} else {
|
||||
item.parentNode.ensureElementIsVisible(item);
|
||||
is(item.getAttribute("active"), "false", "Should be disabled");
|
||||
|
||||
let el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning"
|
||||
);
|
||||
is_element_hidden(el, "Warning notification is hidden.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"class",
|
||||
"disabled-postfix"
|
||||
);
|
||||
is_element_visible(el, "disabled-postfix is visible.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Disable button not visible.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Enable button not visible.");
|
||||
|
||||
let menu = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"state-menulist"
|
||||
);
|
||||
is_element_visible(menu, "State menu should be visible.");
|
||||
|
||||
let neverActivate = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"never-activate-menuitem"
|
||||
);
|
||||
is(
|
||||
menu.selectedItem,
|
||||
neverActivate,
|
||||
"Plugin state should be never-activate."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +191,7 @@ async function testNotInstalled() {
|
||||
);
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
Assert.ok(item, "Got add-on element:" + addon.id);
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
|
||||
is(item.parentNode.getAttribute("section"), "0", "Should be enabled");
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = item.querySelector("plugin-options");
|
||||
@ -264,74 +204,18 @@ async function testNotInstalled() {
|
||||
"Plugin state should be always-activate"
|
||||
);
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
} else {
|
||||
item.parentNode.ensureElementIsVisible(item);
|
||||
is(item.getAttribute("active"), "true");
|
||||
|
||||
let el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning"
|
||||
);
|
||||
is_element_visible(el, "Warning notification is visible.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"class",
|
||||
"disabled-postfix"
|
||||
);
|
||||
is_element_hidden(el, "disabled-postfix is hidden.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Disable button not visible.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Enable button not visible.");
|
||||
|
||||
let menu = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"state-menulist"
|
||||
);
|
||||
is_element_visible(menu, "State menu should be visible.");
|
||||
|
||||
let alwaysActivate = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"always-activate-menuitem"
|
||||
);
|
||||
is(
|
||||
menu.selectedItem,
|
||||
alwaysActivate,
|
||||
"Plugin state should be always-activate."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function testNotInstalledDetails() {
|
||||
for (let addon of gMockAddons) {
|
||||
await openDetailsView(addon.id);
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
|
||||
const addonCard = get_addon_element(gManagerWindow, addon.id);
|
||||
let el = addonCard.querySelector("[action=update-check]");
|
||||
is_element_visible(el, "Check for Updates action is visible");
|
||||
// TODO: add assertion for the warning notification once implemented
|
||||
// as part of Bug 1544950.
|
||||
} else {
|
||||
let doc = gManagerWindow.document;
|
||||
let el = doc.getElementsByClassName("disabled-postfix")[0];
|
||||
is_element_hidden(el, "disabled-postfix is hidden.");
|
||||
el = doc.getElementById("detail-findUpdates-btn");
|
||||
is_element_visible(el, "Find updates link is visible.");
|
||||
el = doc.getElementById("detail-warning");
|
||||
is_element_visible(el, "Warning notification is visible.");
|
||||
}
|
||||
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
}
|
||||
@ -354,7 +238,7 @@ async function testInstalled() {
|
||||
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
Assert.ok(item, "Got add-on element.");
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
|
||||
is(item.parentNode.getAttribute("section"), "0", "Should be enabled");
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = item.querySelector("plugin-options");
|
||||
@ -367,53 +251,6 @@ async function testInstalled() {
|
||||
"Plugin state should be always-activate"
|
||||
);
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
} else {
|
||||
item.parentNode.ensureElementIsVisible(item);
|
||||
is(item.getAttribute("active"), "true");
|
||||
|
||||
let el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning"
|
||||
);
|
||||
is_element_hidden(el, "Warning notification is hidden.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"class",
|
||||
"disabled-postfix"
|
||||
);
|
||||
is_element_hidden(el, "disabled-postfix is hidden.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"disable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Disable button not visible.");
|
||||
el = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"enable-btn"
|
||||
);
|
||||
is_element_hidden(el, "Enable button not visible.");
|
||||
|
||||
let menu = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"state-menulist"
|
||||
);
|
||||
is_element_visible(menu, "State menu should be visible.");
|
||||
|
||||
let alwaysActivate = item.ownerDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"always-activate-menuitem"
|
||||
);
|
||||
is(
|
||||
menu.selectedItem,
|
||||
alwaysActivate,
|
||||
"Plugin state should be always-activate."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,44 +258,11 @@ async function testInstalledDetails() {
|
||||
for (let addon of gMockAddons) {
|
||||
await openDetailsView(addon.id);
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
let card = get_addon_element(gManagerWindow, addon.id);
|
||||
is_element_visible(
|
||||
card.querySelector("[action=update-check]"),
|
||||
"Find updates link is bisible"
|
||||
);
|
||||
} else {
|
||||
let doc = gManagerWindow.document;
|
||||
|
||||
let el = doc.getElementsByClassName("disabled-postfix")[0];
|
||||
is_element_hidden(el, "disabled-postfix is hidden.");
|
||||
el = doc.getElementById("detail-findUpdates-btn");
|
||||
is_element_visible(el, "Find updates link is visible.");
|
||||
el = doc.getElementById("detail-warning");
|
||||
is_element_hidden(el, "Warning notification is hidden.");
|
||||
el = doc.getElementsByTagName("setting")[0];
|
||||
|
||||
let contextMenu = doc.getElementById("addonitem-popup");
|
||||
await new Promise(resolve => {
|
||||
let listener = () => {
|
||||
contextMenu.removeEventListener("popupshown", listener);
|
||||
resolve();
|
||||
};
|
||||
contextMenu.addEventListener("popupshown", listener);
|
||||
el = doc.getElementsByClassName("detail-view-container")[0];
|
||||
EventUtils.synthesizeMouse(el, 4, 4, {}, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(
|
||||
el,
|
||||
4,
|
||||
4,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
gManagerWindow
|
||||
);
|
||||
});
|
||||
let menuSep = doc.getElementById("addonitem-menuseparator");
|
||||
is_element_hidden(menuSep, "Menu separator is hidden.");
|
||||
contextMenu.hidePopup();
|
||||
}
|
||||
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
}
|
||||
@ -469,7 +273,6 @@ async function testInstalledGlobalEmeDisabled() {
|
||||
for (let addon of gMockAddons) {
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
if (addon.isEME) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
is(item.parentNode.getAttribute("section"), "1", "Should be disabled");
|
||||
// Open the options menu (needed to check the disabled buttons).
|
||||
const pluginOptions = item.querySelector("plugin-options");
|
||||
@ -482,9 +285,6 @@ async function testInstalledGlobalEmeDisabled() {
|
||||
"ask-to-activate should be disabled"
|
||||
);
|
||||
pluginOptions.querySelector("panel-list").open = false;
|
||||
} else {
|
||||
Assert.ok(!item, "Couldn't get add-on element.");
|
||||
}
|
||||
} else {
|
||||
Assert.ok(item, "Got add-on element.");
|
||||
}
|
||||
@ -520,10 +320,8 @@ async function testPreferencesButton() {
|
||||
);
|
||||
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
let doc = gManagerWindow.document;
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
// Open the options menu (needed to check the more options action is enabled).
|
||||
const pluginOptions = item.querySelector("plugin-options");
|
||||
pluginOptions.querySelector("panel-list").open = true;
|
||||
@ -535,19 +333,6 @@ async function testPreferencesButton() {
|
||||
"more options action should be enabled"
|
||||
);
|
||||
moreOptions.click();
|
||||
} else {
|
||||
let button = doc.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is_element_visible(button);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
button,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
}
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
}
|
||||
@ -567,38 +352,15 @@ async function testUpdateButton() {
|
||||
|
||||
for (let addon of gMockAddons) {
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
let doc = gManagerWindow.document;
|
||||
let item = get_addon_element(gManagerWindow, addon.id);
|
||||
|
||||
gInstalledAddonId = "";
|
||||
gInstallDeferred = Promise.defer();
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
item.querySelector("[action=expand]").click();
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
let detail = get_addon_element(gManagerWindow, addon.id);
|
||||
detail.querySelector("[action=update-check]").click();
|
||||
} else {
|
||||
let button = doc.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
button,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
|
||||
button = doc.getElementById("detail-findUpdates-btn");
|
||||
Assert.ok(button != null, "Got detail-findUpdates-btn");
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
button,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
}
|
||||
|
||||
await gInstallDeferred.promise;
|
||||
Assert.equal(gInstalledAddonId, addon.id);
|
||||
@ -672,8 +434,8 @@ async function testCleanupState() {
|
||||
// This function run the sequence of all the gmpProvider tests
|
||||
// under the same initializeStateOptions (which will enable or disable
|
||||
// the HTML about:addons views).
|
||||
async function test_gmpProvider(initializeStateOptions) {
|
||||
await initializeState(initializeStateOptions);
|
||||
add_task(async function test_gmpProvider(initializeStateOptions) {
|
||||
await initializeState();
|
||||
await testNotInstalledDisabled();
|
||||
await testNotInstalledDisabledDetails();
|
||||
await testNotInstalled();
|
||||
@ -685,12 +447,4 @@ async function test_gmpProvider(initializeStateOptions) {
|
||||
await testUpdateButton();
|
||||
await testEmeSupport();
|
||||
await testCleanupState();
|
||||
}
|
||||
|
||||
add_task(function test_gmpProvider_on_XUL_aboutaddons() {
|
||||
return test_gmpProvider({ useHtmlViews: false });
|
||||
});
|
||||
|
||||
add_task(async function test_gmpProvider_on_HTML_aboutaddons() {
|
||||
return test_gmpProvider({ useHtmlViews: true });
|
||||
});
|
||||
|
@ -19,7 +19,6 @@ const { AddonTestUtils } = ChromeUtils.import(
|
||||
AddonTestUtils.initMochitest(this);
|
||||
|
||||
const MAIN_URL = `https://example.com/${RELATIVE_DIR}discovery.html`;
|
||||
const SECOND_URL = `https://example.com/${RELATIVE_DIR}releaseNotes.xhtml`;
|
||||
const DISCOAPI_URL = `http://example.com/${RELATIVE_DIR}/discovery/api_response_empty.json`;
|
||||
|
||||
// Clearing this pref is currently done from a cleanup function registered
|
||||
@ -46,67 +45,6 @@ gProvider.createAddons([
|
||||
},
|
||||
]);
|
||||
|
||||
var gLoadCompleteCallback = null;
|
||||
|
||||
var gProgressListener = {
|
||||
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
// Only care about the network stop status events
|
||||
if (
|
||||
!(aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) ||
|
||||
!(aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gLoadCompleteCallback) {
|
||||
executeSoon(gLoadCompleteCallback);
|
||||
}
|
||||
gLoadCompleteCallback = null;
|
||||
},
|
||||
|
||||
onLocationChange() {},
|
||||
onSecurityChange() {},
|
||||
onProgressChange() {},
|
||||
onStatusChange() {},
|
||||
onContentBlockingEvent() {},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
};
|
||||
|
||||
function waitForLoad(aManager, aCallback) {
|
||||
let promise = new Promise(resolve => {
|
||||
var browser = aManager.document.getElementById("discover-browser");
|
||||
browser.addProgressListener(gProgressListener);
|
||||
|
||||
gLoadCompleteCallback = function() {
|
||||
browser.removeProgressListener(gProgressListener);
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
if (aCallback) {
|
||||
promise.then(aCallback);
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
function clickLink(aManager, aId, aCallback) {
|
||||
let promise = new Promise(async resolve => {
|
||||
waitForLoad(aManager, resolve);
|
||||
|
||||
var browser = aManager.document.getElementById("discover-browser");
|
||||
|
||||
var link = browser.contentDocument.getElementById(aId);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, link);
|
||||
});
|
||||
if (aCallback) {
|
||||
promise.then(aCallback);
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
function go_back() {
|
||||
gBrowser.goBack();
|
||||
}
|
||||
@ -137,24 +75,16 @@ function is_in_list(aManager, view, canGoBack, canGoForward) {
|
||||
"Should be on the right category"
|
||||
);
|
||||
|
||||
if (aManager.useHtmlViews) {
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"html-view",
|
||||
"the current view should be set to the HTML about:addons browser"
|
||||
);
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
doc = aManager.getHtmlBrowser().contentDocument;
|
||||
ok(
|
||||
doc.querySelector("addon-list"),
|
||||
"Got a list-view in the HTML about:addons browser"
|
||||
);
|
||||
} else {
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"list-view",
|
||||
"Should be on the right view"
|
||||
);
|
||||
}
|
||||
|
||||
check_state(canGoBack, canGoForward);
|
||||
}
|
||||
@ -168,25 +98,17 @@ function is_in_detail(aManager, view, canGoBack, canGoForward) {
|
||||
"Should be on the right category"
|
||||
);
|
||||
|
||||
if (aManager.useHtmlViews) {
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"html-view",
|
||||
"the current view should be set to the HTML about:addons browser"
|
||||
);
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
doc = aManager.getHtmlBrowser().contentDocument;
|
||||
is(
|
||||
doc.querySelectorAll("addon-card").length,
|
||||
1,
|
||||
"Got a detail-view in the HTML about:addons browser"
|
||||
);
|
||||
} else {
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"detail-view",
|
||||
"Should be on the right view"
|
||||
);
|
||||
}
|
||||
|
||||
check_state(canGoBack, canGoForward);
|
||||
}
|
||||
@ -228,13 +150,7 @@ function is_in_discovery(aManager, url, canGoBack, canGoForward) {
|
||||
|
||||
async function expand_addon_element(aManager, aId) {
|
||||
var addon = get_addon_element(aManager, aId);
|
||||
if (aManager.useHtmlViews) {
|
||||
addon.click();
|
||||
} else {
|
||||
addon.parentNode.ensureElementIsVisible(addon);
|
||||
EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager);
|
||||
EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager);
|
||||
}
|
||||
}
|
||||
|
||||
function wait_for_page_show(browser) {
|
||||
@ -257,34 +173,9 @@ function wait_for_page_show(browser) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function runTestOnPrefEnvs(prefEnvs, testFn) {
|
||||
for (const [message, prefEnv] of prefEnvs) {
|
||||
info(`${message}: ${JSON.stringify(prefEnv)}`);
|
||||
await SpecialPowers.pushPrefEnv(prefEnv);
|
||||
await testFn();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
}
|
||||
|
||||
// Tests simple forward and back navigation and that the right heading and
|
||||
// category is selected
|
||||
add_task(async function test_navigate_history() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/extension", false, false);
|
||||
@ -330,28 +221,10 @@ add_task(async function test_navigate_history() {
|
||||
is_in_list(aManager, "addons://list/extension", false, true);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that browsing to the add-ons manager from a website and going back works
|
||||
add_task(async function test_navigate_between_webpage_and_aboutaddons() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
info("Part 1");
|
||||
await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
@ -376,9 +249,7 @@ add_task(async function test_navigate_between_webpage_and_aboutaddons() {
|
||||
// the browser frame switching between remote/non-remote in e10s mode.
|
||||
let promiseLoaded;
|
||||
if (gMultiProcessBrowser) {
|
||||
promiseLoaded = BrowserTestUtils.browserLoaded(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
promiseLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
} else {
|
||||
promiseLoaded = BrowserTestUtils.waitForEvent(
|
||||
gBrowser.selectedBrowser,
|
||||
@ -407,8 +278,6 @@ add_task(async function test_navigate_between_webpage_and_aboutaddons() {
|
||||
is_in_list(manager, "addons://list/extension", true, false);
|
||||
|
||||
await close_manager(manager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests simple forward and back navigation and that the right heading and
|
||||
@ -421,22 +290,6 @@ add_task(async function test_keyboard_history_navigation() {
|
||||
return;
|
||||
}
|
||||
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/extension", false, false);
|
||||
@ -482,28 +335,10 @@ add_task(async function test_keyboard_history_navigation() {
|
||||
is_in_list(aManager, "addons://list/extension", false, true);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that opening a custom first view only stores a single history entry
|
||||
add_task(async function test_single_history_entry() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/plugin");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
@ -525,29 +360,11 @@ add_task(async function test_single_history_entry() {
|
||||
is_in_list(aManager, "addons://list/plugin", false, true);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that opening a view while the manager is already open adds a new
|
||||
// history entry
|
||||
add_task(async function test_new_history_entry_while_opened() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/extension", false, false);
|
||||
@ -571,35 +388,11 @@ add_task(async function test_new_history_entry_while_opened() {
|
||||
is_in_list(aManager, "addons://list/plugin", true, false);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests than navigating to a website and then going back returns to the
|
||||
// previous view
|
||||
add_task(async function test_navigate_back_from_website() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["security.allow_eval_with_system_principal", true],
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["security.allow_eval_with_system_principal", true],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/plugin");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
@ -660,28 +453,10 @@ add_task(async function test_navigate_back_from_website() {
|
||||
);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that refreshing a list view does not affect the history
|
||||
add_task(async function test_refresh_listview_donot_add_history_entries() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/extension", false, false);
|
||||
@ -719,28 +494,10 @@ add_task(async function test_refresh_listview_donot_add_history_entries() {
|
||||
});
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that refreshing a detail view does not affect the history
|
||||
add_task(async function test_refresh_detailview_donot_add_history_entries() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager(null);
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/extension", false, false);
|
||||
@ -774,29 +531,11 @@ add_task(async function test_refresh_detailview_donot_add_history_entries() {
|
||||
});
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that removing an extension from the detail view goes back and doesn't
|
||||
// allow you to go forward again.
|
||||
add_task(async function test_history_on_detailview_extension_removed() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/extension");
|
||||
|
||||
info("Part 1");
|
||||
@ -808,7 +547,6 @@ add_task(async function test_history_on_detailview_extension_removed() {
|
||||
info("Part 2");
|
||||
is_in_detail(aManager, "addons://list/extension", true, false);
|
||||
|
||||
if (aManager.useHtmlViews) {
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
const addonCard = doc.querySelector(
|
||||
'addon-card[addon-id="test1@tests.mozilla.org"]'
|
||||
@ -816,13 +554,6 @@ add_task(async function test_history_on_detailview_extension_removed() {
|
||||
const promptService = mockPromptService();
|
||||
promptService._response = 0;
|
||||
addonCard.querySelector("[action=remove]").click();
|
||||
} else {
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
aManager.document.getElementById("detail-uninstall-btn"),
|
||||
{},
|
||||
aManager
|
||||
);
|
||||
}
|
||||
|
||||
await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/extension", true, false);
|
||||
@ -831,28 +562,10 @@ add_task(async function test_history_on_detailview_extension_removed() {
|
||||
addon.cancelUninstall();
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that opening the manager opens the last view
|
||||
add_task(async function test_open_last_view() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/plugin");
|
||||
info("Part 1");
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
@ -863,68 +576,21 @@ add_task(async function test_open_last_view() {
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that navigating the discovery page works when that was the first view
|
||||
add_task(async function test_discopane_first_history_entry() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
["extensions.getAddons.discovery.api_url", DISCOAPI_URL],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
});
|
||||
|
||||
let aManager = await open_manager("addons://discover/");
|
||||
info("1");
|
||||
is_in_discovery(aManager, MAIN_URL, false, false);
|
||||
|
||||
let waitLoaded;
|
||||
const isLegacyDiscoPane = !Services.prefs.getBoolPref(
|
||||
"extensions.htmlaboutaddons.discover.enabled"
|
||||
);
|
||||
|
||||
if (isLegacyDiscoPane) {
|
||||
// This is a test for an old version of the discovery panel that was actually
|
||||
// navigating links, skip if using the HTML about:addons.
|
||||
await clickLink(aManager, "link-good");
|
||||
info("2");
|
||||
is_in_discovery(aManager, SECOND_URL, true, false);
|
||||
|
||||
waitLoaded = waitForLoad(aManager);
|
||||
// Execute go_back only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_back);
|
||||
info("3");
|
||||
await waitLoaded;
|
||||
is_in_discovery(aManager, MAIN_URL, false, true);
|
||||
|
||||
// Execute go_forward only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
waitLoaded = waitForLoad(aManager);
|
||||
executeSoon(go_forward);
|
||||
|
||||
await waitLoaded;
|
||||
is_in_discovery(aManager, SECOND_URL, true, false);
|
||||
}
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
aManager.document.getElementById("category-plugin"),
|
||||
{},
|
||||
@ -934,51 +600,16 @@ add_task(async function test_discopane_first_history_entry() {
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/plugin", true, false);
|
||||
|
||||
if (isLegacyDiscoPane) {
|
||||
go_back();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, true);
|
||||
|
||||
waitLoaded = waitForLoad(aManager);
|
||||
}
|
||||
|
||||
go_back();
|
||||
await waitLoaded;
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
|
||||
is_in_discovery(aManager, MAIN_URL, false, true);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that navigating the discovery page works when that was the second view
|
||||
add_task(async function test_discopane_second_history_entry() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
["extensions.getAddons.discovery.api_url", DISCOAPI_URL],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/plugin");
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
|
||||
@ -991,31 +622,6 @@ add_task(async function test_discopane_second_history_entry() {
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, false);
|
||||
|
||||
const isLegacyDiscoPane = !Services.prefs.getBoolPref(
|
||||
"extensions.htmlaboutaddons.discover.enabled"
|
||||
);
|
||||
|
||||
// This is a test for an old version of the discovery panel that was actually
|
||||
// navigating links.
|
||||
if (isLegacyDiscoPane) {
|
||||
await clickLink(aManager, "link-good");
|
||||
is_in_discovery(aManager, SECOND_URL, true, false);
|
||||
|
||||
// Execute go_back only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_back);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, true);
|
||||
|
||||
// Execute go_forward only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_forward);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, false);
|
||||
}
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
aManager.document.getElementById("category-plugin"),
|
||||
{},
|
||||
@ -1025,34 +631,6 @@ add_task(async function test_discopane_second_history_entry() {
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/plugin", true, false);
|
||||
|
||||
if (isLegacyDiscoPane) {
|
||||
go_back();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, true);
|
||||
|
||||
go_back();
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, true);
|
||||
|
||||
go_back();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/plugin", false, true);
|
||||
|
||||
go_forward();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, true);
|
||||
|
||||
// Execute go_forward only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_forward);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, true);
|
||||
} else {
|
||||
go_back();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
@ -1062,116 +640,11 @@ add_task(async function test_discopane_second_history_entry() {
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/plugin", false, true);
|
||||
}
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Tests that refreshing the discovery pane integrates properly with history
|
||||
add_task(async function test_legacy_discopane_history_navigation() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let aManager = await open_manager("addons://list/plugin");
|
||||
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
aManager.document.getElementById("category-discover"),
|
||||
{},
|
||||
aManager
|
||||
);
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, false);
|
||||
|
||||
await clickLink(aManager, "link-good");
|
||||
is_in_discovery(aManager, SECOND_URL, true, false);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
aManager.document.getElementById("category-discover"),
|
||||
{},
|
||||
aManager
|
||||
);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, false);
|
||||
|
||||
go_back();
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, true);
|
||||
|
||||
go_back();
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, true);
|
||||
|
||||
go_back();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_list(aManager, "addons://list/plugin", false, true);
|
||||
|
||||
go_forward();
|
||||
|
||||
aManager = await wait_for_view_load(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, true);
|
||||
|
||||
// Execute go_forward only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_forward);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, SECOND_URL, true, true);
|
||||
|
||||
// Execute go_forward only after waitForLoad() has had a chance to setup
|
||||
// its listeners.
|
||||
executeSoon(go_forward);
|
||||
|
||||
await waitForLoad(aManager);
|
||||
is_in_discovery(aManager, MAIN_URL, true, false);
|
||||
|
||||
await close_manager(aManager);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_initialSelectedView_on_aboutaddons_reload() {
|
||||
await runTestOnPrefEnvs(
|
||||
[
|
||||
[
|
||||
"Test on HTML about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
["extensions.getAddons.discovery.api_url", DISCOAPI_URL],
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
"Test on XUL about:addons",
|
||||
{
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
async () => {
|
||||
let managerWindow = await open_manager("addons://list/extension");
|
||||
ok(
|
||||
managerWindow.gViewController.initialViewSelected,
|
||||
@ -1186,13 +659,7 @@ add_task(async function test_initialSelectedView_on_aboutaddons_reload() {
|
||||
managerWindow.gViewController.initialViewSelected,
|
||||
"initialViewSelected is true as expected on first about:addons load"
|
||||
);
|
||||
is(
|
||||
managerWindow.gPendingInitializations,
|
||||
0,
|
||||
"No pending initializations"
|
||||
);
|
||||
is(managerWindow.gPendingInitializations, 0, "No pending initializations");
|
||||
|
||||
await close_manager(managerWindow);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -270,7 +270,6 @@ add_task(async function setup() {
|
||||
// Enable html about:addons and the abuse reporting.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.abuseReport.enabled", true],
|
||||
["extensions.abuseReport.url", "http://test.addons.org/api/report/"],
|
||||
],
|
||||
|
@ -107,10 +107,7 @@ async function hasPrivateAllowed(id) {
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.allowPrivateBrowsingByDefault", false],
|
||||
],
|
||||
set: [["extensions.allowPrivateBrowsingByDefault", false]],
|
||||
});
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
@ -289,8 +289,6 @@ add_task(async function setup() {
|
||||
"extensions.getAddons.discovery.api_url",
|
||||
`http://${AMO_TEST_HOST}/discoapi`,
|
||||
],
|
||||
// Enable HTML for all because some tests load non-discopane views.
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
// Disable non-discopane recommendations to avoid unexpected discovery
|
||||
// API requests.
|
||||
|
@ -48,7 +48,6 @@ add_task(async function setup() {
|
||||
["extensions.getAddons.discovery.api_url", `${serverBaseUrl}discoapi`],
|
||||
["app.support.baseURL", `${serverBaseUrl}sumo/`],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
// Discovery API requests can be triggered by the discopane and the
|
||||
// recommendations in the list view. To make sure that the every test
|
||||
// checks the behavior of the view they're testing, ensure that only one
|
||||
|
@ -35,9 +35,6 @@ function waitForThemeChange(list) {
|
||||
}
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
promptService = mockPromptService();
|
||||
Services.telemetry.clearEvents();
|
||||
});
|
||||
|
@ -41,7 +41,6 @@ add_task(async function setup() {
|
||||
set: [
|
||||
// Disable personalized recommendations, they will break the data URI.
|
||||
["browser.discovery.enabled", false],
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.getAddons.discovery.api_url", `data:;base64,${results}`],
|
||||
[
|
||||
"extensions.recommendations.themeRecommendationUrl",
|
||||
|
@ -33,14 +33,8 @@ function createMessageBar(messageBarStack, { attrs, children, onclose } = {}) {
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
htmlAboutAddonsWindow = await loadInitialView("extension");
|
||||
registerCleanupFunction(async () => {
|
||||
await closeView(htmlAboutAddonsWindow);
|
||||
});
|
||||
registerCleanupFunction(() => closeView(htmlAboutAddonsWindow));
|
||||
});
|
||||
|
||||
add_task(async function test_message_bar_stack() {
|
||||
|
@ -4,12 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
const DEFAULT_SECTION_NAMES = ["one", "two", "three"];
|
||||
|
||||
function makeButton({ doc, name, deckId }) {
|
||||
|
@ -27,10 +27,7 @@ function waitOptionsBrowserInserted() {
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.inline-options.enabled", true],
|
||||
],
|
||||
set: [["extensions.htmlaboutaddons.inline-options.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -6,10 +6,7 @@
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.inline-options.enabled", true],
|
||||
],
|
||||
set: [["extensions.htmlaboutaddons.inline-options.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -7,10 +7,6 @@
|
||||
const TEST_PLUGIN_DESCRIPTION = "Flash plug-in for testing purposes.";
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
let gProvider = new MockProvider();
|
||||
gProvider.createAddons([
|
||||
{
|
||||
|
@ -8,10 +8,6 @@ function dateHoursAgo(hours) {
|
||||
}
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
gProvider = new MockProvider();
|
||||
gProvider.createAddons([
|
||||
{
|
||||
|
@ -4,12 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
async function checkRecommendedBadge(id, hidden) {
|
||||
function checkBadge() {
|
||||
let card = win.document.querySelector(`addon-card[addon-id="${id}"]`);
|
||||
|
@ -6,10 +6,7 @@ const { AddonTestUtils } = ChromeUtils.import(
|
||||
|
||||
AddonTestUtils.initMochitest(this);
|
||||
|
||||
add_task(async function enableHtmlViews() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
add_task(async function setup() {
|
||||
Services.telemetry.clearEvents();
|
||||
});
|
||||
|
||||
|
@ -23,9 +23,6 @@ const SUPPORT_URL = Services.urlFormatter.formatURL(
|
||||
);
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
gProvider = new MockProvider();
|
||||
});
|
||||
|
||||
|
@ -1,274 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
||||
/* globals TestUtils */
|
||||
|
||||
let { ExtensionTestCommon } = ChromeUtils.import(
|
||||
"resource://testing-common/ExtensionTestCommon.jsm"
|
||||
);
|
||||
|
||||
ChromeUtils.import("resource://testing-common/ContentTask.jsm", {});
|
||||
|
||||
// This test is testing resizing of the inline options in XUL about:addons. The
|
||||
// behavior in HTML about:addons is checked in the testInlineOptions task of
|
||||
// browser_html_options_ui.js.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
var gAddon;
|
||||
var gOtherAddon;
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
||||
function installAddon(details) {
|
||||
let id = Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(Ci.nsIUUIDGenerator)
|
||||
.generateUUID().number;
|
||||
if (!details.manifest) {
|
||||
details.manifest = {};
|
||||
}
|
||||
details.manifest.applications = { gecko: { id } };
|
||||
let xpi = ExtensionTestCommon.generateXPI(details);
|
||||
|
||||
return AddonManager.installTemporaryAddon(xpi).then(addon => {
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
addon.uninstall();
|
||||
|
||||
Services.obs.notifyObservers(xpi, "flush-cache-entry");
|
||||
xpi.remove(false);
|
||||
});
|
||||
|
||||
return addon;
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
gAddon = await installAddon({
|
||||
manifest: {
|
||||
options_ui: {
|
||||
page: "options.html",
|
||||
},
|
||||
},
|
||||
|
||||
files: {
|
||||
"options.html": `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style type="text/css">
|
||||
body > p {
|
||||
height: 300px;
|
||||
margin: 0;
|
||||
}
|
||||
body.bigger > p {
|
||||
height: 600px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>The quick mauve fox jumps over the opalescent dog.</p>
|
||||
</body>
|
||||
</html>`,
|
||||
},
|
||||
});
|
||||
|
||||
// Create another add-on with no inline options, to verify that detail
|
||||
// view switches work correctly.
|
||||
gOtherAddon = await installAddon({});
|
||||
|
||||
gManagerWindow = await open_manager("addons://list/extension");
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
});
|
||||
|
||||
async function openDetailsBrowser(addonId) {
|
||||
var addon = get_addon_element(gManagerWindow, addonId);
|
||||
|
||||
is(
|
||||
addon.mAddon.optionsType,
|
||||
AddonManager.OPTIONS_TYPE_INLINE_BROWSER,
|
||||
"Options should be inline browser type"
|
||||
);
|
||||
|
||||
addon.parentNode.ensureElementIsVisible(addon);
|
||||
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
addon,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
|
||||
is_element_visible(button, "Preferences button should be visible");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
|
||||
await TestUtils.topicObserved(
|
||||
AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
|
||||
(subject, data) => data == addonId
|
||||
);
|
||||
|
||||
is(
|
||||
gManagerWindow.gViewController.currentViewId,
|
||||
`addons://detail/${encodeURIComponent(addonId)}/preferences`,
|
||||
"Current view should scroll to preferences"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.querySelector(
|
||||
"#detail-grid > rows > stack > .inline-options-browser"
|
||||
);
|
||||
var rows = browser.parentNode.parentNode;
|
||||
|
||||
let url = await ContentTask.spawn(browser, {}, () => content.location.href);
|
||||
|
||||
ok(browser, "Grid should have a browser descendant");
|
||||
is(browser.localName, "browser", "Grid should have a browser descendant");
|
||||
is(
|
||||
url,
|
||||
addon.mAddon.optionsURL,
|
||||
"Browser has the expected options URL loaded"
|
||||
);
|
||||
|
||||
is(
|
||||
browser.clientWidth,
|
||||
browser.parentNode.clientWidth,
|
||||
"Browser should be the same width as its direct parent"
|
||||
);
|
||||
is(
|
||||
browser.clientWidth,
|
||||
rows.clientWidth,
|
||||
"Browser should be the same width as its rows ancestor"
|
||||
);
|
||||
|
||||
button = gManagerWindow.document.getElementById("detail-prefs-btn");
|
||||
is_element_hidden(button, "Preferences button should not be visible");
|
||||
|
||||
return browser;
|
||||
}
|
||||
|
||||
add_task(async function test_inline_browser_addon() {
|
||||
let browser = await openDetailsBrowser(gAddon.id);
|
||||
|
||||
function checkHeights(expected) {
|
||||
let { clientHeight } = browser;
|
||||
return ContentTask.spawn(
|
||||
browser,
|
||||
{ expected, clientHeight },
|
||||
({ expected, clientHeight }) => {
|
||||
let { body } = content.document;
|
||||
|
||||
is(
|
||||
body.clientHeight,
|
||||
expected,
|
||||
`Document body should be ${expected}px tall`
|
||||
);
|
||||
is(
|
||||
body.clientHeight,
|
||||
body.scrollHeight,
|
||||
"Document body should be tall enough to fit its contents"
|
||||
);
|
||||
|
||||
let heightDiff = clientHeight - expected;
|
||||
ok(
|
||||
heightDiff >= 0 && heightDiff < 50,
|
||||
`Browser should be slightly taller than the document body (${clientHeight} vs. ${expected})`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Delay long enough to avoid hitting our resize rate limit.
|
||||
let delay = () => new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
await delay();
|
||||
|
||||
await checkHeights(300);
|
||||
|
||||
info(
|
||||
"Increase the document height, and expect the browser to grow correspondingly"
|
||||
);
|
||||
await ContentTask.spawn(browser, null, () => {
|
||||
content.document.body.classList.toggle("bigger");
|
||||
});
|
||||
|
||||
await delay();
|
||||
|
||||
await checkHeights(600);
|
||||
|
||||
info(
|
||||
"Decrease the document height, and expect the browser to shrink correspondingly"
|
||||
);
|
||||
await ContentTask.spawn(browser, null, () => {
|
||||
content.document.body.classList.toggle("bigger");
|
||||
});
|
||||
|
||||
await delay();
|
||||
|
||||
await checkHeights(300);
|
||||
|
||||
await new Promise(resolve =>
|
||||
gCategoryUtilities.openType("extension", resolve)
|
||||
);
|
||||
|
||||
browser = gManagerWindow.document.querySelector(".inline-options-browser");
|
||||
|
||||
is(browser, null, "Options browser should be removed from the document");
|
||||
});
|
||||
|
||||
// Test that loading an add-on with no inline browser works as expected
|
||||
// after having viewed our main test add-on.
|
||||
add_task(async function test_plain_addon() {
|
||||
var addon = get_addon_element(gManagerWindow, gOtherAddon.id);
|
||||
|
||||
is(addon.mAddon.optionsType, null, "Add-on should have no options");
|
||||
|
||||
addon.parentNode.ensureElementIsVisible(addon);
|
||||
|
||||
await EventUtils.synthesizeMouseAtCenter(
|
||||
addon,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, gManagerWindow);
|
||||
|
||||
await BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged");
|
||||
|
||||
is(
|
||||
gManagerWindow.gViewController.currentViewId,
|
||||
`addons://detail/${encodeURIComponent(gOtherAddon.id)}`,
|
||||
"Detail view should be open"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.querySelector(
|
||||
"#detail-grid > rows > .inline-options-browser"
|
||||
);
|
||||
|
||||
is(browser, null, "Detail view should have no inline browser");
|
||||
|
||||
await new Promise(resolve =>
|
||||
gCategoryUtilities.openType("extension", resolve)
|
||||
);
|
||||
});
|
||||
|
||||
// Test that loading the original add-on details successfully creates a
|
||||
// browser.
|
||||
add_task(async function test_inline_browser_addon_again() {
|
||||
let browser = await openDetailsBrowser(gAddon.id);
|
||||
|
||||
await new Promise(resolve =>
|
||||
gCategoryUtilities.openType("extension", resolve)
|
||||
);
|
||||
|
||||
browser = gManagerWindow.document.querySelector(".inline-options-browser");
|
||||
|
||||
is(browser, null, "Options browser should be removed from the document");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
await close_manager(gManagerWindow);
|
||||
|
||||
gManagerWindow = null;
|
||||
gCategoryUtilities = null;
|
||||
});
|
@ -213,7 +213,7 @@ function clickLinks(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
async function init(startPage, isHtmlViews) {
|
||||
async function init(startPage) {
|
||||
gManagerWindow = await open_manager(null);
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
@ -226,26 +226,20 @@ async function init(startPage, isHtmlViews) {
|
||||
|
||||
await gCategoryUtilities.openType(startPage);
|
||||
|
||||
if (isHtmlViews) {
|
||||
return gManagerWindow.document.getElementById("html-view-browser")
|
||||
.contentDocument;
|
||||
}
|
||||
return gManagerWindow.document;
|
||||
}
|
||||
|
||||
/* Test functions start here. */
|
||||
|
||||
async function setup(isHtmlViews) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", isHtmlViews]],
|
||||
});
|
||||
add_task(async function setup() {
|
||||
// Clear out any telemetry data that existed before this file is run.
|
||||
Services.telemetry.clearEvents();
|
||||
}
|
||||
});
|
||||
|
||||
async function testBasicViewTelemetry(isHtmlViews) {
|
||||
add_task(async function testBasicViewTelemetry() {
|
||||
let addons = await Promise.all([installTheme(), installExtension()]);
|
||||
let doc = await init("discover", isHtmlViews);
|
||||
let doc = await init("discover");
|
||||
|
||||
await gCategoryUtilities.openType("theme");
|
||||
openDetailView(doc, "theme@mochi.test");
|
||||
@ -278,12 +272,12 @@ async function testBasicViewTelemetry(isHtmlViews) {
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
await Promise.all(addons.map(addon => addon.unload()));
|
||||
}
|
||||
});
|
||||
|
||||
async function testExtensionEvents(isHtmlViews) {
|
||||
add_task(async function testExtensionEvents() {
|
||||
let addon = await installExtension();
|
||||
let type = "extension";
|
||||
let doc = await init("extension", isHtmlViews);
|
||||
let doc = await init("extension");
|
||||
|
||||
// Check/clear the current telemetry.
|
||||
assertTelemetryMatches(
|
||||
@ -315,7 +309,7 @@ async function testExtensionEvents(isHtmlViews) {
|
||||
|
||||
// Check remove/undo.
|
||||
await removeAddonAndUndo(doc, row);
|
||||
let uninstallValue = isHtmlViews ? "accepted" : null;
|
||||
let uninstallValue = "accepted";
|
||||
assertTelemetryMatches(
|
||||
[
|
||||
[
|
||||
@ -455,10 +449,10 @@ async function testExtensionEvents(isHtmlViews) {
|
||||
await close_manager(gManagerWindow);
|
||||
await addon.unload();
|
||||
await upgraded.unload();
|
||||
}
|
||||
});
|
||||
|
||||
async function testGeneralActions(isHtmlViews) {
|
||||
await init("extension", isHtmlViews);
|
||||
add_task(async function testGeneralActions() {
|
||||
await init("extension");
|
||||
|
||||
let doc = gManagerWindow.document;
|
||||
let menu = doc.getElementById("utils-menu");
|
||||
@ -550,12 +544,12 @@ async function testGeneralActions(isHtmlViews) {
|
||||
await close_manager(gManagerWindow);
|
||||
|
||||
assertTelemetryMatches([]);
|
||||
}
|
||||
});
|
||||
|
||||
async function testPreferencesLink(isHtmlViews) {
|
||||
add_task(async function testPreferencesLink() {
|
||||
assertTelemetryMatches([]);
|
||||
|
||||
await init("theme", isHtmlViews);
|
||||
await init("theme");
|
||||
|
||||
let doc = gManagerWindow.document;
|
||||
|
||||
@ -588,31 +582,4 @@ async function testPreferencesLink(isHtmlViews) {
|
||||
);
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
}
|
||||
|
||||
const testFns = [
|
||||
testBasicViewTelemetry,
|
||||
testExtensionEvents,
|
||||
testGeneralActions,
|
||||
testPreferencesLink,
|
||||
];
|
||||
|
||||
/**
|
||||
* Setup the tasks. This will add tasks for each of testFns to run with the
|
||||
* XUL and HTML version of about:addons.
|
||||
*
|
||||
* To add a test, add it to the testFns array.
|
||||
*/
|
||||
function addTestTasks(isHtmlViews) {
|
||||
add_task(() => setup(isHtmlViews));
|
||||
|
||||
for (let fn of testFns) {
|
||||
let localTestFnName = fn.name + (isHtmlViews ? "HTML" : "XUL");
|
||||
// Get an informative name for the function in stack traces.
|
||||
let obj = { [localTestFnName]: () => fn(isHtmlViews) };
|
||||
add_task(obj[localTestFnName]);
|
||||
}
|
||||
}
|
||||
|
||||
addTestTasks(false);
|
||||
addTestTasks(true);
|
||||
});
|
||||
|
@ -1,124 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// The HTML tests are in browser_html_warning_messages.js.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
// Tests that signed and unsigned language packs show up correctly in
|
||||
// the Languages tab based on the langpack signing preference.
|
||||
add_task(async function() {
|
||||
const PREF = "extensions.langpacks.signatures.required";
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, false]],
|
||||
});
|
||||
|
||||
let provider = new MockProvider();
|
||||
|
||||
provider.createAddons([
|
||||
{
|
||||
id: "signed@tests.mozilla.org",
|
||||
name: "Signed langpack",
|
||||
type: "locale",
|
||||
signedState: AddonManager.SIGNEDSTATE_SIGNED,
|
||||
isCorrectlySigned: true,
|
||||
},
|
||||
{
|
||||
id: "unsigned@tests.mozilla.org",
|
||||
name: "Unsigned langpack",
|
||||
type: "locale",
|
||||
signedState: AddonManager.SIGNEDSTATE_MISSING,
|
||||
isCorrectlySigned: false,
|
||||
},
|
||||
]);
|
||||
|
||||
let mgrWin = await open_manager(null);
|
||||
|
||||
function checklist(signingRequired) {
|
||||
let list = mgrWin.document.getElementById("addon-list");
|
||||
is(list.itemChildren.length, 2, "Found 2 items in langpack list");
|
||||
for (let item of list.itemChildren) {
|
||||
let what, warningVisible, errorVisible;
|
||||
|
||||
if (item.mAddon.id.startsWith("signed")) {
|
||||
// Signed langpack should not have any warning/error
|
||||
what = "signed langpack";
|
||||
warningVisible = false;
|
||||
errorVisible = false;
|
||||
} else if (signingRequired) {
|
||||
// Unsigned should have an error if signing is required
|
||||
what = "unsigned langpack";
|
||||
warningVisible = false;
|
||||
errorVisible = true;
|
||||
} else {
|
||||
// Usnigned should have a warning is signing is not required
|
||||
what = "unsigned langpack";
|
||||
warningVisible = true;
|
||||
errorVisible = false;
|
||||
}
|
||||
|
||||
let warning = mgrWin.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning"
|
||||
);
|
||||
let warningLink = mgrWin.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"warning-link"
|
||||
);
|
||||
if (warningVisible) {
|
||||
is_element_visible(warning, `Warning should be visible for ${what}`);
|
||||
is_element_visible(
|
||||
warningLink,
|
||||
`Warning link should be visible for ${what}`
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(warning, `Warning should be hidden for ${what}`);
|
||||
is_element_hidden(
|
||||
warningLink,
|
||||
`Warning link should be hidden for ${what}`
|
||||
);
|
||||
}
|
||||
|
||||
let error = mgrWin.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"error"
|
||||
);
|
||||
let errorLink = mgrWin.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"error-link"
|
||||
);
|
||||
if (errorVisible) {
|
||||
is_element_visible(error, `Error should be visible for ${what}`);
|
||||
is_element_visible(
|
||||
errorLink,
|
||||
`Error link should be visible for ${what}`
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(error, `Error should be hidden for ${what}`);
|
||||
is_element_hidden(errorLink, `Error link should be hidden for ${what}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let catUtils = new CategoryUtilities(mgrWin);
|
||||
|
||||
await catUtils.openType("locale");
|
||||
checklist(false);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, true]],
|
||||
});
|
||||
|
||||
await catUtils.openType("extension");
|
||||
await catUtils.openType("locale");
|
||||
checklist(true);
|
||||
|
||||
await close_manager(mgrWin);
|
||||
});
|
@ -1,260 +0,0 @@
|
||||
// This test is testing the view with legacy add-ons in the XUL about:addons UI.
|
||||
// This is not implemented in HTML about:addons, but might be in bug 1525184.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
const INFO_URL =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
||||
"webextensions";
|
||||
|
||||
// The mochitest framework installs a bunch of legacy extensions.
|
||||
// Fortunately, the extensions.legacy.exceptions preference exists to
|
||||
// avoid treating some extensions as legacy for the purposes of the UI.
|
||||
const IGNORE = [
|
||||
"special-powers@mozilla.org",
|
||||
"mochikit@mozilla.org",
|
||||
"mozscreenshots@mozilla.org",
|
||||
];
|
||||
|
||||
let exceptions = Services.prefs.getCharPref("extensions.legacy.exceptions");
|
||||
exceptions = [exceptions, ...IGNORE].join(",");
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.legacy.enabled", false],
|
||||
["extensions.legacy.exceptions", exceptions],
|
||||
|
||||
["xpinstall.signatures.required", false],
|
||||
],
|
||||
});
|
||||
|
||||
let goodAddons = [
|
||||
{
|
||||
id: "webextension@tests.mozilla.org",
|
||||
name: "WebExtension",
|
||||
type: "extension",
|
||||
isWebExtension: true,
|
||||
},
|
||||
{
|
||||
id: "mozilla@tests.mozilla.org",
|
||||
name: "Mozilla signed extension",
|
||||
type: "extension",
|
||||
isWebExtension: false,
|
||||
signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
|
||||
},
|
||||
];
|
||||
|
||||
let disabledAddon = [
|
||||
{
|
||||
id: "legacy@tests.mozilla.org",
|
||||
name: "Legacy extension",
|
||||
type: "extension",
|
||||
isWebExtension: false,
|
||||
appDisabled: true,
|
||||
},
|
||||
];
|
||||
|
||||
let unsignedAddons = [
|
||||
{
|
||||
id: "unsigned_webext@tests.mozilla.org",
|
||||
name: "Unsigned WebExtension",
|
||||
type: "extension",
|
||||
isWebExtension: true,
|
||||
appDisabled: true,
|
||||
signedState: AddonManager.SIGNEDSTATE_MISSING,
|
||||
},
|
||||
{
|
||||
id: "unsigned_legacy@tests.mozilla.org",
|
||||
name: "Unsigned legacy extension",
|
||||
type: "extension",
|
||||
isWebExtension: false,
|
||||
appDisabled: true,
|
||||
signedState: AddonManager.SIGNEDSTATE_MISSING,
|
||||
},
|
||||
];
|
||||
|
||||
let provider = new MockProvider();
|
||||
provider.createAddons(goodAddons);
|
||||
|
||||
let mgrWin = await open_manager(null);
|
||||
let catUtils = new CategoryUtilities(mgrWin);
|
||||
|
||||
// Check that the test addons in the given list are exactly those
|
||||
// in the expected list.
|
||||
async function checkList(listId, expectIds) {
|
||||
let ids = new Set(expectIds);
|
||||
for (let item of mgrWin.document.getElementById(listId).itemChildren) {
|
||||
if (!item.mAddon.id.endsWith("@tests.mozilla.org")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ok(ids.has(item.mAddon.id), `Found ${item.mAddon.id} in addons list`);
|
||||
ids.delete(item.mAddon.id);
|
||||
}
|
||||
|
||||
for (let id of ids) {
|
||||
ok(false, `Did not find ${id} in addons list`);
|
||||
}
|
||||
}
|
||||
|
||||
// Initially, we have two good extensions (a webextension and a
|
||||
// "Mozilla Extensions"-signed extension).
|
||||
await catUtils.openType("extension");
|
||||
checkList("addon-list", [
|
||||
"webextension@tests.mozilla.org",
|
||||
"mozilla@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
let banner = mgrWin.document.getElementById("legacy-extensions-notice");
|
||||
is_element_hidden(banner, "Warning about legacy extensions should be hidden");
|
||||
is(
|
||||
mgrWin.gLegacyView._categoryItem.disabled,
|
||||
true,
|
||||
"Legacy category is hidden"
|
||||
);
|
||||
|
||||
// Now add a legacy extension
|
||||
provider.createAddons(disabledAddon);
|
||||
|
||||
// The legacy category does not watch for new installs since new
|
||||
// legacy extensions cannot be installed while legacy extensions
|
||||
// are disabled, so manually refresh it here.
|
||||
await mgrWin.gLegacyView.refreshVisibility();
|
||||
|
||||
// Make sure we re-render the extensions list, after that we should
|
||||
// still just have the original two entries.
|
||||
await catUtils.openType("plugin");
|
||||
await catUtils.openType("extension");
|
||||
|
||||
checkList("addon-list", [
|
||||
"webextension@tests.mozilla.org",
|
||||
"mozilla@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
// But now the legacy banner and category should be visible
|
||||
banner = mgrWin.document.getElementById("legacy-extensions-notice");
|
||||
is_element_visible(
|
||||
banner,
|
||||
"Warning about legacy extensions should be visible"
|
||||
);
|
||||
|
||||
let catItem = mgrWin.gLegacyView._categoryItem;
|
||||
is(catItem.disabled, false, "Legacy category is visible");
|
||||
is(
|
||||
catItem.getAttribute("name"),
|
||||
get_string("type.legacy.name"),
|
||||
"Category label with no unsigned extensions is correct"
|
||||
);
|
||||
|
||||
// Follow the link to the legacy extensions page
|
||||
let legacyLink = mgrWin.document.getElementById(
|
||||
"legacy-extensions-learnmore-link"
|
||||
);
|
||||
is_element_visible(legacyLink, "Link to legacy extension is visible");
|
||||
|
||||
let loadPromise = new Promise(resolve =>
|
||||
wait_for_view_load(mgrWin, resolve, true)
|
||||
);
|
||||
legacyLink.click();
|
||||
await loadPromise;
|
||||
|
||||
is(
|
||||
mgrWin.gViewController.currentViewId,
|
||||
"addons://legacy/",
|
||||
"Legacy extensions link leads to the correct view"
|
||||
);
|
||||
|
||||
let link = mgrWin.document.getElementById("legacy-learnmore");
|
||||
is(link.href, INFO_URL, "Learn more link points to the right place");
|
||||
|
||||
// The only extension in the list should be the one we just added.
|
||||
checkList("legacy-list", ["legacy@tests.mozilla.org"]);
|
||||
|
||||
// Now add some unsigned addons and flip the signing preference
|
||||
provider.createAddons(unsignedAddons);
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["xpinstall.signatures.required", true]],
|
||||
});
|
||||
|
||||
// The entry on the left side should now read "Unsupported"
|
||||
await mgrWin.gLegacyView.refreshVisibility();
|
||||
is(catItem.disabled, false, "Legacy category is visible");
|
||||
is(
|
||||
catItem.getAttribute("name"),
|
||||
get_string("type.unsupported.name"),
|
||||
"Category label with unsigned extensions is correct"
|
||||
);
|
||||
|
||||
// The main extensions list should still have the original two
|
||||
// good extensions and the legacy banner.
|
||||
await catUtils.openType("extension");
|
||||
checkList("addon-list", [
|
||||
"webextension@tests.mozilla.org",
|
||||
"mozilla@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
banner = mgrWin.document.getElementById("legacy-extensions-notice");
|
||||
is_element_visible(
|
||||
banner,
|
||||
"Warning about legacy extensions should be visible"
|
||||
);
|
||||
|
||||
// And the legacy pane should show both legacy and unsigned extensions
|
||||
await catUtils.openType("legacy");
|
||||
checkList("legacy-list", [
|
||||
"legacy@tests.mozilla.org",
|
||||
"unsigned_webext@tests.mozilla.org",
|
||||
"unsigned_legacy@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
// Disable unsigned extensions
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["xpinstall.signatures.required", false]],
|
||||
});
|
||||
|
||||
await new Promise(executeSoon);
|
||||
|
||||
// The name of the pane should go back to "Legacy Extensions"
|
||||
await mgrWin.gLegacyView.refreshVisibility();
|
||||
is(catItem.disabled, false, "Legacy category is visible");
|
||||
is(
|
||||
catItem.getAttribute("name"),
|
||||
get_string("type.legacy.name"),
|
||||
"Category label with no unsigned extensions is correct"
|
||||
);
|
||||
|
||||
// The unsigned extension should be present in the main extensions pane
|
||||
await catUtils.openType("extension");
|
||||
checkList("addon-list", [
|
||||
"webextension@tests.mozilla.org",
|
||||
"mozilla@tests.mozilla.org",
|
||||
"unsigned_webext@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
// And it should not be present in the legacy pane
|
||||
await catUtils.openType("legacy");
|
||||
checkList("legacy-list", [
|
||||
"legacy@tests.mozilla.org",
|
||||
"unsigned_legacy@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
await close_manager(mgrWin);
|
||||
|
||||
// Now enable legacy extensions and open a new addons manager tab.
|
||||
// The remembered last view will be the list of legacy extensions but
|
||||
// now that legacy extensions are enabled, we should jump to the
|
||||
// regular Extensions list.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.legacy.enabled", true]],
|
||||
});
|
||||
|
||||
mgrWin = await open_manager(null);
|
||||
is(
|
||||
mgrWin.gViewController.currentViewId,
|
||||
"addons://list/extension",
|
||||
"addons manager switched to extensions list"
|
||||
);
|
||||
await close_manager(mgrWin);
|
||||
});
|
@ -1,104 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This test is testing XUL about:addons UI not implemented in the HTML about:addons,
|
||||
// it may be adapted or tested in a separate test file in Bug 1525184.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
const INFO_URL =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
||||
"webextensions";
|
||||
|
||||
const NAMES = {
|
||||
newTheme: "New LWT",
|
||||
legacy: "Legacy Extension",
|
||||
webextension: "WebExtension",
|
||||
dictionary: "Dictionary",
|
||||
langpack: "Language Pack",
|
||||
};
|
||||
let addons = [
|
||||
{
|
||||
id: "new-theme@tests.mozilla.org",
|
||||
name: NAMES.newTheme,
|
||||
type: "theme",
|
||||
isWebExtension: true,
|
||||
},
|
||||
{
|
||||
id: "legacy@tests.mozilla.org",
|
||||
name: NAMES.legacy,
|
||||
type: "extension",
|
||||
isWebExtension: false,
|
||||
},
|
||||
{
|
||||
id: "webextension@tests.mozilla.org",
|
||||
name: NAMES.webextension,
|
||||
type: "extension",
|
||||
isWebExtension: true,
|
||||
},
|
||||
{
|
||||
id: "dictionary@tests.mozilla.org",
|
||||
name: NAMES.dictionary,
|
||||
type: "dictionary",
|
||||
},
|
||||
];
|
||||
|
||||
let provider = new MockProvider();
|
||||
provider.createAddons(addons);
|
||||
|
||||
let mgrWin = await open_manager(null);
|
||||
let catUtils = new CategoryUtilities(mgrWin);
|
||||
|
||||
async function check(category, name, isLegacy) {
|
||||
await catUtils.openType(category);
|
||||
|
||||
let document = mgrWin.document;
|
||||
// First find the entry in the list.
|
||||
let item = Array.from(
|
||||
document.getElementById("addon-list").childNodes
|
||||
).find(i => i.getAttribute("name") == name);
|
||||
|
||||
ok(item, `Found ${name} in list`);
|
||||
item.parentNode.ensureElementIsVisible(item);
|
||||
|
||||
// Check the badge
|
||||
let badge = document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"legacy"
|
||||
);
|
||||
|
||||
if (isLegacy) {
|
||||
is_element_visible(badge, `Legacy badge is visible for ${name}`);
|
||||
is(badge.href, INFO_URL, "Legacy badge link is correct");
|
||||
} else {
|
||||
is_element_hidden(badge, `Legacy badge is hidden for ${name}`);
|
||||
}
|
||||
|
||||
// Click down to the details page.
|
||||
EventUtils.synthesizeMouseAtCenter(item, {}, mgrWin);
|
||||
await new Promise(resolve => wait_for_view_load(mgrWin, resolve));
|
||||
|
||||
// And check the badge
|
||||
let elements = document.getElementsByClassName("legacy-warning");
|
||||
is(elements.length, 1, "Found the legacy-warning element");
|
||||
badge = elements[0];
|
||||
|
||||
if (isLegacy) {
|
||||
is_element_visible(badge, `Legacy badge is visible for ${name}`);
|
||||
is(badge.href, INFO_URL, "Legacy badge link is correct");
|
||||
} else {
|
||||
is_element_hidden(badge, `Legacy badge is hidden for ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
await check("theme", NAMES.newTheme, false);
|
||||
await check("extension", NAMES.legacy, true);
|
||||
await check("extension", NAMES.webextension, false);
|
||||
await check("dictionary", NAMES.dictionary, false);
|
||||
|
||||
await close_manager(mgrWin);
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -1,439 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests manual updates, including the Available Updates pane
|
||||
|
||||
var gProvider;
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gAvailableCategory;
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "auto updating addon",
|
||||
version: "1.0",
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
add_test(function clearOldTelemetry() {
|
||||
Services.telemetry.clearEvents();
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
gAvailableCategory = gManagerWindow.gCategories.get(
|
||||
"addons://updates/available"
|
||||
);
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
false,
|
||||
"Available Updates category should initially be hidden"
|
||||
);
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon2@tests.mozilla.org",
|
||||
name: "manually updating addon",
|
||||
version: "1.0",
|
||||
isCompatible: false,
|
||||
operationsRequiringRestart: 0,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
|
||||
},
|
||||
]);
|
||||
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
false,
|
||||
"Available Updates category should still be hidden"
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
let finished = 0;
|
||||
function maybeRunNext() {
|
||||
if (++finished == 2) {
|
||||
run_next_test();
|
||||
}
|
||||
}
|
||||
|
||||
gAvailableCategory.addEventListener(
|
||||
"CategoryBadgeUpdated",
|
||||
function() {
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
true,
|
||||
"Available Updates category should now be visible"
|
||||
);
|
||||
is(
|
||||
gAvailableCategory.badgeCount,
|
||||
1,
|
||||
"Badge for Available Updates should now be 1"
|
||||
);
|
||||
maybeRunNext();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
gProvider.createInstalls([
|
||||
{
|
||||
name: "manually updating addon (new and improved!)",
|
||||
existingAddon: gProvider.addons[1],
|
||||
version: "1.1",
|
||||
releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml"),
|
||||
},
|
||||
]);
|
||||
|
||||
var item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
|
||||
get_tooltip_info(item).then(({ version }) => {
|
||||
is(version, "1.0", "Should still show the old version in the tooltip");
|
||||
maybeRunNext();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
Promise.resolve().then(() => {
|
||||
EventUtils.synthesizeMouseAtCenter(gAvailableCategory, {}, gManagerWindow);
|
||||
});
|
||||
await wait_for_view_load(gManagerWindow, null, true);
|
||||
is(
|
||||
gManagerWindow.document.getElementById("categories").selectedItem.value,
|
||||
"addons://updates/available",
|
||||
"Available Updates category should now be selected"
|
||||
);
|
||||
is(
|
||||
gManagerWindow.gViewController.currentViewId,
|
||||
"addons://updates/available",
|
||||
"Available Updates view should be the current view"
|
||||
);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
is(list.itemCount, 1, "Should be 1 available update listed");
|
||||
var item = list.firstChild;
|
||||
is(
|
||||
item.mAddon.id,
|
||||
"addon2@tests.mozilla.org",
|
||||
"Update item should be for the manually updating addon"
|
||||
);
|
||||
|
||||
// The item in the list will be checking for update information asynchronously
|
||||
// so we have to wait for it to complete. Doing the same async request should
|
||||
// make our callback be called later.
|
||||
await AddonManager.getAllInstalls();
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
function checkReleaseNotesTelemetry() {
|
||||
let snapshot = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
|
||||
true
|
||||
);
|
||||
ok(
|
||||
snapshot.parent && snapshot.parent.length > 0,
|
||||
"Got parent telemetry events in the snapshot"
|
||||
);
|
||||
|
||||
let releaseNotesEvents = snapshot.parent
|
||||
.filter(
|
||||
([ts, category, method]) =>
|
||||
category == "addonsManager" && method == "action"
|
||||
)
|
||||
.map(([ts, category, ...rest]) => rest);
|
||||
|
||||
Assert.deepEqual(
|
||||
releaseNotesEvents,
|
||||
[
|
||||
[
|
||||
"action",
|
||||
"aboutAddons",
|
||||
null,
|
||||
{
|
||||
action: "releaseNotes",
|
||||
type: "extension",
|
||||
addonId: "addon2@tests.mozilla.org",
|
||||
view: "updates",
|
||||
},
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"aboutAddons",
|
||||
null,
|
||||
{
|
||||
action: "releaseNotes",
|
||||
type: "extension",
|
||||
addonId: "addon2@tests.mozilla.org",
|
||||
view: "updates",
|
||||
},
|
||||
],
|
||||
],
|
||||
"The releaseNotes events are tracked"
|
||||
);
|
||||
}
|
||||
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
var item = list.firstChild;
|
||||
get_tooltip_info(item).then(({ version }) => {
|
||||
is(version, "1.1", "Update item should have version number of the update");
|
||||
var postfix = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"class",
|
||||
"update-postfix"
|
||||
);
|
||||
is_element_visible(postfix, "'Update' postfix should be visible");
|
||||
is_element_visible(item._updateAvailable, "");
|
||||
is_element_visible(
|
||||
item._relNotesToggle,
|
||||
"Release notes toggle should be visible"
|
||||
);
|
||||
is_element_hidden(item._warning, "Incompatible warning should be hidden");
|
||||
is_element_hidden(item._error, "Blocklist error should be hidden");
|
||||
|
||||
info("Opening release notes");
|
||||
item.addEventListener(
|
||||
"RelNotesToggle",
|
||||
function() {
|
||||
info("Release notes now open");
|
||||
|
||||
is_element_hidden(
|
||||
item._relNotesLoading,
|
||||
"Release notes loading message should be hidden"
|
||||
);
|
||||
is_element_visible(
|
||||
item._relNotesError,
|
||||
"Release notes error message should be visible"
|
||||
);
|
||||
is(
|
||||
item._relNotes.childElementCount,
|
||||
0,
|
||||
"Release notes should be empty"
|
||||
);
|
||||
|
||||
info("Closing release notes");
|
||||
item.addEventListener(
|
||||
"RelNotesToggle",
|
||||
function() {
|
||||
info("Release notes now closed");
|
||||
info("Setting Release notes URI to something that should load");
|
||||
gProvider.installs[0].releaseNotesURI = Services.io.newURI(
|
||||
TESTROOT + "releaseNotes.xhtml"
|
||||
);
|
||||
|
||||
info("Re-opening release notes");
|
||||
item.addEventListener(
|
||||
"RelNotesToggle",
|
||||
function() {
|
||||
info("Release notes now open");
|
||||
|
||||
is_element_hidden(
|
||||
item._relNotesLoading,
|
||||
"Release notes loading message should be hidden"
|
||||
);
|
||||
is_element_hidden(
|
||||
item._relNotesError,
|
||||
"Release notes error message should be hidden"
|
||||
);
|
||||
isnot(
|
||||
item._relNotes.childElementCount,
|
||||
0,
|
||||
"Release notes should have been inserted into container"
|
||||
);
|
||||
|
||||
checkReleaseNotesTelemetry();
|
||||
|
||||
run_next_test();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
item._relNotesToggle,
|
||||
{},
|
||||
gManagerWindow
|
||||
);
|
||||
is_element_visible(
|
||||
item._relNotesLoading,
|
||||
"Release notes loading message should be visible"
|
||||
);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
item._relNotesToggle,
|
||||
{},
|
||||
gManagerWindow
|
||||
);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
item._relNotesToggle,
|
||||
{},
|
||||
gManagerWindow
|
||||
);
|
||||
is_element_visible(
|
||||
item._relNotesLoading,
|
||||
"Release notes loading message should be visible"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
var badgeUpdated = false;
|
||||
var installCompleted = false;
|
||||
|
||||
gAvailableCategory.addEventListener(
|
||||
"CategoryBadgeUpdated",
|
||||
function() {
|
||||
if (installCompleted) {
|
||||
run_next_test();
|
||||
} else {
|
||||
badgeUpdated = true;
|
||||
}
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
var list = gManagerWindow.document.getElementById("updates-list");
|
||||
var item = list.firstChild;
|
||||
var updateBtn = item._updateBtn;
|
||||
is_element_visible(updateBtn, "Update button should be visible");
|
||||
|
||||
var install = gProvider.installs[0];
|
||||
var listener = {
|
||||
onInstallStarted() {
|
||||
info("Install started");
|
||||
is_element_visible(
|
||||
item._installStatus,
|
||||
"Install progress widget should be visible"
|
||||
);
|
||||
},
|
||||
onInstallEnded(...args) {
|
||||
install.removeTestListener(this);
|
||||
info("Install ended");
|
||||
is_element_hidden(
|
||||
item._installStatus,
|
||||
"Install progress widget should be hidden"
|
||||
);
|
||||
|
||||
if (badgeUpdated) {
|
||||
run_next_test();
|
||||
} else {
|
||||
installCompleted = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
install.addTestListener(listener);
|
||||
EventUtils.synthesizeMouseAtCenter(updateBtn, {}, gManagerWindow);
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
true,
|
||||
"Available Updates category should still be visible"
|
||||
);
|
||||
is(
|
||||
gAvailableCategory.badgeCount,
|
||||
0,
|
||||
"Badge for Available Updates should now be 0"
|
||||
);
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
false,
|
||||
"Available Updates category should be hidden"
|
||||
);
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
gAvailableCategory = gManagerWindow.gCategories.get(
|
||||
"addons://updates/available"
|
||||
);
|
||||
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
false,
|
||||
"Available Updates category should be hidden"
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
gAvailableCategory.addEventListener(
|
||||
"CategoryBadgeUpdated",
|
||||
async function() {
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
true,
|
||||
"Available Updates category should now be visible"
|
||||
);
|
||||
is(
|
||||
gAvailableCategory.badgeCount,
|
||||
1,
|
||||
"Badge for Available Updates should now be 1"
|
||||
);
|
||||
|
||||
gAvailableCategory.addEventListener(
|
||||
"CategoryBadgeUpdated",
|
||||
function() {
|
||||
is(
|
||||
gCategoryUtilities.isVisible(gAvailableCategory),
|
||||
false,
|
||||
"Available Updates category should now be hidden"
|
||||
);
|
||||
|
||||
run_next_test();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
|
||||
aAddon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
gProvider.createInstalls([
|
||||
{
|
||||
name: "manually updating addon (new and even more improved!)",
|
||||
existingAddon: gProvider.addons[1],
|
||||
version: "1.2",
|
||||
releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml"),
|
||||
},
|
||||
]);
|
||||
});
|
@ -1,149 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that state menu is displayed correctly (enabled or disabled) in the add-on manager
|
||||
// when the preference is unlocked / locked
|
||||
const gIsWindows = "@mozilla.org/windows-registry-key;1" in Cc;
|
||||
const gIsLinux =
|
||||
"@mozilla.org/gnome-gconf-service;1" in Cc ||
|
||||
"@mozilla.org/gio-service;1" in Cc;
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gPluginElement;
|
||||
|
||||
function getTestPluginPref() {
|
||||
let prefix = "plugin.state.";
|
||||
if (gIsWindows) {
|
||||
return `${prefix}nptest`;
|
||||
}
|
||||
if (gIsLinux) {
|
||||
return `${prefix}libnptest`;
|
||||
}
|
||||
return `${prefix}test`;
|
||||
}
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons tests should verify
|
||||
// this in their own test files).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.unlockPref(getTestPluginPref());
|
||||
Services.prefs.clearUserPref(getTestPluginPref());
|
||||
});
|
||||
|
||||
function getPlugins() {
|
||||
return AddonManager.getAddonsByTypes(["plugin"]);
|
||||
}
|
||||
|
||||
function getTestPlugin(aPlugins) {
|
||||
let testPluginId;
|
||||
|
||||
for (let plugin of aPlugins) {
|
||||
if (plugin.name == "Test Plug-in") {
|
||||
testPluginId = plugin.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.ok(testPluginId, "Test Plug-in should exist");
|
||||
|
||||
let pluginElement = get_addon_element(gManagerWindow, testPluginId);
|
||||
pluginElement.parentNode.ensureElementIsVisible(pluginElement);
|
||||
|
||||
return pluginElement;
|
||||
}
|
||||
|
||||
function checkStateMenu(locked) {
|
||||
Assert.equal(
|
||||
Services.prefs.prefIsLocked(getTestPluginPref()),
|
||||
locked,
|
||||
"Preference lock state should be correct."
|
||||
);
|
||||
let menuList = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
gPluginElement,
|
||||
"anonid",
|
||||
"state-menulist"
|
||||
);
|
||||
// State menu should always have a selected item which must be visible
|
||||
let selectedMenuItem = menuList.querySelector(
|
||||
'.addon-control[selected="true"]'
|
||||
);
|
||||
|
||||
is_element_visible(menuList, "State menu should be visible.");
|
||||
Assert.equal(
|
||||
menuList.disabled,
|
||||
locked,
|
||||
"State menu should" + (locked === true ? "" : " not") + " be disabled."
|
||||
);
|
||||
|
||||
is_element_visible(
|
||||
selectedMenuItem,
|
||||
"State menu's selected item should be visible."
|
||||
);
|
||||
}
|
||||
|
||||
function checkStateMenuDetail(locked) {
|
||||
Assert.equal(
|
||||
Services.prefs.prefIsLocked(getTestPluginPref()),
|
||||
locked,
|
||||
"Preference should be " + (locked === true ? "" : "un") + "locked."
|
||||
);
|
||||
|
||||
// open details menu
|
||||
EventUtils.synthesizeMouseAtCenter(gPluginElement, {}, gManagerWindow);
|
||||
|
||||
return new Promise(async resolve => {
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
let menuList = gManagerWindow.document.getElementById(
|
||||
"detail-state-menulist"
|
||||
);
|
||||
is_element_visible(menuList, "Details state menu should be visible.");
|
||||
Assert.equal(
|
||||
menuList.disabled,
|
||||
locked,
|
||||
"Details state menu enabled state should be correct."
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function initializeState() {
|
||||
Services.prefs.setIntPref(getTestPluginPref(), Ci.nsIPluginTag.STATE_ENABLED);
|
||||
Services.prefs.unlockPref(getTestPluginPref());
|
||||
gManagerWindow = await open_manager();
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
|
||||
let plugins = await getPlugins();
|
||||
gPluginElement = getTestPlugin(plugins);
|
||||
});
|
||||
|
||||
// Tests that plugin state menu is enabled if the preference is unlocked
|
||||
add_task(async function taskCheckStateMenuIsEnabled() {
|
||||
checkStateMenu(false);
|
||||
await checkStateMenuDetail(false);
|
||||
});
|
||||
|
||||
// Lock the preference and then reload the plugin category
|
||||
add_task(async function reinitializeState() {
|
||||
// lock the preference
|
||||
Services.prefs.lockPref(getTestPluginPref());
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
// Retrieve the test plugin element
|
||||
let plugins = await getPlugins();
|
||||
gPluginElement = getTestPlugin(plugins);
|
||||
});
|
||||
|
||||
// Tests that plugin state menu is disabled if the preference is locked
|
||||
add_task(async function taskCheckStateMenuIsDisabled() {
|
||||
checkStateMenu(true);
|
||||
await checkStateMenuDetail(true);
|
||||
});
|
||||
|
||||
add_task(async function testCleanup() {
|
||||
await close_manager(gManagerWindow);
|
||||
});
|
@ -11,7 +11,7 @@ async function getTestPluginAddon() {
|
||||
return plugins.find(plugin => plugin.name === "Test Plug-in");
|
||||
}
|
||||
|
||||
async function test_inline_plugin_prefs() {
|
||||
add_task(async function test_inline_plugin_prefs() {
|
||||
gManagerWindow = await open_manager("addons://list/plugin");
|
||||
let testPlugin = await getTestPluginAddon();
|
||||
ok(testPlugin, "Test Plug-in should exist");
|
||||
@ -35,26 +35,7 @@ async function test_inline_plugin_prefs() {
|
||||
}
|
||||
).then(event => event.target);
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
pluginEl.querySelector("panel-item[action='preferences']").click();
|
||||
} else {
|
||||
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
|
||||
|
||||
let button = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
pluginEl,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is_element_visible(button, "Preferences button should be visible");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
pluginEl,
|
||||
{ clickCount: 1 },
|
||||
gManagerWindow
|
||||
);
|
||||
|
||||
await TestUtils.topicObserved(AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
|
||||
}
|
||||
|
||||
info("Waiting for inline options page to be ready");
|
||||
let doc = (await optionsBrowserPromise).contentDocument;
|
||||
@ -82,20 +63,4 @@ async function test_inline_plugin_prefs() {
|
||||
);
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
}
|
||||
|
||||
add_task(async function test_inline_plugin_prefs_on_XUL_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await test_inline_plugin_prefs();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function test_inline_plugin_prefs_on_HTML_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await test_inline_plugin_prefs();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests plugin prefs being enabled
|
||||
|
||||
function getTestPlugin(aPlugins) {
|
||||
let [testPlugin] = aPlugins.filter(plugin => plugin.name === "Test Plug-in");
|
||||
Assert.ok(testPlugin, "Test Plug-in should exist");
|
||||
return testPlugin;
|
||||
}
|
||||
|
||||
add_task(async function taskCheckPluginPrefsEnabled() {
|
||||
const [gManagerWindow, plugins] = await Promise.all([
|
||||
open_manager(),
|
||||
AddonManager.getAddonsByTypes(["plugin"]),
|
||||
]);
|
||||
const testPlugin = getTestPlugin(plugins);
|
||||
const testPluginTag = getTestPluginTag();
|
||||
Assert.ok(testPluginTag, "Test Plug-in tag should exist");
|
||||
const initialTestPluginState = testPluginTag.enabledState;
|
||||
|
||||
Assert.ok(
|
||||
gManagerWindow.gViewController.commands.cmd_showItemPreferences.isEnabled(
|
||||
testPlugin
|
||||
),
|
||||
"Test Plug-in preferences should be enabled"
|
||||
);
|
||||
testPluginTag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
|
||||
Assert.ok(
|
||||
gManagerWindow.gViewController.commands.cmd_showItemPreferences.isEnabled(
|
||||
testPlugin
|
||||
),
|
||||
"Test Plug-in preferences should be enabled"
|
||||
);
|
||||
|
||||
testPluginTag.enabledState = initialTestPluginState;
|
||||
await close_manager(gManagerWindow);
|
||||
});
|
@ -14,78 +14,26 @@ const testIdSuffix = "@tests.mozilla.org";
|
||||
|
||||
let gManagerWindow, xpi1, xpi2;
|
||||
|
||||
function get_test_items_in_list(aManager) {
|
||||
let item = aManager.document.getElementById("addon-list").firstChild;
|
||||
let items = [];
|
||||
|
||||
while (item) {
|
||||
if (item.localName != "richlistitem") {
|
||||
item = item.nextSibling;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
!item.mAddon ||
|
||||
item.mAddon.id.substring(item.mAddon.id.length - testIdSuffix.length) ==
|
||||
testIdSuffix
|
||||
) {
|
||||
items.push(item);
|
||||
}
|
||||
item = item.nextSibling;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function htmlDoc() {
|
||||
return gManagerWindow.document.getElementById("html-view-browser")
|
||||
.contentDocument;
|
||||
}
|
||||
|
||||
function get_list_item_count() {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return htmlDoc().querySelectorAll(`addon-card[addon-id$="${testIdSuffix}"]`)
|
||||
.length;
|
||||
}
|
||||
return get_test_items_in_list(gManagerWindow).length;
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
return parent.ownerDocument.getAnonymousElementByAttribute(
|
||||
parent,
|
||||
"anonid",
|
||||
anonid
|
||||
);
|
||||
}
|
||||
|
||||
function removeItem(item) {
|
||||
let button;
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
button = item.querySelector('[action="remove"]');
|
||||
let button = item.querySelector('[action="remove"]');
|
||||
button.click();
|
||||
} else {
|
||||
button = get_node(item, "remove-btn");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerGlobal);
|
||||
}
|
||||
}
|
||||
|
||||
function get_class_node(parent, cls) {
|
||||
return parent.ownerDocument.getAnonymousElementByAttribute(
|
||||
parent,
|
||||
"class",
|
||||
cls
|
||||
);
|
||||
}
|
||||
|
||||
function hasPendingMessage(item, msg) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
let messageBar = htmlDoc().querySelector(
|
||||
`message-bar[addon-id="${item.addon.id}"`
|
||||
);
|
||||
is_element_visible(messageBar, msg);
|
||||
} else {
|
||||
is_element_visible(get_class_node(item, "pending"), msg);
|
||||
}
|
||||
}
|
||||
|
||||
async function install_addon(xpi) {
|
||||
@ -109,7 +57,6 @@ async function check_addon(aAddon, aVersion) {
|
||||
let { version } = await get_tooltip_info(item, gManagerWindow);
|
||||
is(version, aVersion, "Version should be correct");
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
const l10nAttrs = item.ownerDocument.l10n.getAttributes(
|
||||
item.querySelector(".addon-name")
|
||||
);
|
||||
@ -126,25 +73,9 @@ async function check_addon(aAddon, aVersion) {
|
||||
"localized addon name is not marked as disabled"
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAddon.userDisabled) {
|
||||
is_element_visible(
|
||||
get_class_node(item, "disabled-postfix"),
|
||||
"Disabled postfix should be hidden"
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(
|
||||
get_class_node(item, "disabled-postfix"),
|
||||
"Disabled postfix should be hidden"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function wait_for_addon_item_added(addonId) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
htmlDoc().querySelector("addon-list"),
|
||||
"add"
|
||||
@ -152,10 +83,8 @@ async function wait_for_addon_item_added(addonId) {
|
||||
const item = get_addon_element(gManagerWindow, addonId);
|
||||
ok(item, `Found addon card for ${addonId}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function wait_for_addon_item_removed(addonId) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
htmlDoc().querySelector("addon-list"),
|
||||
"remove"
|
||||
@ -163,16 +92,13 @@ async function wait_for_addon_item_removed(addonId) {
|
||||
const item = get_addon_element(gManagerWindow, addonId);
|
||||
ok(!item, `There shouldn't be an addon card for ${addonId}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function wait_for_addon_item_updated(addonId) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
function wait_for_addon_item_updated(addonId) {
|
||||
return BrowserTestUtils.waitForEvent(
|
||||
get_addon_element(gManagerWindow, addonId),
|
||||
"update"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Install version 1 then upgrade to version 2 with the manager open
|
||||
async function test_upgrade_v1_to_v2() {
|
||||
@ -316,35 +242,6 @@ async function test_upgrade_pending_uninstall_disabled_v1_to_v2() {
|
||||
is(get_list_item_count(), 0, "Should be no items in the list");
|
||||
}
|
||||
|
||||
async function test_upgrades(useHtmlViews) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", useHtmlViews]],
|
||||
});
|
||||
|
||||
// Close existing about:addons tab if a test failure has
|
||||
// prevented it from being closed.
|
||||
if (gManagerWindow) {
|
||||
await close_manager(gManagerWindow);
|
||||
}
|
||||
|
||||
gManagerWindow = await open_manager("addons://list/extension");
|
||||
is(
|
||||
gManagerWindow.useHtmlViews,
|
||||
useHtmlViews,
|
||||
"Got about:addons window in the expected mode"
|
||||
);
|
||||
|
||||
await test_upgrade_v1_to_v2();
|
||||
await test_upgrade_disabled_v1_to_v2();
|
||||
await test_upgrade_pending_uninstall_v1_to_v2();
|
||||
await test_upgrade_pending_uninstall_disabled_v1_to_v2();
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
gManagerWindow = null;
|
||||
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
xpi1 = await AddonTestUtils.createTempWebExtensionFile({
|
||||
manifest: {
|
||||
@ -364,10 +261,20 @@ add_task(async function setup() {
|
||||
mockPromptService()._response = 0;
|
||||
});
|
||||
|
||||
add_task(function run_tests_on_XUL_aboutaddons() {
|
||||
return test_upgrades(false);
|
||||
});
|
||||
add_task(async function test_upgrades() {
|
||||
// Close existing about:addons tab if a test failure has
|
||||
// prevented it from being closed.
|
||||
if (gManagerWindow) {
|
||||
await close_manager(gManagerWindow);
|
||||
}
|
||||
|
||||
add_task(function run_tests_on_HTML_aboutaddons() {
|
||||
return test_upgrades(true);
|
||||
gManagerWindow = await open_manager("addons://list/extension");
|
||||
|
||||
await test_upgrade_v1_to_v2();
|
||||
await test_upgrade_disabled_v1_to_v2();
|
||||
await test_upgrade_pending_uninstall_v1_to_v2();
|
||||
await test_upgrade_pending_uninstall_disabled_v1_to_v2();
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
gManagerWindow = null;
|
||||
});
|
||||
|
@ -1,385 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that sorting of add-ons works correctly
|
||||
// (this test uses the list view, even though it no longer has sort buttons - see bug 623207)
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI features that are not supported in the
|
||||
// HTML about:addons.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
gProvider.createAddons([
|
||||
{
|
||||
// enabledInstalled group
|
||||
// * Enabled
|
||||
// * Incompatible but enabled because compatibility checking is off
|
||||
// * Waiting to be installed
|
||||
// * Waiting to be enabled
|
||||
id: "test1@tests.mozilla.org",
|
||||
name: "Test add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 0),
|
||||
pendingOperations: AddonManager.PENDING_NONE,
|
||||
},
|
||||
{
|
||||
id: "test2@tests.mozilla.org",
|
||||
name: "a first add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 1, 23, 59, 59),
|
||||
pendingOperations: AddonManager.PENDING_UPGRADE,
|
||||
isActive: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
{
|
||||
id: "test3@tests.mozilla.org",
|
||||
name: "\u010Cesk\u00FD slovn\u00EDk", // Český slovník
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 1),
|
||||
pendingOperations: AddonManager.PENDING_INSTALL,
|
||||
isActive: false,
|
||||
},
|
||||
{
|
||||
id: "test4@tests.mozilla.org",
|
||||
name: "canadian dictionary",
|
||||
updateDate: new Date(1970, 0, 1, 0, 0, 0),
|
||||
description: "foo",
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
id: "test5@tests.mozilla.org",
|
||||
name: "croatian dictionary",
|
||||
description: "foo",
|
||||
updateDate: new Date(2012, 12, 12, 0, 0, 0),
|
||||
pendingOperations: AddonManager.PENDING_ENABLE,
|
||||
isActive: false,
|
||||
},
|
||||
{
|
||||
// pendingDisable group
|
||||
// * Waiting to be disabled
|
||||
id: "test6@tests.mozilla.org",
|
||||
name: "orange Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 0),
|
||||
isCompatible: false,
|
||||
isActive: true,
|
||||
pendingOperations: AddonManager.PENDING_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "test7@tests.mozilla.org",
|
||||
name: "Blue Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 1, 23, 59, 59),
|
||||
isActive: true,
|
||||
pendingOperations: AddonManager.PENDING_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "test8@tests.mozilla.org",
|
||||
name: "Green Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 3, 0, 0, 1),
|
||||
pendingOperations: AddonManager.PENDING_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "test9@tests.mozilla.org",
|
||||
name: "red Add-on",
|
||||
updateDate: new Date(2011, 4, 1, 0, 0, 0),
|
||||
description: "foo",
|
||||
isCompatible: false,
|
||||
pendingOperations: AddonManager.PENDING_DISABLE,
|
||||
},
|
||||
{
|
||||
id: "test10@tests.mozilla.org",
|
||||
name: "Purple Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2012, 12, 12, 0, 0, 0),
|
||||
isCompatible: false,
|
||||
pendingOperations: AddonManager.PENDING_DISABLE,
|
||||
},
|
||||
{
|
||||
// pendingUninstall group
|
||||
// * Waiting to be removed
|
||||
id: "test11@tests.mozilla.org",
|
||||
name: "amber Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(1978, 4, 2, 0, 0, 0),
|
||||
isActive: false,
|
||||
appDisabled: true,
|
||||
pendingOperations: AddonManager.PENDING_UNINSTALL,
|
||||
},
|
||||
{
|
||||
id: "test12@tests.mozilla.org",
|
||||
name: "Salmon Add-on - pending disable",
|
||||
description: "foo",
|
||||
updateDate: new Date(2054, 4, 1, 23, 59, 59),
|
||||
isActive: true,
|
||||
pendingOperations: AddonManager.PENDING_UNINSTALL,
|
||||
},
|
||||
{
|
||||
id: "test13@tests.mozilla.org",
|
||||
name: "rose Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 1),
|
||||
isActive: false,
|
||||
userDisabled: true,
|
||||
pendingOperations: AddonManager.PENDING_UNINSTALL,
|
||||
},
|
||||
{
|
||||
id: "test14@tests.mozilla.org",
|
||||
name: "Violet Add-on",
|
||||
updateDate: new Date(2010, 5, 1, 0, 0, 0),
|
||||
description: "foo",
|
||||
isActive: false,
|
||||
appDisabled: true,
|
||||
pendingOperations: AddonManager.PENDING_UNINSTALL,
|
||||
},
|
||||
{
|
||||
id: "test15@tests.mozilla.org",
|
||||
name: "white Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 12, 0, 0, 0),
|
||||
isActive: false,
|
||||
userDisabled: true,
|
||||
pendingOperations: AddonManager.PENDING_UNINSTALL,
|
||||
},
|
||||
{
|
||||
// disabledIncompatibleBlocked group
|
||||
// * Disabled
|
||||
// * Incompatible
|
||||
// * Blocklisted
|
||||
id: "test16@tests.mozilla.org",
|
||||
name: "grimsby Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 1, 0, 0, 0),
|
||||
isActive: false,
|
||||
appDisabled: true,
|
||||
},
|
||||
{
|
||||
id: "test17@tests.mozilla.org",
|
||||
name: "beamsville Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 8, 23, 59, 59),
|
||||
isActive: false,
|
||||
userDisabled: true,
|
||||
},
|
||||
{
|
||||
id: "test18@tests.mozilla.org",
|
||||
name: "smithville Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 3, 0, 0, 1),
|
||||
isActive: false,
|
||||
userDisabled: true,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED,
|
||||
},
|
||||
{
|
||||
id: "test19@tests.mozilla.org",
|
||||
name: "dunnville Add-on",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 0),
|
||||
description: "foo",
|
||||
isActive: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
|
||||
},
|
||||
{
|
||||
id: "test20@tests.mozilla.org",
|
||||
name: "silverdale Add-on",
|
||||
description: "foo",
|
||||
updateDate: new Date(2010, 4, 12, 0, 0, 0),
|
||||
isActive: false,
|
||||
appDisabled: true,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
function set_order(aSortBy, aAscending) {
|
||||
var list = gManagerWindow.document.getElementById("addon-list");
|
||||
var elements = [];
|
||||
var node = list.firstChild;
|
||||
while (node) {
|
||||
elements.push(node);
|
||||
node = node.nextSibling;
|
||||
}
|
||||
gManagerWindow.sortElements(elements, ["uiState", aSortBy], aAscending);
|
||||
for (let element of elements) {
|
||||
list.appendChild(element);
|
||||
}
|
||||
}
|
||||
|
||||
function check_order(aExpectedOrder) {
|
||||
var order = [];
|
||||
var list = gManagerWindow.document.getElementById("addon-list");
|
||||
var node = list.firstChild;
|
||||
while (node) {
|
||||
var id = node.getAttribute("value");
|
||||
if (id && id.endsWith("@tests.mozilla.org")) {
|
||||
order.push(node.getAttribute("value"));
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
is(
|
||||
order.toSource(),
|
||||
aExpectedOrder.toSource(),
|
||||
"Should have seen the right order"
|
||||
);
|
||||
}
|
||||
|
||||
// Tests that ascending name ordering was the default
|
||||
add_test(function() {
|
||||
check_order([
|
||||
"test2@tests.mozilla.org",
|
||||
"test4@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
"test5@tests.mozilla.org",
|
||||
"test1@tests.mozilla.org",
|
||||
"test7@tests.mozilla.org",
|
||||
"test8@tests.mozilla.org",
|
||||
"test6@tests.mozilla.org",
|
||||
"test10@tests.mozilla.org",
|
||||
"test9@tests.mozilla.org",
|
||||
"test11@tests.mozilla.org",
|
||||
"test13@tests.mozilla.org",
|
||||
"test12@tests.mozilla.org",
|
||||
"test14@tests.mozilla.org",
|
||||
"test15@tests.mozilla.org",
|
||||
"test17@tests.mozilla.org",
|
||||
"test19@tests.mozilla.org",
|
||||
"test16@tests.mozilla.org",
|
||||
"test20@tests.mozilla.org",
|
||||
"test18@tests.mozilla.org",
|
||||
]);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that switching to date ordering works
|
||||
add_test(function() {
|
||||
set_order("updateDate", false);
|
||||
|
||||
// When we're ascending with updateDate, it's from newest
|
||||
// to oldest.
|
||||
|
||||
check_order([
|
||||
"test5@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
"test1@tests.mozilla.org",
|
||||
"test2@tests.mozilla.org",
|
||||
"test4@tests.mozilla.org",
|
||||
"test10@tests.mozilla.org",
|
||||
"test9@tests.mozilla.org",
|
||||
"test8@tests.mozilla.org",
|
||||
"test6@tests.mozilla.org",
|
||||
"test7@tests.mozilla.org",
|
||||
"test12@tests.mozilla.org",
|
||||
"test14@tests.mozilla.org",
|
||||
"test15@tests.mozilla.org",
|
||||
"test13@tests.mozilla.org",
|
||||
"test11@tests.mozilla.org",
|
||||
"test20@tests.mozilla.org",
|
||||
"test17@tests.mozilla.org",
|
||||
"test18@tests.mozilla.org",
|
||||
"test19@tests.mozilla.org",
|
||||
"test16@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
set_order("updateDate", true);
|
||||
|
||||
check_order([
|
||||
"test4@tests.mozilla.org",
|
||||
"test2@tests.mozilla.org",
|
||||
"test1@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
"test5@tests.mozilla.org",
|
||||
"test7@tests.mozilla.org",
|
||||
"test6@tests.mozilla.org",
|
||||
"test8@tests.mozilla.org",
|
||||
"test9@tests.mozilla.org",
|
||||
"test10@tests.mozilla.org",
|
||||
"test11@tests.mozilla.org",
|
||||
"test13@tests.mozilla.org",
|
||||
"test15@tests.mozilla.org",
|
||||
"test14@tests.mozilla.org",
|
||||
"test12@tests.mozilla.org",
|
||||
"test16@tests.mozilla.org",
|
||||
"test19@tests.mozilla.org",
|
||||
"test18@tests.mozilla.org",
|
||||
"test17@tests.mozilla.org",
|
||||
"test20@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that switching to name ordering works
|
||||
add_test(function() {
|
||||
set_order("name", true);
|
||||
|
||||
check_order([
|
||||
"test2@tests.mozilla.org",
|
||||
"test4@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
"test5@tests.mozilla.org",
|
||||
"test1@tests.mozilla.org",
|
||||
"test7@tests.mozilla.org",
|
||||
"test8@tests.mozilla.org",
|
||||
"test6@tests.mozilla.org",
|
||||
"test10@tests.mozilla.org",
|
||||
"test9@tests.mozilla.org",
|
||||
"test11@tests.mozilla.org",
|
||||
"test13@tests.mozilla.org",
|
||||
"test12@tests.mozilla.org",
|
||||
"test14@tests.mozilla.org",
|
||||
"test15@tests.mozilla.org",
|
||||
"test17@tests.mozilla.org",
|
||||
"test19@tests.mozilla.org",
|
||||
"test16@tests.mozilla.org",
|
||||
"test20@tests.mozilla.org",
|
||||
"test18@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
set_order("name", false);
|
||||
|
||||
check_order([
|
||||
"test1@tests.mozilla.org",
|
||||
"test5@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
"test4@tests.mozilla.org",
|
||||
"test2@tests.mozilla.org",
|
||||
"test9@tests.mozilla.org",
|
||||
"test10@tests.mozilla.org",
|
||||
"test6@tests.mozilla.org",
|
||||
"test8@tests.mozilla.org",
|
||||
"test7@tests.mozilla.org",
|
||||
"test15@tests.mozilla.org",
|
||||
"test14@tests.mozilla.org",
|
||||
"test12@tests.mozilla.org",
|
||||
"test13@tests.mozilla.org",
|
||||
"test11@tests.mozilla.org",
|
||||
"test18@tests.mozilla.org",
|
||||
"test20@tests.mozilla.org",
|
||||
"test16@tests.mozilla.org",
|
||||
"test19@tests.mozilla.org",
|
||||
"test17@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -1,109 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that sorting of plugins works correctly
|
||||
// (this test checks that plugins with "ask to activate" state appear after those with
|
||||
// "always activate" and before those with "never activate")
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI features that are not supported in the
|
||||
// HTML about:addons.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
gProvider.createAddons([
|
||||
{
|
||||
// enabledInstalled group
|
||||
// * Always activate
|
||||
// * Ask to activate
|
||||
// * Never activate
|
||||
id: "test1@tests.mozilla.org",
|
||||
name: "Java Applet Plug-in Java 7 Update 51",
|
||||
description: "foo",
|
||||
type: "plugin",
|
||||
isActive: true,
|
||||
userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE,
|
||||
},
|
||||
{
|
||||
id: "test2@tests.mozilla.org",
|
||||
name: "Quick Time Plug-in",
|
||||
description: "foo",
|
||||
type: "plugin",
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
},
|
||||
{
|
||||
id: "test3@tests.mozilla.org",
|
||||
name: "Shockwave Flash",
|
||||
description: "foo",
|
||||
type: "plugin",
|
||||
isActive: false,
|
||||
userDisabled: true,
|
||||
},
|
||||
{
|
||||
id: "test4@tests.mozilla.org",
|
||||
name: "Adobe Reader Plug-in",
|
||||
description: "foo",
|
||||
type: "plugin",
|
||||
isActive: true,
|
||||
userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE,
|
||||
},
|
||||
{
|
||||
id: "test5@tests.mozilla.org",
|
||||
name: "3rd Party Plug-in",
|
||||
description: "foo",
|
||||
type: "plugin",
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager("addons://list/plugin");
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
function check_order(aExpectedOrder) {
|
||||
var order = [];
|
||||
var list = gManagerWindow.document.getElementById("addon-list");
|
||||
var node = list.firstChild;
|
||||
while (node) {
|
||||
var id = node.getAttribute("value");
|
||||
if (id && id.endsWith("@tests.mozilla.org")) {
|
||||
order.push(node.getAttribute("value"));
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
is(
|
||||
order.toSource(),
|
||||
aExpectedOrder.toSource(),
|
||||
"Should have seen the right order"
|
||||
);
|
||||
}
|
||||
|
||||
// Tests that ascending name ordering was the default
|
||||
add_test(function() {
|
||||
check_order([
|
||||
"test5@tests.mozilla.org",
|
||||
"test2@tests.mozilla.org",
|
||||
"test4@tests.mozilla.org",
|
||||
"test1@tests.mozilla.org",
|
||||
"test3@tests.mozilla.org",
|
||||
]);
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -1,77 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests various aspects of the details view
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "tabsettings@tests.mozilla.org",
|
||||
name: "Tab Settings",
|
||||
version: "1",
|
||||
optionsURL: CHROMEROOT + "addon_prefs.xul",
|
||||
optionsType: AddonManager.OPTIONS_TYPE_TAB,
|
||||
},
|
||||
]);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
add_test(function() {
|
||||
var addon = get_addon_element(
|
||||
gManagerWindow,
|
||||
"tabsettings@tests.mozilla.org"
|
||||
);
|
||||
is(
|
||||
addon.mAddon.optionsType,
|
||||
AddonManager.OPTIONS_TYPE_TAB,
|
||||
"Options should be inline type"
|
||||
);
|
||||
addon.parentNode.ensureElementIsVisible(addon);
|
||||
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
addon,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is_element_visible(button, "Preferences button should be visible");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
|
||||
var browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
function() {
|
||||
is(
|
||||
browser.currentURI.spec,
|
||||
addon.mAddon.optionsURL,
|
||||
"New tab should have loaded the options URL"
|
||||
);
|
||||
browser.contentWindow.close();
|
||||
run_next_test();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
@ -1,184 +0,0 @@
|
||||
const { AddonTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/AddonTestUtils.jsm"
|
||||
);
|
||||
|
||||
let gManagerWindow;
|
||||
let gCategoryUtilities;
|
||||
|
||||
// This test is testing the theme list at XUL about:addons. HTML about:addons's
|
||||
// theme list is already tested in browser_html_list_view.js.
|
||||
// The testThemeOrdering part of this test should be adapted when bug 1557768
|
||||
// is fixed.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
// AddonTestUtils with open_manager cause this reference to be maintained and creates a leak.
|
||||
gManagerWindow = null;
|
||||
});
|
||||
|
||||
function imageBufferFromDataURI(encodedImageData) {
|
||||
let decodedImageData = atob(encodedImageData);
|
||||
return Uint8Array.from(decodedImageData, byte => byte.charCodeAt(0)).buffer;
|
||||
}
|
||||
const img =
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==";
|
||||
const imageBuffer = imageBufferFromDataURI(img);
|
||||
|
||||
const id = "theme@mochi.test";
|
||||
|
||||
AddonTestUtils.initMochitest(this);
|
||||
|
||||
function getThemeData(_id = id, manifest = {}, files = {}) {
|
||||
return {
|
||||
"manifest.json": {
|
||||
applications: {
|
||||
gecko: { id: _id },
|
||||
},
|
||||
manifest_version: 2,
|
||||
name: "atheme",
|
||||
description: "wow. such theme.",
|
||||
author: "Pixel Pusher",
|
||||
version: "1",
|
||||
theme: {},
|
||||
...manifest,
|
||||
},
|
||||
"preview.png": imageBuffer,
|
||||
...files,
|
||||
};
|
||||
}
|
||||
|
||||
async function init(startPage) {
|
||||
gManagerWindow = await open_manager(null);
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
return gCategoryUtilities.openType(startPage);
|
||||
}
|
||||
|
||||
add_task(async function testThemePreviewShown() {
|
||||
await init("theme");
|
||||
|
||||
await AddonTestUtils.promiseInstallXPI(getThemeData());
|
||||
let theme = await AddonManager.getAddonByID(id);
|
||||
|
||||
ok(theme.screenshots[0].url, "The add-on has a preview URL");
|
||||
let previewURL = theme.screenshots[0].url;
|
||||
|
||||
let doc = gManagerWindow.document;
|
||||
let item = doc.querySelector(`richlistitem[value="${id}"]`);
|
||||
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() =>
|
||||
item.getAttribute("status") == "installed" &&
|
||||
item.getAttribute("previewURL"),
|
||||
"Wait for the item to update to installed"
|
||||
);
|
||||
|
||||
is(
|
||||
item.getAttribute("previewURL"),
|
||||
previewURL,
|
||||
"The previewURL is set on the item"
|
||||
);
|
||||
let image = doc.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"theme-screenshot"
|
||||
);
|
||||
is(image.src, previewURL, "The previewURL is set on the image src");
|
||||
|
||||
item.click();
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
|
||||
image = doc.querySelector(".theme-screenshot");
|
||||
is(image.src, previewURL, "The previewURL is set on the detail image src");
|
||||
|
||||
// Now check that an add-on doesn't have a preview (bug 1519616).
|
||||
let extensionId = "extension@mochi.test";
|
||||
await AddonTestUtils.promiseInstallXPI({
|
||||
"manifest.json": {
|
||||
applications: {
|
||||
gecko: { id: extensionId },
|
||||
},
|
||||
manifest_version: 2,
|
||||
name: "anextension",
|
||||
description: "wow. such extension.",
|
||||
author: "Woof",
|
||||
version: "1",
|
||||
},
|
||||
});
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
|
||||
// Go to the detail page.
|
||||
item = doc.querySelector(`richlistitem[value="${extensionId}"]`);
|
||||
item.click();
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
|
||||
// Check that the image has no src attribute.
|
||||
image = doc.querySelector(".theme-screenshot");
|
||||
ok(!image.src, "There is no preview for extensions");
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
await theme.uninstall();
|
||||
|
||||
let extension = await AddonManager.getAddonByID(extensionId);
|
||||
await extension.uninstall();
|
||||
});
|
||||
|
||||
add_task(async function testThemeOrdering() {
|
||||
// Install themes before loading the manager, if it's open they'll sort by install date.
|
||||
let themeId = id => id + "@mochi.test";
|
||||
let themeIds = [themeId(5), themeId(6), themeId(7), themeId(8)];
|
||||
await AddonTestUtils.promiseInstallXPI(
|
||||
getThemeData(themeId(6), { name: "BBB" })
|
||||
);
|
||||
await AddonTestUtils.promiseInstallXPI(
|
||||
getThemeData(themeId(7), { name: "CCC" })
|
||||
);
|
||||
await AddonTestUtils.promiseInstallXPI(
|
||||
getThemeData(themeId(5), { name: "AAA" }, { previewURL: "" })
|
||||
);
|
||||
await AddonTestUtils.promiseInstallXPI(
|
||||
getThemeData(themeId(8), { name: "DDD" })
|
||||
);
|
||||
|
||||
// Enable a theme to make sure it's first.
|
||||
let addon = await AddonManager.getAddonByID(themeId(8));
|
||||
addon.enable();
|
||||
|
||||
// Load themes now that the extensions are setup.
|
||||
await init("theme");
|
||||
|
||||
// Find the order of ids for the ones we installed.
|
||||
let list = gManagerWindow.document.getElementById("addon-list");
|
||||
let idOrder = list.itemChildren
|
||||
.map(row => row.getAttribute("value"))
|
||||
.filter(id => themeIds.includes(id));
|
||||
|
||||
// Check the order.
|
||||
Assert.deepEqual(
|
||||
idOrder,
|
||||
[
|
||||
themeId(8), // The active theme first.
|
||||
themeId(6),
|
||||
themeId(7), // With previews, ordered by name.
|
||||
themeId(5), // The theme without a preview last.
|
||||
],
|
||||
"Themes are ordered by enabled, previews, then name"
|
||||
);
|
||||
|
||||
// Ensure allow in private mode badge is hidden for themes.
|
||||
for (let item of list.itemChildren) {
|
||||
let badge = gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"privateBrowsing"
|
||||
);
|
||||
is_element_hidden(badge, `private browsing badge is hidden`);
|
||||
}
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
for (let addon of await promiseAddonsByIDs(themeIds)) {
|
||||
await addon.uninstall();
|
||||
}
|
||||
});
|
@ -1,513 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that registering new types works
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
||||
var gProvider = {};
|
||||
|
||||
var gTypes = [
|
||||
new AddonManagerPrivate.AddonType(
|
||||
"type1",
|
||||
null,
|
||||
"Type 1",
|
||||
AddonManager.VIEW_TYPE_LIST,
|
||||
4500
|
||||
),
|
||||
new AddonManagerPrivate.AddonType("missing1", null, "Missing 1"),
|
||||
new AddonManagerPrivate.AddonType(
|
||||
"type2",
|
||||
null,
|
||||
"Type 1",
|
||||
AddonManager.VIEW_TYPE_LIST,
|
||||
5100,
|
||||
AddonManager.TYPE_UI_HIDE_EMPTY
|
||||
),
|
||||
{
|
||||
id: "type3",
|
||||
name: "Type 3",
|
||||
uiPriority: 5200,
|
||||
viewType: AddonManager.VIEW_TYPE_LIST,
|
||||
},
|
||||
];
|
||||
|
||||
// This test is testing XUL about:addons UI features that are not supported in the
|
||||
// HTML about:addons.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
function go_back(aManager) {
|
||||
gBrowser.goBack();
|
||||
}
|
||||
|
||||
function go_forward(aManager) {
|
||||
gBrowser.goForward();
|
||||
}
|
||||
|
||||
function check_state(canGoBack, canGoForward) {
|
||||
is(gBrowser.canGoBack, canGoBack, "canGoBack should be correct");
|
||||
is(gBrowser.canGoForward, canGoForward, "canGoForward should be correct");
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
finish();
|
||||
}
|
||||
|
||||
// Add a new type, open the manager and make sure it is in the right place
|
||||
add_test(async function() {
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
|
||||
ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
|
||||
|
||||
is(
|
||||
gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
|
||||
"addons://list/extension",
|
||||
"Type 1 should be in the right place"
|
||||
);
|
||||
is(
|
||||
gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
|
||||
"addons://list/theme",
|
||||
"Type 2 should be in the right place"
|
||||
);
|
||||
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Select the type, close the manager and remove it then open the manager and
|
||||
// check we're back to the default view
|
||||
add_test(async function() {
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await close_manager(gManagerWindow);
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
|
||||
ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
|
||||
ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
|
||||
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be back to the default view"
|
||||
);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Add a type while the manager is still open and check it appears
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
|
||||
ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
|
||||
ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
|
||||
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
|
||||
ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
|
||||
|
||||
is(
|
||||
gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
|
||||
"addons://list/extension",
|
||||
"Type 1 should be in the right place"
|
||||
);
|
||||
is(
|
||||
gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
|
||||
"addons://list/theme",
|
||||
"Type 2 should be in the right place"
|
||||
);
|
||||
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Remove the type while it is beng viewed and check it is replaced with the
|
||||
// default view
|
||||
add_test(async function() {
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"type1",
|
||||
"Should be showing the custom view"
|
||||
);
|
||||
check_state(true, true);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
|
||||
ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
|
||||
ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
|
||||
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be back to the default view"
|
||||
);
|
||||
check_state(true, true);
|
||||
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be showing the extension view"
|
||||
);
|
||||
check_state(false, true);
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be back to the default view"
|
||||
);
|
||||
check_state(true, true);
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"plugin",
|
||||
"Should be back to the plugins view"
|
||||
);
|
||||
check_state(true, false);
|
||||
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be back to the default view"
|
||||
);
|
||||
check_state(true, true);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going back to a now missing category we skip it
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be back to the first view"
|
||||
);
|
||||
check_state(false, true);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going forward to a now missing category we skip it
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be back to the extension view"
|
||||
);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"plugin",
|
||||
"Should be back to the plugin view"
|
||||
);
|
||||
check_state(true, false);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going back to a now missing category and we can't go back any
|
||||
// any further then we just display the default view
|
||||
add_test(async function() {
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
let aWindow = await open_manager("addons://list/type1");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"type1",
|
||||
"Should be at the custom view"
|
||||
);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be at the default view"
|
||||
);
|
||||
check_state(false, true);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going forward to a now missing category and we can't go
|
||||
// forward any further then we just display the default view
|
||||
add_test(async function() {
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be at the extension view"
|
||||
);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be at the default view"
|
||||
);
|
||||
check_state(true, false);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going back we skip multiple missing categories
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("type3");
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be back to the first view"
|
||||
);
|
||||
check_state(false, true);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going forward we skip multiple missing categories
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("type3");
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
go_back(gManagerWindow);
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be back to the extension view"
|
||||
);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"plugin",
|
||||
"Should be back to the plugin view"
|
||||
);
|
||||
check_state(true, false);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going back we skip all missing categories and when we can't go
|
||||
// back any any further then we just display the default view
|
||||
add_test(async function() {
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
let aWindow = await open_manager("addons://list/type1");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"type1",
|
||||
"Should be at the custom view"
|
||||
);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type3");
|
||||
await gCategoryUtilities.openType("extension");
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be at the default view"
|
||||
);
|
||||
check_state(false, true);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test that when going forward we skip all missing categories and when we can't
|
||||
// go back any any further then we just display the default view
|
||||
add_test(async function() {
|
||||
AddonManagerPrivate.registerProvider(gProvider, gTypes);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
|
||||
ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
|
||||
|
||||
await gCategoryUtilities.openType("type1");
|
||||
await gCategoryUtilities.openType("type3");
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
go_back(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be at the extension view"
|
||||
);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(gProvider);
|
||||
|
||||
ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
|
||||
|
||||
go_forward(gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should be at the default view"
|
||||
);
|
||||
check_state(true, false);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
@ -1,666 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var gManagerWindow;
|
||||
var gDocument;
|
||||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons has its
|
||||
// own test files for these test cases).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
async function setup_manager(...args) {
|
||||
let aWindow = await open_manager(...args);
|
||||
gManagerWindow = aWindow;
|
||||
gDocument = gManagerWindow.document;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
requestLongerTimeout(2);
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon2@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 1",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon3@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 2",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon4@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 3",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon5@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 4",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon6@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 5",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon7@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 6",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon8@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 7",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
{
|
||||
id: "addon9@tests.mozilla.org",
|
||||
name: "Uninstall doesn't need restart 8",
|
||||
type: "extension",
|
||||
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
|
||||
},
|
||||
]);
|
||||
|
||||
await setup_manager(null);
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
async function end_test() {
|
||||
await close_manager(gManagerWindow);
|
||||
finish();
|
||||
}
|
||||
|
||||
function get_item_in_list(aId, aList) {
|
||||
var item = aList.firstChild;
|
||||
while (item) {
|
||||
if ("mAddon" in item && item.mAddon.id == aId) {
|
||||
aList.ensureElementIsVisible(item);
|
||||
return item;
|
||||
}
|
||||
item = item.nextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Tests that uninstalling a restartless add-on from the list view can be undone
|
||||
add_test(async function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
|
||||
ok(
|
||||
aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that uninstalling a disabled restartless add-on from the list view can
|
||||
// be undone and doesn't re-enable
|
||||
add_test(async function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
await aAddon.disable();
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
|
||||
ok(
|
||||
aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
await aAddon.enable();
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
async function test_uninstall_details(aAddon, ID) {
|
||||
is(
|
||||
get_current_view(gManagerWindow).id,
|
||||
"detail-view",
|
||||
"Should be in the detail view"
|
||||
);
|
||||
|
||||
var button = gDocument.getElementById("detail-uninstall-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
|
||||
ok(
|
||||
!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
// Tests that uninstalling a restartless add-on from the details view switches
|
||||
// back to the list view and can be undone
|
||||
add_test(async function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
item.click();
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
|
||||
// Test the uninstall.
|
||||
return test_uninstall_details(aAddon, ID);
|
||||
});
|
||||
|
||||
// Tests that uninstalling a restartless add-on from directly loading the
|
||||
// details view switches back to the list view and can be undone
|
||||
add_test(async function() {
|
||||
// Close this about:addons and open a new one in a new tab.
|
||||
await close_manager(gManagerWindow);
|
||||
|
||||
// Load the detail view directly.
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
await setup_manager(`addons://detail/${ID}`);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
// Test the uninstall.
|
||||
return test_uninstall_details(aAddon, ID);
|
||||
});
|
||||
|
||||
// Tests that uninstalling a restartless add-on from the details view switches
|
||||
// back to the list view and can be undone and doesn't re-enable
|
||||
add_test(async function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
await aAddon.disable();
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
item.click();
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
get_current_view(gManagerWindow).id,
|
||||
"detail-view",
|
||||
"Should be in the detail view"
|
||||
);
|
||||
|
||||
var button = gDocument.getElementById("detail-uninstall-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
|
||||
ok(
|
||||
!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
await aAddon.enable();
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that switching away from the list view finalises the uninstall of
|
||||
// multiple restartless add-ons
|
||||
add_test(async function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var ID2 = "addon6@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
ok(
|
||||
aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
item = get_item_in_list(ID2, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
await gCategoryUtilities.openType("plugin");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"plugin",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
|
||||
is(bAddon, null, "Add-on should no longer be installed");
|
||||
is(bAddon2, null, "Second add-on should no longer be installed");
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
item = get_item_in_list(ID, list);
|
||||
is(item, null, "Should not have found the add-on in the list");
|
||||
item = get_item_in_list(ID2, list);
|
||||
is(item, null, "Should not have found the second add-on in the list");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that closing the manager from the list view finalises the uninstall of
|
||||
// multiple restartless add-ons
|
||||
add_test(async function() {
|
||||
var ID = "addon4@tests.mozilla.org";
|
||||
var ID2 = "addon8@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("addon-list");
|
||||
|
||||
// Select the extensions category
|
||||
await gCategoryUtilities.openType("extension");
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID(ID);
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(
|
||||
!(
|
||||
aAddon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_UNINSTALL
|
||||
),
|
||||
"Add-on should not require a restart to uninstall"
|
||||
);
|
||||
ok(
|
||||
!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
|
||||
"Add-on should not be pending uninstall"
|
||||
);
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(
|
||||
item.getAttribute("pending"),
|
||||
"uninstall",
|
||||
"Add-on should be uninstalling"
|
||||
);
|
||||
|
||||
ok(
|
||||
aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
|
||||
"Add-on should be pending uninstall"
|
||||
);
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
item = get_item_in_list(ID2, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"remove-btn"
|
||||
);
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
|
||||
|
||||
await close_manager(gManagerWindow);
|
||||
let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
|
||||
is(bAddon, null, "Add-on should no longer be installed");
|
||||
is(bAddon2, null, "Second add-on should no longer be installed");
|
||||
|
||||
await setup_manager(null);
|
||||
list = gDocument.getElementById("addon-list");
|
||||
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"View should have changed to extension"
|
||||
);
|
||||
|
||||
item = get_item_in_list(ID, list);
|
||||
is(item, null, "Should not have found the add-on in the list");
|
||||
item = get_item_in_list(ID2, list);
|
||||
is(item, null, "Should not have found the second add-on in the list");
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -9,18 +9,10 @@ var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
||||
function getName(item) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return item.querySelector(".addon-name").textContent;
|
||||
}
|
||||
return gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"name"
|
||||
).textContent;
|
||||
}
|
||||
|
||||
async function getUpdateButton(item) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
let button = item.querySelector('[action="install-update"]');
|
||||
let panel = button.closest("panel-list");
|
||||
let shown = BrowserTestUtils.waitForEvent(panel, "shown");
|
||||
@ -28,14 +20,8 @@ async function getUpdateButton(item) {
|
||||
await shown;
|
||||
return button;
|
||||
}
|
||||
return gManagerWindow.document.getAnonymousElementByAttribute(
|
||||
item,
|
||||
"anonid",
|
||||
"update-btn"
|
||||
);
|
||||
}
|
||||
|
||||
async function test_updateid() {
|
||||
add_task(async function test_updateid() {
|
||||
// Close the existing about:addons tab and unrestier the existing MockProvider
|
||||
// instance if a previous failed test has not been able to clear them.
|
||||
if (gManagerWindow) {
|
||||
@ -97,24 +83,4 @@ async function test_updateid() {
|
||||
gManagerWindow = null;
|
||||
gProvider.unregister();
|
||||
gProvider = null;
|
||||
}
|
||||
|
||||
add_task(async function test_XUL_updateid() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
await test_updateid();
|
||||
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function test_HTML_updateid() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
await test_updateid();
|
||||
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
@ -66,36 +66,6 @@ add_task(async function test_addon_icon() {
|
||||
const extension = ExtensionTestUtils.loadExtension(extensionDefinition);
|
||||
await extension.startup();
|
||||
|
||||
info(`Testing XUL about:addons`);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
await checkIconInView("addons://list/extension", "list", doc => {
|
||||
const addon = get_addon_element(doc.defaultView, id);
|
||||
const content = doc.getAnonymousElementByAttribute(
|
||||
addon,
|
||||
"class",
|
||||
"content-container"
|
||||
);
|
||||
return content.querySelector(".icon");
|
||||
});
|
||||
|
||||
await checkIconInView(
|
||||
"addons://detail/" + encodeURIComponent(id),
|
||||
"details",
|
||||
doc => {
|
||||
return doc.getElementById("detail-icon");
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
||||
info(`Testing HTML about:addons`);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
|
||||
await checkIconInView("addons://list/extension", "list", doc => {
|
||||
return get_addon_element(doc.defaultView, id).querySelector(".addon-icon");
|
||||
});
|
||||
@ -110,7 +80,5 @@ add_task(async function test_addon_icon() {
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
||||
await extension.unload();
|
||||
});
|
||||
|
@ -16,26 +16,15 @@ AddonTestUtils.initMochitest(this);
|
||||
function get_test_items() {
|
||||
var items = {};
|
||||
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
for (let item of gManagerWindow
|
||||
.getHtmlBrowser()
|
||||
.contentDocument.querySelectorAll("addon-card")) {
|
||||
items[item.getAttribute("addon-id")] = item;
|
||||
}
|
||||
} else {
|
||||
for (let item of gManagerWindow.document.getElementById("addon-list")
|
||||
.childNodes) {
|
||||
items[item.mAddon.id] = item;
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function get(aId) {
|
||||
return gManagerWindow.document.getElementById(aId);
|
||||
}
|
||||
|
||||
function getHtmlElem(selector) {
|
||||
return gManagerWindow
|
||||
.getHtmlBrowser()
|
||||
@ -43,48 +32,28 @@ function getHtmlElem(selector) {
|
||||
}
|
||||
|
||||
function getPrivateBrowsingBadge(card) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return card.querySelector(".addon-badge-private-browsing-allowed");
|
||||
}
|
||||
return card.ownerDocument.getAnonymousElementByAttribute(
|
||||
card,
|
||||
"anonid",
|
||||
"privateBrowsing"
|
||||
);
|
||||
}
|
||||
|
||||
function getPreferencesButtonAtListView(card) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return card.querySelector("panel-item[action='preferences']");
|
||||
}
|
||||
return card._preferencesBtn;
|
||||
}
|
||||
|
||||
function getPreferencesButtonAtDetailsView() {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return getHtmlElem("panel-item[action='preferences']");
|
||||
}
|
||||
return gManagerWindow.document.getElementById("detail-prefs-btn");
|
||||
}
|
||||
|
||||
function isInlineOptionsVisible() {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
// The following button is used to open the inline options browser.
|
||||
return !getHtmlElem("named-deck-button[name='preferences']").hidden;
|
||||
}
|
||||
return !!gManagerWindow.document.getElementById("addon-options");
|
||||
}
|
||||
|
||||
function getPrivateBrowsingValue() {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
return getHtmlElem("input[type='radio'][name='private-browsing']:checked")
|
||||
.value;
|
||||
}
|
||||
return gManagerWindow.document.getElementById("detail-privateBrowsing").value;
|
||||
}
|
||||
|
||||
async function setPrivateBrowsingValue(value) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
let radio = getHtmlElem(
|
||||
`input[type="radio"][name="private-browsing"][value="${value}"]`
|
||||
);
|
||||
@ -98,20 +67,9 @@ async function setPrivateBrowsingValue(value) {
|
||||
`Waiting for privateBrowsing=${value}`
|
||||
);
|
||||
}
|
||||
let privateBrowsing = gManagerWindow.document.getElementById(
|
||||
"detail-privateBrowsing"
|
||||
);
|
||||
let radio = privateBrowsing.querySelector(`radio[value="${value}"]`);
|
||||
EventUtils.synthesizeMouseAtCenter(radio, { clickCount: 1 }, gManagerWindow);
|
||||
return TestUtils.waitForCondition(
|
||||
() => privateBrowsing.value == value,
|
||||
`Waiting for privateBrowsing=${value}`
|
||||
);
|
||||
}
|
||||
|
||||
// Check whether the private browsing inputs are visible in the details view.
|
||||
function checkIsModifiable(expected) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
getHtmlElem(".addon-detail-row-private-browsing"),
|
||||
@ -124,32 +82,10 @@ function checkIsModifiable(expected) {
|
||||
);
|
||||
}
|
||||
checkHelpRow(".addon-detail-row-private-browsing", expected);
|
||||
return;
|
||||
}
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-row"),
|
||||
"Private browsing should be visible"
|
||||
);
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-row-footer"),
|
||||
"Private browsing footer should be visible"
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-row"),
|
||||
"Private browsing should be hidden"
|
||||
);
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-row-footer"),
|
||||
"Private browsing footer should be hidden"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the details view shows that private browsing is forcibly disallowed.
|
||||
function checkIsDisallowed(expected) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
getHtmlElem(".addon-detail-row-private-browsing-disallowed"),
|
||||
@ -162,32 +98,10 @@ function checkIsDisallowed(expected) {
|
||||
);
|
||||
}
|
||||
checkHelpRow(".addon-detail-row-private-browsing-disallowed", expected);
|
||||
return;
|
||||
}
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-disallowed"),
|
||||
"Private browsing should be disallowed"
|
||||
);
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-disallowed-footer"),
|
||||
"Private browsing footer should be disallowed"
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-disallowed"),
|
||||
"Private browsing should not be disallowed"
|
||||
);
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-disallowed-footer"),
|
||||
"Private browsing footer should not be disallowed"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the details view shows that private browsing is forcibly allowed.
|
||||
function checkIsRequired(expected) {
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
getHtmlElem(".addon-detail-row-private-browsing-required"),
|
||||
@ -200,27 +114,6 @@ function checkIsRequired(expected) {
|
||||
);
|
||||
}
|
||||
checkHelpRow(".addon-detail-row-private-browsing-required", expected);
|
||||
return;
|
||||
}
|
||||
if (expected) {
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-required"),
|
||||
"Private required should be visible"
|
||||
);
|
||||
is_element_visible(
|
||||
get("detail-privateBrowsing-required-footer"),
|
||||
"Private required footer should be visible"
|
||||
);
|
||||
} else {
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-required"),
|
||||
"Private required should be hidden"
|
||||
);
|
||||
is_element_hidden(
|
||||
get("detail-privateBrowsing-required-footer"),
|
||||
"Private required footer should be hidden"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function checkHelpRow(selector, expected) {
|
||||
@ -249,7 +142,7 @@ add_task(function clearInitialTelemetry() {
|
||||
Services.telemetry.clearEvents();
|
||||
});
|
||||
|
||||
async function test_badge_and_toggle_incognito() {
|
||||
add_task(async function test_badge_and_toggle_incognito() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.allowPrivateBrowsingByDefault", false]],
|
||||
});
|
||||
@ -393,9 +286,9 @@ async function test_badge_and_toggle_incognito() {
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
|
||||
}
|
||||
});
|
||||
|
||||
async function test_addon_preferences_button() {
|
||||
add_task(async function test_addon_preferences_button() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.allowPrivateBrowsingByDefault", false]],
|
||||
});
|
||||
@ -468,18 +361,10 @@ async function test_addon_preferences_button() {
|
||||
};
|
||||
|
||||
const setAddonPrivateBrowsingAccess = async (id, allowPrivateBrowsing) => {
|
||||
let cardUpdatedPromise;
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
cardUpdatedPromise = BrowserTestUtils.waitForEvent(
|
||||
const cardUpdatedPromise = BrowserTestUtils.waitForEvent(
|
||||
getHtmlElem("addon-card"),
|
||||
"update"
|
||||
);
|
||||
} else {
|
||||
cardUpdatedPromise = BrowserTestUtils.waitForEvent(
|
||||
gManagerWindow,
|
||||
"ViewChanged"
|
||||
);
|
||||
}
|
||||
is(
|
||||
getPrivateBrowsingValue(),
|
||||
allowPrivateBrowsing ? "0" : "1",
|
||||
@ -510,14 +395,12 @@ async function test_addon_preferences_button() {
|
||||
allowPrivateBrowsing ? "added" : "removed"
|
||||
}`
|
||||
);
|
||||
if (gManagerWindow.useHtmlViews) {
|
||||
let badge = getPrivateBrowsingBadge(getHtmlElem("addon-card"));
|
||||
is(
|
||||
!badge.hidden,
|
||||
allowPrivateBrowsing,
|
||||
`Expected private browsing badge at ${id}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const extensions = [];
|
||||
@ -574,14 +457,13 @@ async function test_addon_preferences_button() {
|
||||
// run tests in private and non-private windows.
|
||||
await runTest(true);
|
||||
await runTest(false);
|
||||
}
|
||||
});
|
||||
|
||||
async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
|
||||
add_task(async function test_addon_postinstall_incognito_hidden_checkbox() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.allowPrivateBrowsingByDefault", false],
|
||||
["extensions.langpacks.signatures.required", false],
|
||||
["extensions.htmlaboutaddons.enabled", withHtmlViews],
|
||||
],
|
||||
});
|
||||
|
||||
@ -708,9 +590,7 @@ async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
|
||||
// It is not possible to create a privileged add-on and install it, so just
|
||||
// simulate an installed privileged add-on and check the UI.
|
||||
await test_incognito_of_privileged_addons();
|
||||
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
}
|
||||
});
|
||||
|
||||
// Checks that the private browsing flag of privileged add-ons cannot be modified.
|
||||
async function test_incognito_of_privileged_addons() {
|
||||
@ -753,53 +633,3 @@ async function test_incognito_of_privileged_addons() {
|
||||
|
||||
provider.unregister();
|
||||
}
|
||||
|
||||
add_task(async function test_badge_and_toggle_incognito_on_XUL_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
await test_badge_and_toggle_incognito();
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function test_badge_and_toggle_incognito_on_HTML_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", true]],
|
||||
});
|
||||
await test_badge_and_toggle_incognito();
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function test_addon_preferences_button_on_XUL_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", false],
|
||||
["extensions.htmlaboutaddons.inline-options.enabled", false],
|
||||
],
|
||||
});
|
||||
await test_addon_preferences_button();
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(async function test_addon_preferences_button_on_HTML_aboutaddons() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.enabled", true],
|
||||
["extensions.htmlaboutaddons.inline-options.enabled", true],
|
||||
],
|
||||
});
|
||||
await test_addon_preferences_button();
|
||||
// No popPrefEnv because of bug 1557397.
|
||||
});
|
||||
|
||||
add_task(
|
||||
async function test_addon_postinstall_incognito_hidden_checkbox_on_XUL_aboutaddons() {
|
||||
await test_addon_postinstall_incognito_hidden_checkbox(false);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function test_addon_postinstall_incognito_hidden_checkbox_on_HTML_aboutaddons() {
|
||||
await test_addon_postinstall_incognito_hidden_checkbox(true);
|
||||
}
|
||||
);
|
||||
|
@ -1,124 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
ChromeUtils.import("resource://testing-common/ContentTask.jsm", {});
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons preferences
|
||||
// panel is already tested in browser_html_options_ui.js).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
// Wrapper to run a test that consists of:
|
||||
// 1. opening the add-ons manager viewing the list of extensions
|
||||
// 2. installing an extension (using the provider installer callable)
|
||||
// 3. opening the preferences panel for the new extension and verifying
|
||||
// that it opens cleanly
|
||||
async function runTest(installer) {
|
||||
let mgrWindow = await open_manager("addons://list/extension");
|
||||
|
||||
let { addon, id } = await installer();
|
||||
isnot(addon, null, "Extension is installed");
|
||||
|
||||
let element = get_addon_element(mgrWindow, id);
|
||||
element.parentNode.ensureElementIsVisible(element);
|
||||
|
||||
let button = mgrWindow.document.getAnonymousElementByAttribute(
|
||||
element,
|
||||
"anonid",
|
||||
"preferences-btn"
|
||||
);
|
||||
is_element_visible(button, "Preferences button should be visible");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, mgrWindow);
|
||||
|
||||
await TestUtils.topicObserved(
|
||||
AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
|
||||
(subject, data) => data == id
|
||||
);
|
||||
|
||||
is(
|
||||
mgrWindow.gViewController.currentViewId,
|
||||
`addons://detail/${encodeURIComponent(id)}/preferences`,
|
||||
"Current view should scroll to preferences"
|
||||
);
|
||||
|
||||
var browser = mgrWindow.document.querySelector(
|
||||
"#detail-grid > rows > stack > .inline-options-browser"
|
||||
);
|
||||
ok(browser, "Grid should have a browser descendant");
|
||||
is(browser.localName, "browser", "Grid should have a browser descendant");
|
||||
|
||||
var rows = browser.parentNode;
|
||||
|
||||
await ContentTask.spawn(browser, element.mAddon.optionsURL, async url => {
|
||||
await ContentTaskUtils.waitForCondition(
|
||||
() => content.location.href == url,
|
||||
"Browser has the expected options URL loaded"
|
||||
);
|
||||
});
|
||||
|
||||
is(
|
||||
browser.clientWidth,
|
||||
browser.parentNode.clientWidth,
|
||||
"Browser should be the same width as its direct parent"
|
||||
);
|
||||
is(
|
||||
browser.clientWidth,
|
||||
rows.clientWidth,
|
||||
"Browser should be the same width as its rows ancestor"
|
||||
);
|
||||
|
||||
button = mgrWindow.document.getElementById("detail-prefs-btn");
|
||||
is_element_hidden(button, "Preferences button should not be visible");
|
||||
|
||||
await close_manager(mgrWindow);
|
||||
|
||||
addon.uninstall();
|
||||
}
|
||||
|
||||
function promiseWebExtensionStartup() {
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm",
|
||||
null
|
||||
);
|
||||
|
||||
return new Promise(resolve => {
|
||||
let listener = (event, extension) => {
|
||||
Management.off("startup", listener);
|
||||
resolve(extension);
|
||||
};
|
||||
|
||||
Management.on("startup", listener);
|
||||
});
|
||||
}
|
||||
|
||||
// Test that deferred handling of optionsURL works for a signed webextension
|
||||
add_task(async function test_options_signed() {
|
||||
await runTest(async function() {
|
||||
// The extension in-tree is signed with this ID:
|
||||
const ID = "{9792932b-32b2-4567-998c-e7bf6c4c5e35}";
|
||||
|
||||
await Promise.all([
|
||||
promiseWebExtensionStartup(),
|
||||
install_addon("addons/options_signed.xpi"),
|
||||
]);
|
||||
let addon = await promiseAddonByID(ID);
|
||||
|
||||
return { addon, id: ID };
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_options_temporary() {
|
||||
await runTest(async function() {
|
||||
let dir = get_addon_file_url("options_signed").file;
|
||||
let [addon] = await Promise.all([
|
||||
AddonManager.installTemporaryAddon(dir),
|
||||
promiseWebExtensionStartup(),
|
||||
]);
|
||||
isnot(addon, null, "Extension is installed (temporarily)");
|
||||
|
||||
return { addon, id: addon.id };
|
||||
});
|
||||
});
|
@ -1,126 +0,0 @@
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
const { AddonTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/AddonTestUtils.jsm"
|
||||
);
|
||||
const { ExtensionParent } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionParent.jsm"
|
||||
);
|
||||
|
||||
// This test is testing XUL about:addons UI (the HTML about:addons options page
|
||||
// is tested by the testCardRerender test in browser_html_options_ui.js).
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.enabled", false]],
|
||||
});
|
||||
|
||||
// This test function helps to detect when an addon options browser have been inserted
|
||||
// in the about:addons page.
|
||||
function waitOptionsBrowserInserted() {
|
||||
return new Promise(resolve => {
|
||||
async function listener(eventName, browser) {
|
||||
// wait for a webextension XUL browser element that is owned by the "about:addons" page.
|
||||
if (browser.ownerDocument.location.href == "about:addons") {
|
||||
ExtensionParent.apiManager.off("extension-browser-inserted", listener);
|
||||
|
||||
resolve(browser);
|
||||
}
|
||||
}
|
||||
ExtensionParent.apiManager.on("extension-browser-inserted", listener);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_options_on_addon_reload() {
|
||||
const ID = "@test-options-on-addon-reload";
|
||||
|
||||
function backgroundScript() {
|
||||
const { browser } = window;
|
||||
browser.runtime.openOptionsPage();
|
||||
}
|
||||
|
||||
let extensionDefinition = {
|
||||
useAddonManager: "temporary",
|
||||
|
||||
manifest: {
|
||||
options_ui: {
|
||||
page: "options.html",
|
||||
},
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID,
|
||||
},
|
||||
},
|
||||
},
|
||||
files: {
|
||||
"options.html": `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
Extension Options UI
|
||||
</body>
|
||||
</html>`,
|
||||
},
|
||||
background: backgroundScript,
|
||||
};
|
||||
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:addons");
|
||||
|
||||
const extension = ExtensionTestUtils.loadExtension(extensionDefinition);
|
||||
|
||||
const onceOptionsBrowserInserted = waitOptionsBrowserInserted();
|
||||
|
||||
await extension.startup();
|
||||
|
||||
info("Wait for the options_ui page XUL browser to be created");
|
||||
await onceOptionsBrowserInserted;
|
||||
|
||||
const aboutAddonsDocument = gBrowser.selectedBrowser.contentDocument;
|
||||
|
||||
Assert.equal(
|
||||
aboutAddonsDocument.location.href,
|
||||
"about:addons",
|
||||
"The about:addons page is the currently selected tab"
|
||||
);
|
||||
|
||||
const optionsBrowsers = aboutAddonsDocument.querySelectorAll(
|
||||
"#addon-options"
|
||||
);
|
||||
Assert.equal(
|
||||
optionsBrowsers.length,
|
||||
1,
|
||||
"Got a single XUL browser for the addon options_ui page"
|
||||
);
|
||||
|
||||
// Reload the addon five times in a row, and then check that there is still one addon options browser.
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const onceOptionsReloaded = Promise.all([
|
||||
AddonTestUtils.promiseWebExtensionStartup(),
|
||||
waitOptionsBrowserInserted(),
|
||||
]);
|
||||
|
||||
await addon.reload();
|
||||
|
||||
info("Wait for the new options_ui page XUL browser to be created");
|
||||
await onceOptionsReloaded;
|
||||
|
||||
let optionsBrowsers = aboutAddonsDocument.querySelectorAll(
|
||||
"#addon-options"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
optionsBrowsers.length,
|
||||
1,
|
||||
"Got a single XUL browser for the addon options_ui page"
|
||||
);
|
||||
}
|
||||
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
|
||||
await extension.unload();
|
||||
});
|
@ -248,7 +248,6 @@ function run_next_test() {
|
||||
}
|
||||
|
||||
var get_tooltip_info = async function(addonEl, managerWindow) {
|
||||
if (managerWindow && managerWindow.useHtmlViews) {
|
||||
// Extract from title attribute.
|
||||
const { addon } = addonEl;
|
||||
const name = addon.name;
|
||||
@ -267,45 +266,6 @@ var get_tooltip_info = async function(addonEl, managerWindow) {
|
||||
name,
|
||||
version: nameWithVersion.substring(name.length + 1),
|
||||
};
|
||||
}
|
||||
|
||||
// Retrieve the tooltip from the XUL about:addons view,
|
||||
// the popup code uses a triggering event's target to set the
|
||||
// document.tooltipNode property.
|
||||
let doc = addonEl.ownerDocument;
|
||||
let nameNode = doc.getAnonymousElementByAttribute(addonEl, "anonid", "name");
|
||||
let event = new doc.ownerGlobal.CustomEvent("TriggerEvent");
|
||||
nameNode.dispatchEvent(event);
|
||||
|
||||
let tooltip = doc.getElementById("addonitem-tooltip");
|
||||
|
||||
let promise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
|
||||
tooltip.openPopup(nameNode, "after_start", 0, 0, false, false, event);
|
||||
await promise;
|
||||
|
||||
let tiptext = tooltip.label;
|
||||
|
||||
promise = BrowserTestUtils.waitForEvent(tooltip, "popuphidden");
|
||||
tooltip.hidePopup();
|
||||
await promise;
|
||||
|
||||
let expectedName = addonEl.getAttribute("name");
|
||||
is(
|
||||
tiptext.substring(0, expectedName.length),
|
||||
expectedName,
|
||||
"Tooltip should always start with the expected name"
|
||||
);
|
||||
|
||||
if (expectedName.length == tiptext.length) {
|
||||
return {
|
||||
name: tiptext,
|
||||
version: undefined,
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: tiptext.substring(0, expectedName.length),
|
||||
version: tiptext.substring(expectedName.length + 1),
|
||||
};
|
||||
};
|
||||
|
||||
function get_addon_file_url(aFilename) {
|
||||
@ -371,30 +331,10 @@ function check_all_in_list(aManager, aIds, aIgnoreExtras) {
|
||||
}
|
||||
|
||||
function get_addon_element(aManager, aId) {
|
||||
if (aManager.useHtmlViews) {
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
return doc.querySelector(`addon-card[addon-id="${aId}"]`);
|
||||
}
|
||||
|
||||
const doc = aManager.document;
|
||||
const view = get_current_view(aManager);
|
||||
let listid = "addon-list";
|
||||
if (view.id == "updates-view") {
|
||||
listid = "updates-list";
|
||||
}
|
||||
const list = doc.getElementById(listid);
|
||||
|
||||
let node = list.firstChild;
|
||||
while (node) {
|
||||
if (node.value == aId) {
|
||||
return node;
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function wait_for_view_load(
|
||||
aManagerWindow,
|
||||
aCallback,
|
||||
|
Loading…
Reference in New Issue
Block a user