Bug 1546597 - Fixes for the Doorhanger BITS download failure tests. r=bytesized

Makes the last 10 doorhanger tests that download updates also run using BITS to download updates.
Replaces the two functions for doorhanger tests with a new function and changes the doorhanger tests so they use it.
Added an optional checkInterval to the update object for startup processing tests that submit telemetry to fix a telemetry warning.
Turned off UpdateService logging for debugging since these tests have been very stable.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Robert Strong 2019-04-29 21:48:48 +00:00
Родитель 4c44b62eee
Коммит 059cab5d88
21 изменённых файлов: 421 добавлений и 391 удалений

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

@ -44,10 +44,20 @@ prefs =
# Doorhanger Application Update Tests
[browser_doorhanger_bc_downloaded.js]
[browser_doorhanger_bc_downloaded_staged.js]
[browser_doorhanger_bc_downloadAutoFailures.js]
[browser_doorhanger_bc_downloadAutoFailures_bgWin.js]
[browser_doorhanger_bc_downloadOptIn.js]
[browser_doorhanger_bc_downloadOptIn_bgWin.js]
[browser_doorhanger_bc_downloadOptIn_staging.js]
[browser_doorhanger_bc_patch_completeBadSize.js]
[browser_doorhanger_bc_patch_partialBadSize.js]
[browser_doorhanger_bc_patch_partialBadSize_complete.js]
[browser_doorhanger_bc_patch_partialBadSize_completeBadSize.js]
[browser_doorhanger_sp_patch_completeApplyFailure.js]
[browser_doorhanger_sp_patch_partialApplyFailure.js]
[browser_doorhanger_sp_patch_partialApplyFailure_complete.js]
[browser_doorhanger_sp_patch_partialApplyFailure_complete_staging.js]
[browser_doorhanger_sp_patch_partialApplyFailure_completeBadSize.js]
# Telemetry Application Update Tests
[browser_telemetry_completeBadSize.js]

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

