From 478940e2c7cfc1d21418e4e78c81734636b9a190 Mon Sep 17 00:00:00 2001 From: squalus Date: Fri, 8 Jul 2022 17:40:24 -0700 Subject: [PATCH] librewolf: add nixos test - support librewolf in the firefox nixos test - use the correct binary name - ensure autoplay is always on for the audio test, since librewolf disables it by default --- nixos/tests/all-tests.nix | 1 + nixos/tests/firefox.nix | 19 ++++++++++++++----- .../networking/browsers/librewolf/default.nix | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5164451cbe03..3253a3c750be 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -278,6 +278,7 @@ in { libreddit = handleTest ./libreddit.nix {}; libresprite = handleTest ./libresprite.nix {}; libreswan = handleTest ./libreswan.nix {}; + librewolf = handleTest ./firefox.nix { firefoxPackage = pkgs.librewolf; }; lidarr = handleTest ./lidarr.nix {}; lightdm = handleTest ./lightdm.nix {}; limesurvey = handleTest ./limesurvey.nix {}; diff --git a/nixos/tests/firefox.nix b/nixos/tests/firefox.nix index 63ccc6efb5bb..9bb78a97f36d 100644 --- a/nixos/tests/firefox.nix +++ b/nixos/tests/firefox.nix @@ -1,5 +1,14 @@ -import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: { - name = "firefox"; +import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: +let firefoxPackage' = firefoxPackage.override (args: { + extraPrefsFiles = (args.extraPrefsFiles or []) ++ [ + # make sure that autoplay is enabled by default for the audio test + (builtins.toString (builtins.toFile "autoplay-pref.js" ''defaultPref("media.autoplay.default",0);'')) + ]; + }); + +in +{ + name = firefoxPackage'.unwrapped.binaryName; meta = with pkgs.lib.maintainers; { maintainers = [ eelco shlevy ]; }; @@ -9,7 +18,7 @@ import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: { { imports = [ ./common/x11.nix ]; environment.systemPackages = [ - firefoxPackage + firefoxPackage' pkgs.xdotool ]; @@ -88,7 +97,7 @@ import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: { with subtest("Wait until Firefox has finished loading the Valgrind docs page"): machine.execute( - "xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &" + "xterm -e '${firefoxPackage'.unwrapped.binaryName} file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &" ) machine.wait_for_window("Valgrind") machine.sleep(40) @@ -96,7 +105,7 @@ import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: { with subtest("Check whether Firefox can play sound"): with record_audio(machine): machine.succeed( - "firefox file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &" + "${firefoxPackage'.unwrapped.binaryName} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &" ) wait_for_sound(machine) machine.copy_from_vm("/tmp/record.wav") diff --git a/pkgs/applications/networking/browsers/librewolf/default.nix b/pkgs/applications/networking/browsers/librewolf/default.nix index bec0c3a9eda9..55451167e0a8 100644 --- a/pkgs/applications/networking/browsers/librewolf/default.nix +++ b/pkgs/applications/networking/browsers/librewolf/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, callPackage, buildMozillaMach }: +{ stdenv, lib, callPackage, buildMozillaMach, nixosTests }: let librewolf-src = callPackage ./librewolf.nix { }; @@ -22,6 +22,7 @@ in maxSilent = 14400; # 4h, double the default of 7200s (c.f. #129212, #129115) license = lib.licenses.mpl20; }; + tests = [ nixosTests.librewolf ]; updateScript = callPackage ./update.nix { attrPath = "librewolf-unwrapped"; };