Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firefox: fix search engine icons #6505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kira-bruneau
Copy link
Contributor

@kira-bruneau kira-bruneau commented Feb 20, 2025

Description

Closes #6450

See also the reference I used to implement the migrations for our Nix config: https://searchfox.org/mozilla-central/rev/e3f42ec9320748b2aab3d474d1e47075def9000c/toolkit/components/search/SearchSettings.sys.mjs#760-876.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all
    or nix build --reference-lock-file flake.lock ./tests#test-all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@brckd @rycee

@kira-bruneau kira-bruneau force-pushed the fix-firefox-search-engine-icons branch from dc489ed to de88c14 Compare February 20, 2025 17:13
}];
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
iconMapObj."16" = "https://wiki.nixos.org/favicon.png";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was inherited from the previous code, but while it's being updated anyways:
this url is actually a 404, it's favicon.ico

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yep thanks for catching that!

@5225225
Copy link

5225225 commented Feb 21, 2025

Hiding existing engines doesn't seem to be working here

I have

"Bing".metaData.hidden = true;
"Google".metaData.hidden = true;
"eBay".metaData.hidden = true;
"Wikipedia (en)".metaData.hidden = true;

in my config, and the HM generated file looks like

{
  "_isAppProvided": true,
  "_metaData": {
    "hidden": true
  },
  "_name": "Bing"
},

(using nix run nixpkgs#dejsonlz4 -- search.json.mozlz4 | jq .)

once i open firefox, it gets converted into

{
  "id": "bing",
  "_name": "Bing",
  "_isAppProvided": true,
  "_metaData": {}
},

... maybe firefox is expecting id to be populated, and bailing out when it isn't, resetting the metadata? unsure. (on that note, it would be nice to make the names in the config actually id, but that'd be a breaking change and i'm not sure how you'd migrate... in any case, that doesn't need to be done here)

adding new search engines with favicons works fine, both by url and using

iconMapObj."32" = pkgs.fetchurl {
  url = "https://github.githubassets.com/favicons/favicon-dark.png";
  hash = "sha256-vwpwhqqIKCid8OSMGppX4U/ltDf7qEx+/00wXR0HT/E=";
};

else
let size = toString (builtins.fromJSON name).width;
in warn
"JSON object names for iconMapObj are deprecated, use ${size} instead of ${name}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"JSON object names for iconMapObj are deprecated, use ${size} instead of ${name}"
"JSON object names for `iconMapObj` are deprecated, use `${size}` instead of `${name}`"

Comment on lines +183 to +185
"16" = warn "iconURL is deprecated, use icon = ${
strings.escapeNixString engine.iconURL
} instead" engine.iconURL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"16" = warn "iconURL is deprecated, use icon = ${
strings.escapeNixString engine.iconURL
} instead" engine.iconURL;
"16" = warn "`iconURL` is deprecated, use `icon = ${
strings.escapeNixString engine.iconURL
}` instead" engine.iconURL;

Comment on lines +187 to +190
"16" = warn "iconUpdateURL is deprecated, use icon = ${
strings.escapeNixString engine.iconUpdateURL
} instead" engine.iconUpdateURL;
} // (engine.iconMapObj or { });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"16" = warn "iconUpdateURL is deprecated, use icon = ${
strings.escapeNixString engine.iconUpdateURL
} instead" engine.iconUpdateURL;
} // (engine.iconMapObj or { });
"16" = warn "`iconUpdateURL` is deprecated, use `icon = ${
strings.escapeNixString engine.iconUpdateURL
}` instead" engine.iconUpdateURL;
} // (engine.iconMapObj or { });

}];
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
iconMapObj."16" = "https://wiki.nixos.org/favicon.png";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
iconMapObj."16" = "https://wiki.nixos.org/favicon.png";
iconMapObj."16" = "https://wiki.nixos.org/favicon.ico";

@khaneliman
Copy link
Collaborator

khaneliman commented Feb 21, 2025

Hiding existing engines doesn't seem to be working here

I have

"Bing".metaData.hidden = true;
"Google".metaData.hidden = true;
"eBay".metaData.hidden = true;
"Wikipedia (en)".metaData.hidden = true;

in my config, and the HM generated file looks like

{
  "_isAppProvided": true,
  "_metaData": {
    "hidden": true
  },
  "_name": "Bing"
},

(using nix run nixpkgs#dejsonlz4 -- search.json.mozlz4 | jq .)

once i open firefox, it gets converted into

{
  "id": "bing",
  "_name": "Bing",
  "_isAppProvided": true,
  "_metaData": {}
},

... maybe firefox is expecting id to be populated, and bailing out when it isn't, resetting the metadata? unsure. (on that note, it would be nice to make the names in the config actually id, but that'd be a breaking change and i'm not sure how you'd migrate... in any case, that doesn't need to be done here)

Is this a regression from this change or just another thing that needs to be migrated/fixed ? Didn't see where this would have affected that. Unless, it's just the version that we pass. Looking at the other migrations on searchfox, I didn't see any obvious migrations either that would help.

EDIT: Also looks like changing the default search engine regressed, so must just be that version string being passed affecting this stuff.

search = {
      default = "DuckDuckGo";
      privateDefault = "DuckDuckGo";
}

Doesn't work with this change.

@kira-bruneau
Copy link
Contributor Author

kira-bruneau commented Feb 21, 2025

Thank you both for catching these regressions! I assumed that the icon changes were the only breaking changes based of migrations that exist in firefox, I'll look into them.

EDIT: It looks like the associated migrations were embedded directly into the implementation rather than in migrateSettings 🫠. For v7, search engine ids were introduced to replace the old way of referring to engines by name: https://searchfox.org/mozilla-central/rev/e3f42ec9320748b2aab3d474d1e47075def9000c/toolkit/components/search/SearchSettings.sys.mjs#543-600.

I'll look into porting this migration for our module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Firefox search engines icons are missing
4 participants