@ -1,19 +1,19 @@
add_task(async function testBasicPrompt() {
SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_SERVICE_ENABLED, false]]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_check_cantApply() {
lockWriteTestFile();
let updateParams = "promptWaitTime=0";
await runUpdateTest(updateParams, 1, [
let updateParams = "&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-manual",
button: "button",
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDetailsURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,28 +1,26 @@
add_task(async function testMalformedXml() {
const updateDetailsUrl = "http://example.com/details";
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_check_malformedXML() {
const maxBackgroundErrors = 10;
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
[PREF_APP_UPDATE_URL_DETAILS, updateDetailsUrl],
]});
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
],
});
let updateParams = "xmlMalformed=1";
await runUpdateTest(updateParams, maxBackgroundErrors, [
let updateParams = "&xmlMalformed=1";
await runDoorhangerUpdateTest(updateParams, maxBackgroundErrors, [
{
// if we fail 10 check attempts, then we want to just show the user a manual update
// workflow.
// If the update check fails 10 consecutive attempts then the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new", updateDetailsUrl);
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDetailsURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,30 +1,40 @@
add_task(async function testDownloadFailures() {
const maxBackgroundErrors = 5;
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
]});
let updateParams = "badURL=1";
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
await runUpdateTest(updateParams, 1, [
"use strict";
add_task(async function doorhanger_bc_downloadAutoFailures() {
const maxBackgroundErrors = 5;
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
],
});
let updateParams = "&badURL=1";
await runDoorhangerUpdateTest(updateParams, 1, [
{
// if we fail maxBackgroundErrors download attempts, then we want to
// first show the user an update available prompt.
// If the update download fails maxBackgroundErrors download attempts then
// show the update available prompt.
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,13 +1,9 @@
add_task(async function testBackgroundWindowFailures() {
const maxBackgroundErrors = 5;
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let updateParams = "badURL=1";
let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
await SimpleTest.promiseFocus(extraWindow);
"use strict";
add_task(async function doorhanger_bc_downloadAutoFailures_bgWin() {
function getBackgroundWindowHandler(destroyWindow) {
return async function() {
await TestUtils.waitForCondition(() =>
@ -18,8 +14,10 @@ add_task(async function testBackgroundWindowFailures() {
is(PanelUI.menuButton.getAttribute("badge-status"), "update-available",
"The badge is showing for the background window");
checkWhatsNewLink(extraWindow, "update-available-whats-new");
let buttonEl = getNotificationButton(extraWindow, "update-available", "button");
checkWhatsNewLink(extraWindow, "update-available-whats-new",
gDefaultWhatsNewURL);
let buttonEl =
getNotificationButton(extraWindow, "update-available", "button");
buttonEl.click();
if (destroyWindow) {
@ -29,18 +27,28 @@ add_task(async function testBackgroundWindowFailures() {
};
}
await runUpdateTest(updateParams, 1, [
const maxBackgroundErrors = 5;
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors],
],
});
let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
await SimpleTest.promiseFocus(extraWindow);
let updateParams = "&badURL=1";
await runDoorhangerUpdateTest(updateParams, 1, [
getBackgroundWindowHandler(false),
getBackgroundWindowHandler(true),
{
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,25 +1,23 @@
add_task(async function testBasicPromptNoStaging() {
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_STAGING_ENABLED, false],
]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_downloadOptIn() {
await UpdateUtils.setAppUpdateAutoEnabled(false);
let updateParams = "promptWaitTime=0";
await runUpdateTest(updateParams, 1, [
let updateParams = "&invalidCompleteSize=1&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-available",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-available-whats-new");
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_PENDING},
},
]);
});

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

@ -1,15 +1,11 @@
add_task(async function testUpdatesBackgroundWindow() {
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_STAGING_ENABLED, false],
]});
await UpdateUtils.setAppUpdateAutoEnabled(false);
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let updateParams = "promptWaitTime=0";
let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
await SimpleTest.promiseFocus(extraWindow);
"use strict";
await runUpdateTest(updateParams, 1, [
async function() {
add_task(async function doorhanger_bc_downloadOptIn_bgWin() {
function getBackgroundWindowHandler() {
return async function() {
await TestUtils.waitForCondition(() =>
PanelUI.menuButton.hasAttribute("badge-status"),
"Background window has a badge.");
@ -17,22 +13,32 @@ add_task(async function testUpdatesBackgroundWindow() {
"The doorhanger is not showing for the background window");
is(PanelUI.menuButton.getAttribute("badge-status"), "update-available",
"The badge is showing for the background window");
let popupShownPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
let popupShownPromise =
BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
await BrowserTestUtils.closeWindow(extraWindow);
await SimpleTest.promiseFocus(window);
await popupShownPromise;
checkWhatsNewLink(window, "update-available-whats-new");
let buttonEl = getNotificationButton(window, "update-available", "button");
checkWhatsNewLink(window, "update-available-whats-new",
gDefaultWhatsNewURL);
let buttonEl =
getNotificationButton(window, "update-available", "button");
buttonEl.click();
},
};
}
await UpdateUtils.setAppUpdateAutoEnabled(false);
let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
await SimpleTest.promiseFocus(extraWindow);
let updateParams = "&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
getBackgroundWindowHandler(),
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_PENDING},
},
]);
});

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

@ -1,25 +1,28 @@
add_task(async function testBasicPrompt() {
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_downloadOptIn_staging() {
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
],
});
await UpdateUtils.setAppUpdateAutoEnabled(false);
let updateParams = "promptWaitTime=0";
await runUpdateTest(updateParams, 1, [
let updateParams = "&invalidCompleteSize=1&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-available",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-available-whats-new");
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_APPLIED},
},
]);
});

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

@ -1,13 +1,15 @@
add_task(async function testCompleteAndPartialPatchesWithBadCompleteSize() {
let updateParams = "invalidCompleteSize=1&promptWaitTime=0";
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
await runUpdateTest(updateParams, 1, [
"use strict";
add_task(async function doorhanger_bc_downloaded() {
let updateParams = "&invalidCompleteSize=1&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_PENDING},
},
]);
});

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

@ -1,16 +1,21 @@
add_task(async function testCompleteAndPartialPatchesWithBadCompleteSize() {
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let updateParams = "invalidCompleteSize=1&promptWaitTime=0";
await runUpdateTest(updateParams, 1, [
"use strict";
add_task(async function doorhanger_bc_downloaded_staged() {
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
],
});
let updateParams = "&invalidCompleteSize=1&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_APPLIED},
},
]);
});

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

@ -1,31 +1,33 @@
add_task(async function testCompletePatchWithBadCompleteSize() {
let updateParams = "completePatchOnly=1&invalidCompleteSize=1";
await runUpdateTest(updateParams, 1, [
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_patch_completeBadSize() {
let updateParams = "&completePatchOnly=1&invalidCompleteSize=1";
await runDoorhangerUpdateTest(updateParams, 1, [
{
// if we fail maxBackgroundErrors download attempts, then we want to
// first show the user an update available prompt.
// If the update download fails maxBackgroundErrors download attempts then
// show the update available prompt.
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,31 +1,33 @@
add_task(async function testPartialPatchWithBadPartialSize() {
let updateParams = "partialPatchOnly=1&invalidPartialSize=1";
await runUpdateTest(updateParams, 1, [
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_patch_partialBadSize() {
let updateParams = "&partialPatchOnly=1&invalidPartialSize=1";
await runDoorhangerUpdateTest(updateParams, 1, [
{
// if we fail maxBackgroundErrors download attempts, then we want to
// first show the user an update available prompt.
// If the update download fails maxBackgroundErrors download attempts then
// show the update available prompt.
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,13 +1,15 @@
add_task(async function testCompleteAndPartialPatchesWithBadPartialSize() {
let updateParams = "invalidPartialSize=1&promptWaitTime=0";
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
await runUpdateTest(updateParams, 1, [
"use strict";
add_task(async function doorhanger_bc_patch_partialBadSize_complete() {
let updateParams = "&invalidPartialSize=1&promptWaitTime=0";
await runDoorhangerUpdateTest(updateParams, 1, [
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_PENDING},
},
]);
});

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

@ -1,31 +1,33 @@
add_task(async function testCompleteAndPartialPatchesWithBadSizes() {
let updateParams = "invalidPartialSize=1&invalidCompleteSize=1";
await runUpdateTest(updateParams, 1, [
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_bc_patch_partialBadSize_completeBadSize() {
let updateParams = "&invalidPartialSize=1&invalidCompleteSize=1";
await runDoorhangerUpdateTest(updateParams, 1, [
{
// if we fail maxBackgroundErrors download attempts, then we want to
// first show the user an update available prompt.
// If the update download fails maxBackgroundErrors download attempts then
// show the update available prompt.
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
notificationId: "update-available",
button: "button",
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL},
},
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,24 +1,25 @@
add_task(async function testCompletePatchApplyFailure() {
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_sp_patch_completeApplyFailure() {
let patchProps = {state: STATE_PENDING};
let patches = getLocalPatchString(patchProps);
let updates = getLocalUpdateString({}, patches);
let updateProps = {checkInterval: "1"};
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
await runUpdateProcessingTest(updates, [
let updateParams = "";
await runDoorhangerUpdateTest(updateParams, 0, [
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If the update process is unable to install the update show the manual
// update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,26 +1,26 @@
add_task(async function testPartialPatchApplyFailure() {
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_sp_patch_partialApplyFailure() {
let patchProps = {type: "partial",
state: STATE_PENDING};
let patches = getLocalPatchString(patchProps);
let updateProps = {isCompleteUpdate: "false"};
let updateProps = {isCompleteUpdate: "false",
checkInterval: "1"};
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
await runUpdateProcessingTest(updates, [
let updateParams = "";
await runDoorhangerUpdateTest(updateParams, 0, [
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If there is only an invalid patch show the manual update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,4 +1,9 @@
add_task(async function testPartialPatchApplyFailureWithCompleteAvailable() {
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_sp_patch_partialApplyFailure_complete() {
let patchProps = {type: "partial",
state: STATE_PENDING};
let patches = getLocalPatchString(patchProps);
@ -7,14 +12,14 @@ add_task(async function testPartialPatchApplyFailureWithCompleteAvailable() {
let updateProps = {isCompleteUpdate: "false",
promptWaitTime: "0"};
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
await runUpdateProcessingTest(updates, [
let updateParams = "";
await runDoorhangerUpdateTest(updateParams, 0, [
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_PENDING},
},
]);
});

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

@ -1,6 +1,11 @@
add_task(async function testPartialPatchApplyFailureWithCompleteValidationFailure() {
// because of the way we're simulating failure, we have to just pretend we've already
// retried.
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_sp_patch_partialApplyFailure_completeBadSize() {
// Because of the way the test is simulating failure it has to pretend it has
// already retried.
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DOWNLOAD_MAXATTEMPTS, 0],
@ -15,23 +20,17 @@ add_task(async function testPartialPatchApplyFailureWithCompleteValidationFailur
patches += getLocalPatchString(patchProps);
let updateProps = {isCompleteUpdate: "false"};
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
await runUpdateProcessingTest(updates, [
let updateParams = "";
await runDoorhangerUpdateTest(updateParams, 0, [
{
// if we have only an invalid patch, then something's wrong and we don't
// have an automatic way to fix it, so show the manual update
// doorhanger.
// If there is only an invalid patch show the manual update doorhanger.
notificationId: "update-manual",
button: "button",
beforeClick() {
checkWhatsNewLink(window, "update-manual-whats-new");
},
async cleanup() {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec,
URL_MANUAL_UPDATE, "Landed on manual update page.");
gBrowser.removeTab(gBrowser.selectedTab);
},
checkActiveUpdate: null,
pageURLs: {whatsNew: gDefaultWhatsNewURL,
manual: URL_MANUAL_UPDATE},
},
]);
});

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

@ -1,7 +1,14 @@
add_task(async function testPartialPatchApplyFailureWithCompleteAvailable() {
SpecialPowers.pushPrefEnv({set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
]});
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function doorhanger_sp_patch_partialApplyFailure_complete_staging() {
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_STAGING_ENABLED, true],
],
});
let patchProps = {type: "partial",
state: STATE_PENDING};
@ -11,14 +18,14 @@ add_task(async function testPartialPatchApplyFailureWithCompleteAvailable() {
let updateProps = {isCompleteUpdate: "false",
promptWaitTime: "0"};
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
await runUpdateProcessingTest(updates, [
let updateParams = "";
await runDoorhangerUpdateTest(updateParams, 0, [
{
notificationId: "update-restart",
button: "secondaryButton",
cleanup() {
AppMenuNotifications.removeNotification(/.*/);
},
checkActiveUpdate: {state: STATE_APPLIED},
},
]);
});

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

@ -34,10 +34,15 @@ Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
let gOriginalUpdateAutoValue = null;
// Some elements append a trailing /. After the chrome tests are removed this
// code can be changed so URL_HOST already has a trailing /.
const gDetailsURL = URL_HOST + "/";
const gDefaultWhatsNewURL = URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS";
// Set to true to log additional information for debugging. To log additional
// information for individual tests set gDebugTest to false here and to true in
// the test's onload function.
gDebugTest = true;
// information for individual tests set gDebugTest to false here and to true
// globally in the test.
gDebugTest = false;
// This is to accommodate the TV task which runs the tests with --verify.
requestLongerTimeout(10);
@ -245,127 +250,6 @@ async function setAppUpdateAutoEnabledHelper(enabled) {
await UpdateUtils.setAppUpdateAutoEnabled(enabled);
}
/**
* Runs a typical update test. Will set various common prefs for using the
* updater doorhanger, runs the provided list of steps, and makes sure
* everything is cleaned up afterwards.
*
* @param updateParams
* Params which will be sent to app_update.sjs.
* @param checkAttempts
* How many times to check for updates. Useful for testing the UI
* for check failures.
* @param steps
* A list of test steps to perform, specifying expected doorhangers
* and additional validation/cleanup callbacks.
* @return A promise which will resolve once all of the steps have been run
* and cleanup has been performed.
*/
function runUpdateTest(updateParams, checkAttempts, steps) {
return (async function() {
gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],
[PREF_APP_UPDATE_IDLETIME, 0],
[PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE],
],
});
await setupTestUpdater();
let url = URL_HTTP_UPDATE_SJS +
"?" + updateParams +
getVersionParams();
setUpdateURL(url);
executeSoon(() => {
(async function() {
gAUS.checkForBackgroundUpdates();
for (var i = 0; i < checkAttempts - 1; i++) {
await waitForEvent("update-error", "check-attempt-failed");
gAUS.checkForBackgroundUpdates();
}
})();
});
for (let step of steps) {
await processStep(step);
}
})();
}
/**
* Runs a test which processes an update. Similar to runUpdateTest.
*
* @param updates
* A list of updates to process.
* @param steps
* A list of test steps to perform, specifying expected doorhangers
* and additional validation/cleanup callbacks.
* @return A promise which will resolve once all of the steps have been run
* and cleanup has been performed.
*/
function runUpdateProcessingTest(updates, steps) {
return (async function() {
gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],
[PREF_APP_UPDATE_IDLETIME, 0],
[PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE],
],
});
await setupTestUpdater();
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
writeStatusFile(STATE_FAILED_CRC_ERROR);
reloadUpdateManagerData();
testPostUpdateProcessing();
for (let step of steps) {
await processStep(step);
}
})();
}
function processStep(step) {
if (typeof(step) == "function") {
return step();
}
const {notificationId, button, beforeClick, cleanup} = step;
return (async function() {
await BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
const shownNotification = AppMenuNotifications.activeNotification.id;
is(shownNotification, notificationId, "The right notification showed up.");
if (shownNotification != notificationId) {
if (cleanup) {
await cleanup();
}
return;
}
let buttonEl = getNotificationButton(window, notificationId, button);
if (beforeClick) {
await beforeClick();
}
buttonEl.click();
if (cleanup) {
await cleanup();
}
})();
}
/**
* Gets the specified button for the notification.
*
@ -380,28 +264,25 @@ function processStep(step) {
function getNotificationButton(win, notificationId, button) {
let notification =
win.document.getElementById(`appMenu-${notificationId}-notification`);
is(notification.hidden, false, `${notificationId} notification is showing`);
ok(!notification.hidden, `${notificationId} notification is showing`);
return notification[button];
}
/**
* Ensures that the "What's new" link with the provided ID is displayed and
* matches the url parameter provided. If no URL is provided, it will instead
* ensure that the link matches the default link URL.
* matches the url parameter provided.
*
* @param win
* The window to get the "What's new" link for.
* @param id
* The ID of the "What's new" link element.
* @param url (optional)
* The URL to check against. If none is provided, a default will be used.
* @param url
* The URL to check against.
*/
function checkWhatsNewLink(win, id, url) {
let whatsNewLink = win.document.getElementById(id);
is(whatsNewLink.href,
url || URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS",
"What's new link points to the test_details URL");
is(whatsNewLink.hidden, false, "What's new link is not hidden.");
ok(!whatsNewLink.hidden, "What's new link is not hidden.");
is(whatsNewLink.href, url, `What's new link href should equal ${url}`);
}
/**
@ -624,6 +505,101 @@ function getPatchOfType(type) {
return null;
}
/**
* Runs a Doorhanger update test. This will set various common prefs for
* updating and runs the provided list of steps.
*
* @param updateParams
* Params which will be sent to app_update.sjs.
* @param checkAttempts
* How many times to check for updates. Useful for testing the UI
* for check failures. If this is 0 then a startup processing test will
* be performed.
* @param steps
* An array of test steps to perform. A step will either be an object
* containing expected conditions and actions or a function to call.
* @return A promise which will resolve once all of the steps have been run.
*/
function runDoorhangerUpdateTest(updateParams, checkAttempts, steps) {
function processDoorhangerStep(step) {
if (typeof(step) == "function") {
return step();
}
const {notificationId, button, checkActiveUpdate, pageURLs} = step;
return (async function() {
await BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
const shownNotificationId = AppMenuNotifications.activeNotification.id;
is(shownNotificationId, notificationId,
"The right notification showed up.");
if (checkActiveUpdate) {
ok(!!gUpdateManager.activeUpdate,
"There should be an active update");
is(gUpdateManager.activeUpdate.state, checkActiveUpdate.state,
`The active update state should equal ${checkActiveUpdate.state}`);
} else {
ok(!gUpdateManager.activeUpdate,
"There should not be an active update");
}
if (pageURLs && pageURLs.whatsNew !== undefined) {
checkWhatsNewLink(window, `${notificationId}-whats-new`,
pageURLs.whatsNew);
}
let buttonEl = getNotificationButton(window, notificationId, button);
buttonEl.click();
if (pageURLs && pageURLs.manual !== undefined) {
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
is(gBrowser.selectedBrowser.currentURI.spec, pageURLs.manual,
`The page's url should equal ${pageURLs.manual}`);
gBrowser.removeTab(gBrowser.selectedTab);
}
})();
}
return (async function() {
gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],
[PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE],
[PREF_APP_UPDATE_URL_DETAILS, gDetailsURL],
],
});
await setupTestUpdater();
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + gDetailsURL +
updateParams + getVersionParams();
setUpdateURL(updateURL);
if (checkAttempts) {
// Perform a background check doorhanger test.
executeSoon(() => {
(async function() {
gAUS.checkForBackgroundUpdates();
for (var i = 0; i < checkAttempts - 1; i++) {
await waitForEvent("update-error", "check-attempt-failed");
gAUS.checkForBackgroundUpdates();
}
})();
});
} else {
// Perform a startup processing doorhanger test.
reloadUpdateManagerData();
writeStatusFile(STATE_FAILED_CRC_ERROR);
testPostUpdateProcessing();
}
for (let step of steps) {
await processDoorhangerStep(step);
}
})();
}
/**
* Runs an About Dialog update test. This will set various common prefs for
* updating and runs the provided list of steps.
@ -639,9 +615,6 @@ function getPatchOfType(type) {
* @return A promise which will resolve once all of the steps have been run.
*/
function runAboutDialogUpdateTest(updateParams, backgroundUpdate, steps) {
// Some elements append a trailing /. After the chrome tests are removed this
// code can be changed so URL_HOST already has a trailing /.
let detailsURL = URL_HOST + "/";
let aboutDialog;
function processAboutDialogStep(step) {
if (typeof(step) == "function") {
@ -708,8 +681,8 @@ function runAboutDialogUpdateTest(updateParams, backgroundUpdate, steps) {
// downloadFailed and manualUpdate panels use the app.update.url.manual
// preference.
let link = selectedPanel.querySelector("label.text-link");
is(link.href, detailsURL,
"The panel's link href should equal the expected value");
is(link.href, gDetailsURL,
`The panel's link href should equal ${gDetailsURL}`);
}
let buttonPanels = ["downloadAndInstall", "apply"];
@ -733,13 +706,13 @@ function runAboutDialogUpdateTest(updateParams, backgroundUpdate, steps) {
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],
[PREF_APP_UPDATE_URL_MANUAL, detailsURL],
[PREF_APP_UPDATE_URL_MANUAL, gDetailsURL],
],
});
await setupTestUpdater();
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + detailsURL +
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + gDetailsURL +
updateParams + getVersionParams();
if (backgroundUpdate) {
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED)) {
@ -782,9 +755,6 @@ function runAboutDialogUpdateTest(updateParams, backgroundUpdate, steps) {
* @return A promise which will resolve once all of the steps have been run.
*/
function runAboutPrefsUpdateTest(updateParams, backgroundUpdate, steps) {
// Some elements append a trailing /. After the chrome tests are removed this
// code can be changed so URL_HOST already has a trailing /.
let detailsURL = URL_HOST + "/";
let tab;
function processAboutPrefsStep(step) {
if (typeof(step) == "function") {
@ -848,8 +818,8 @@ function runAboutPrefsUpdateTest(updateParams, backgroundUpdate, steps) {
await continueFileHandler(continueFile);
}
await ContentTask.spawn(tab.linkedBrowser, {panelId, detailsURL},
async ({panelId, detailsURL}) => {
await ContentTask.spawn(tab.linkedBrowser, {panelId, gDetailsURL},
async ({panelId, gDetailsURL}) => {
let linkPanels = ["downloadFailed", "manualUpdate", "unsupportedSystem"];
if (linkPanels.includes(panelId)) {
let selectedPanel =
@ -864,8 +834,8 @@ function runAboutPrefsUpdateTest(updateParams, backgroundUpdate, steps) {
selector = "a.text-link";
}
let link = selectedPanel.querySelector(selector);
is(link.href, detailsURL,
"The panel's link href should equal the expected value");
is(link.href, gDetailsURL,
`The panel's link href should equal ${gDetailsURL}`);
}
let buttonPanels = ["downloadAndInstall", "apply"];
@ -891,13 +861,13 @@ function runAboutPrefsUpdateTest(updateParams, backgroundUpdate, steps) {
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],
[PREF_APP_UPDATE_URL_MANUAL, detailsURL],
[PREF_APP_UPDATE_URL_MANUAL, gDetailsURL],
],
});
await setupTestUpdater();
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + detailsURL +
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + gDetailsURL +
updateParams + getVersionParams();
if (backgroundUpdate) {
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED)) {
@ -959,9 +929,6 @@ function removeUpdateSettingsIni() {
* @return A promise which will resolve after the .
*/
function runTelemetryUpdateTest(updateParams, event, stageFailure = false) {
// Some elements append a trailing /. After the chrome tests are removed this
// code can be changed so URL_HOST already has a trailing /.
let detailsURL = URL_HOST + "/";
return (async function() {
Services.telemetry.clearScalars();
gEnv.set("MOZ_TEST_SLOW_SKIP_UPDATE_STAGE", "1");
@ -977,7 +944,7 @@ function runTelemetryUpdateTest(updateParams, event, stageFailure = false) {
removeUpdateSettingsIni();
}
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + detailsURL +
let updateURL = URL_HTTP_UPDATE_SJS + "?detailsURL=" + gDetailsURL +
updateParams + getVersionParams();
setUpdateURL(updateURL);
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED)) {

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

@ -244,6 +244,8 @@ function getLocalUpdateString(aUpdateProps, aPatches) {
updateProps[name] = aUpdateProps[name];
}
let checkInterval = updateProps.checkInterval ?
"checkInterval=\"" + updateProps.checkInterval + "\" " : "";
let channel = "channel=\"" + updateProps.channel + "\" ";
let isCompleteUpdate =
"isCompleteUpdate=\"" + updateProps.isCompleteUpdate + "\" ";
@ -258,6 +260,7 @@ function getLocalUpdateString(aUpdateProps, aPatches) {
return getUpdateString(updateProps) +
" " +
checkInterval +
channel +
isCompleteUpdate +
foregroundDownload +