Bug 1594082 - Remove test code related to XUL about:addons, r=mstriemer

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
JaStenson 2019-11-25 20:36:47 +00:00
Родитель f7e5c21bed
Коммит 0ef4489322
1 изменённых файлов: 26 добавлений и 111 удалений

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

@ -79,137 +79,52 @@ function getAddonCard(doc, id) {
}
function openDetailView(doc, id) {
if (doc.ownerGlobal != gManagerWindow) {
let card = getAddonCard(doc, id);
card.querySelector('[action="expand"]').click();
} else {
getAddonCard(doc, id).click();
}
let card = getAddonCard(doc, id);
card.querySelector('[action="expand"]').click();
}
async function enableAndDisable(doc, row) {
if (doc.ownerGlobal != gManagerWindow) {
let toggleButton = row.querySelector('[action="toggle-disabled"]');
let disabled = BrowserTestUtils.waitForEvent(row, "update");
toggleButton.click();
await disabled;
let enabled = BrowserTestUtils.waitForEvent(row, "update");
toggleButton.click();
await enabled;
} else {
is(row.getAttribute("active"), "true", "The add-on is enabled");
doc.getAnonymousElementByAttribute(row, "anonid", "disable-btn").click();
await TestUtils.waitForCondition(
() => row.getAttribute("active") == "false",
"Wait for disable"
);
doc.getAnonymousElementByAttribute(row, "anonid", "enable-btn").click();
await TestUtils.waitForCondition(
() => row.getAttribute("active") == "true",
"Wait for enable"
);
}
let toggleButton = row.querySelector('[action="toggle-disabled"]');
let disabled = BrowserTestUtils.waitForEvent(row, "update");
toggleButton.click();
await disabled;
let enabled = BrowserTestUtils.waitForEvent(row, "update");
toggleButton.click();
await enabled;
}
async function removeAddonAndUndo(doc, row) {
let isHtml = doc.ownerGlobal != gManagerWindow;
let id = isHtml ? row.addon.id : row.mAddon.id;
let started = AddonTestUtils.promiseWebExtensionStartup(id);
if (isHtml) {
let removed = BrowserTestUtils.waitForEvent(row, "remove");
row.querySelector('[action="remove"]').click();
await removed;
let removed = BrowserTestUtils.waitForEvent(row, "remove");
row.querySelector('[action="remove"]').click();
await removed;
let undoBanner = doc.querySelector(
`message-bar[addon-id="${row.addon.id}"]`
);
undoBanner.querySelector('[action="undo"]').click();
await TestUtils.waitForCondition(() => getAddonCard(doc, row.addon.id));
} else {
is(row.getAttribute("status"), "installed", "The add-on is installed");
ok(!row.hasAttribute("pending"), "The add-on is not pending");
doc.getAnonymousElementByAttribute(row, "anonid", "remove-btn").click();
await TestUtils.waitForCondition(
() => row.getAttribute("pending") == "uninstall",
"Wait for uninstall"
);
doc.getAnonymousElementByAttribute(row, "anonid", "undo-btn").click();
await TestUtils.waitForCondition(
() => !row.hasAttribute("pending"),
"Wait for undo"
);
}
let undoBanner = doc.querySelector(`message-bar[addon-id="${row.addon.id}"]`);
undoBanner.querySelector('[action="undo"]').click();
await TestUtils.waitForCondition(() => getAddonCard(doc, row.addon.id));
await started;
}
async function openPrefs(doc, row) {
if (doc.ownerGlobal != gManagerWindow) {
row.querySelector('[action="preferences"]').click();
} else {
let prefsButton;
await TestUtils.waitForCondition(() => {
prefsButton = doc.getAnonymousElementByAttribute(
row,
"anonid",
"preferences-btn"
);
return prefsButton;
});
prefsButton.click();
}
row.querySelector('[action="preferences"]').click();
}
function changeAutoUpdates(doc) {
if (doc.ownerGlobal != gManagerWindow) {
let row = doc.querySelector(".addon-detail-row-updates");
let checked = row.querySelector(":checked");
is(checked.value, "1", "Use default is selected");
row.querySelector('[value="0"]').click();
row.querySelector('[action="update-check"]').click();
row.querySelector('[value="2"]').click();
row.querySelector('[value="1"]').click();
} else {
let autoUpdate = doc.getElementById("detail-autoUpdate");
is(autoUpdate.value, "1", "Use default is selected");
// Turn off auto update.
autoUpdate.querySelector('[value="0"]').click();
// Check for updates.
let checkForUpdates = doc.getElementById("detail-findUpdates-btn");
is(
checkForUpdates.hidden,
false,
"The check for updates button is visible"
);
checkForUpdates.click();
// Turn on auto update.
autoUpdate.querySelector('[value="2"]').click();
// Set auto update to default again.
autoUpdate.querySelector('[value="1"]').click();
}
let row = doc.querySelector(".addon-detail-row-updates");
let checked = row.querySelector(":checked");
is(checked.value, "1", "Use default is selected");
row.querySelector('[value="0"]').click();
row.querySelector('[action="update-check"]').click();
row.querySelector('[value="2"]').click();
row.querySelector('[value="1"]').click();
}
function clickLinks(doc) {
if (doc.ownerGlobal != gManagerWindow) {
let links = ["author", "homepage", "rating"];
for (let linkType of links) {
doc.querySelector(`.addon-detail-row-${linkType} a`).click();
}
} else {
// Check links.
let creator = doc.getElementById("detail-creator");
let label = doc.getAnonymousElementByAttribute(creator, "anonid", "label");
let link = doc.getAnonymousElementByAttribute(
creator,
"anonid",
"creator-link"
);
// Check that clicking the label doesn't trigger a telemetry event.
label.click();
assertAboutAddonsTelemetryEvents([]);
link.click();
doc.getElementById("detail-homepage").click();
doc.getElementById("detail-reviews").click();
let links = ["author", "homepage", "rating"];
for (let linkType of links) {
doc.querySelector(`.addon-detail-row-${linkType} a`).click();
}
}