Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion modules/programs/firefox/mkFirefoxModule.nix
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ in {
};

};

config = let profile = config;
in {
settings."toolkit.legacyUserProfileCustomizations.stylesheets" =
mkIf (profile.userChrome != "" || profile.userContent != "") true;
};
}));
default = { };
description = "Attribute set of ${name} profiles.";
Expand Down Expand Up @@ -739,7 +745,25 @@ in {
(mkNoDuplicateAssertion cfg.profiles "profile")
] ++ (mapAttrsToList
(_: profile: mkNoDuplicateAssertion profile.containers "container")
cfg.profiles);
cfg.profiles) ++ (
# Assert "toolkit.legacyUserProfileCustomizations.stylesheets" is enabled if
# userChrome/userContent is used.
let

assertProfile = userChromeAttr: profile:
profile.${userChromeAttr} != ""
-> (profile.settings."toolkit.legacyUserProfileCustomizations.stylesheets"
!= false);

mkAssertion = userChromeAttr: {
assertion =
all (assertProfile userChromeAttr) (attrValues cfg.profiles);
message = ''
`${userChromeAttr}` won't work with `settings."toolkit.legacyUserProfileCustomizations.stylesheets"` set to false.
'';
};

in [ (mkAssertion "userChrome") (mkAssertion "userContent") ]);

warnings = optional (cfg.enableGnomeExtensions or false) ''
Using '${moduleName}.enableGnomeExtensions' has been deprecated and
Expand Down
30 changes: 25 additions & 5 deletions tests/modules/programs/firefox/profile-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let
name = cfg.wrappedPackageName;
};

userChromeExample = "#example-user-chrome { display: none; }";
userContentExample = "#example-user-content { display: none; }";

in {
imports = [ firefoxMockOverlay ];

Expand Down Expand Up @@ -160,12 +163,17 @@ in {
id = 5;
containers = {
"shopping" = {
id = 6;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wait what was wrong with the containers test? Each container should have its own unique id set, so I think it makes sense to keep one explicitly set in the test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was a bit confusing, because it's container id, not profile id. It looks like someone set it to 6 because it's the next number after 5, but these ids are unrelated. I feel like there's no need to set container id here (apart from making this test failproof against changing the default container id), and it's not testing anything.

I could set it explicitly to 1, but using 6 here is a bit confusing, because it looks like it's related to this 5.

icon = "circle";
color = "yellow";
};
};
};

profiles.userChrome = {
id = 6;
userChrome = userChromeExample;
userContent = userContentExample;
};
} // {

nmt.script = let
Expand Down Expand Up @@ -199,10 +207,6 @@ in {
home-files/${cfg.configPath}/test/user.js \
${withName ./profile-settings-expected-user.js}

assertFileContent \
home-files/${cfg.configPath}/containers/containers.json \
${withName ./profile-settings-expected-containers.json}

bookmarksUserJs=$(normalizeStorePaths \
home-files/${cfg.configPath}/bookmarks/user.js)

Expand Down Expand Up @@ -236,6 +240,22 @@ in {
assertFirefoxSearchContent \
home-files/${cfg.configPath}/searchWithoutDefault/search.json.mozlz4 \
${withName ./profile-settings-expected-search-without-default.json}

assertFileContent \
home-files/${cfg.configPath}/containers/containers.json \
${withName ./profile-settings-expected-containers.json}

assertFileContains \
home-files/${cfg.configPath}/userChrome/user.js \
'user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true)'

assertFileContains \
home-files/${cfg.configPath}/userChrome/chrome/userChrome.css \
'${userChromeExample}'

assertFileContains \
home-files/${cfg.configPath}/userChrome/chrome/userContent.css \
'${userContentExample}'
'';
Comment thread
MrQubo marked this conversation as resolved.
});
}