Skip to content

Commit

Permalink
Bug 1940533 - Fix search settings v11 migration fail when going back …
Browse files Browse the repository at this point in the history
…and forth between releases. a=pascalc

Original Revision: https://phabricator.services.mozilla.com/D233675

Differential Revision: https://phabricator.services.mozilla.com/D234014
  • Loading branch information
moritzbeier committed Jan 13, 2025
1 parent 6e10b90 commit ac46044
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions toolkit/components/search/SearchSettings.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,16 @@ export class SearchSettings {
sizeObj = JSON.parse(sizeStr);
} catch {}
if (
typeof sizeObj === "object" &&
"width" in sizeObj &&
parseInt(sizeObj.width) > 0 &&
sizeObj.width == sizeObj.height
) {
engine._iconMapObj[sizeObj.width] = icon;
} else if (typeof sizeObj === "number") {
// This happens if the user copies a version 11+ search config to
// an old install, which gets updated eventually; see bug 1940533.
engine._iconMapObj[sizeObj] = icon;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const SEARCH_SETTINGS = {
'{"width":42,"height":41}': "data:image/png;base64,ico42",
"{}": "data:image/png;base64,ico0",
"invalid json": "data:image/png;base64,ico0",
// Going back and forth should work.
64: "data:image/png;base64,ico64",
},
_metaData: {
loadPathHash: "OixanEC3I3fSEnZY/YeX1YndC9qdzkqotEEKsodghLY=",
Expand Down Expand Up @@ -81,7 +83,7 @@ add_task(async function test_icon_migration() {

Assert.equal(
Object.keys(engine.wrappedJSObject._iconMapObj).length,
2,
3,
"Only valid _iconMapObj keys got converted."
);
Assert.ok(
Expand All @@ -94,5 +96,6 @@ add_task(async function test_icon_migration() {
Assert.ok((await engine.getIconURL()).includes("ico16"));
Assert.ok((await engine.getIconURL(16)).includes("ico16"));
Assert.ok((await engine.getIconURL(32)).includes("ico32"));
Assert.ok((await engine.getIconURL(64)).includes("ico64"));
Assert.ok((await engine.getIconURL(74)).includes("ico74"));
});

0 comments on commit ac46044

Please sign in to comment.