Bug 1706219 - Handle gSavedSate without placements in proton toolbar migration r=Gijs

Depends on D113423

Differential Revision: https://phabricator.services.mozilla.com/D113432
This commit is contained in:
Mark Striemer
2021-04-26 23:50:36 +00:00
parent 1195a2aae2
commit dc20804a27
2 changed files with 35 additions and 3 deletions

View File

@@ -641,7 +641,7 @@ var CustomizableUIInternal = {
return;
}
let placements = gSavedState?.placements[CustomizableUI.AREA_NAVBAR];
let placements = gSavedState?.placements?.[CustomizableUI.AREA_NAVBAR];
if (!placements) {
// The profile was created with this version, so no need to migrate.

View File

@@ -246,9 +246,9 @@ add_task(async function testNullSavedState() {
});
/**
* Checks that a saved state that is missing the placements value does not prevent migration.
* Checks that a saved state that is missing nav-bar placements does not prevent migration.
*/
add_task(async function testNullPlacements() {
add_task(async function testNoNavbarPlacements() {
await SpecialPowers.pushPrefEnv({
set: [
[kPrefProtonToolbarVersion, 0],
@@ -278,3 +278,35 @@ add_task(async function testNullPlacements() {
await SpecialPowers.popPrefEnv();
});
/**
* Checks that a saved state that is missing the placements value does not prevent migration.
*/
add_task(async function testNullPlacements() {
await SpecialPowers.pushPrefEnv({
set: [
[kPrefProtonToolbarVersion, 0],
[kPrefProtonToolbarEnabled, true],
],
});
let oldState = CustomizableUIBSPass.gSavedState;
Assert.equal(
Services.prefs.getIntPref(kPrefProtonToolbarVersion),
0,
"Toolbar proton version is 0"
);
let { CustomizableUIInternal } = CustomizableUIBSPass;
CustomizableUIBSPass.gSavedState = {};
CustomizableUIInternal._updateForNewProtonVersion();
Assert.ok(true, "_updateForNewProtonVersion didn't throw");
// Cleanup
CustomizableUIBSPass.gSavedState = oldState;
await SpecialPowers.popPrefEnv();
});