Merge pull request #131453 from primeos/chromium-backport
[21.05] Backport the test improvements for Chromium (+ wrapper fix)
This commit is contained in:
commit
52e4b484ca
@ -30,7 +30,10 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||||||
machine.imports = [ ./common/user-account.nix ./common/x11.nix ];
|
machine.imports = [ ./common/user-account.nix ./common/x11.nix ];
|
||||||
machine.virtualisation.memorySize = 2047;
|
machine.virtualisation.memorySize = 2047;
|
||||||
machine.test-support.displayManager.auto.user = user;
|
machine.test-support.displayManager.auto.user = user;
|
||||||
machine.environment.systemPackages = [ chromiumPkg ];
|
machine.environment = {
|
||||||
|
systemPackages = [ chromiumPkg ];
|
||||||
|
variables."XAUTHORITY" = "/home/alice/.Xauthority";
|
||||||
|
};
|
||||||
|
|
||||||
startupHTML = pkgs.writeText "chromium-startup.html" ''
|
startupHTML = pkgs.writeText "chromium-startup.html" ''
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -63,17 +66,32 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||||||
return "su - ${user} -c " + shlex.quote(cmd)
|
return "su - ${user} -c " + shlex.quote(cmd)
|
||||||
|
|
||||||
|
|
||||||
def get_browser_binary():
|
def launch_browser():
|
||||||
"""Returns the name of the browser binary."""
|
"""Launches the web browser with the correct options."""
|
||||||
|
# Determine the name of the binary:
|
||||||
pname = "${getName chromiumPkg.name}"
|
pname = "${getName chromiumPkg.name}"
|
||||||
if pname.find("chromium") != -1:
|
if pname.find("chromium") != -1:
|
||||||
return "chromium" # Same name for all channels and ungoogled-chromium
|
binary = "chromium" # Same name for all channels and ungoogled-chromium
|
||||||
if pname == "google-chrome":
|
elif pname == "google-chrome":
|
||||||
return "google-chrome-stable"
|
binary = "google-chrome-stable"
|
||||||
if pname == "google-chrome-dev":
|
elif pname == "google-chrome-dev":
|
||||||
return "google-chrome-unstable"
|
binary = "google-chrome-unstable"
|
||||||
# For google-chrome-beta and as fallback:
|
else: # For google-chrome-beta and as fallback:
|
||||||
return pname
|
binary = pname
|
||||||
|
# Add optional CLI options:
|
||||||
|
options = []
|
||||||
|
major_version = "${versions.major (getVersion chromiumPkg.name)}"
|
||||||
|
if major_version > "91":
|
||||||
|
# To avoid a GPU crash:
|
||||||
|
options += ["--use-gl=angle", "--use-angle=swiftshader"]
|
||||||
|
options.append("file://${startupHTML}")
|
||||||
|
# Launch the process:
|
||||||
|
machine.succeed(ru(f'ulimit -c unlimited; {binary} {shlex.join(options)} & disown'))
|
||||||
|
if binary.startswith("google-chrome"):
|
||||||
|
# Need to click away the first window:
|
||||||
|
machine.wait_for_text("Make Google Chrome the default browser")
|
||||||
|
machine.screenshot("google_chrome_default_browser_prompt")
|
||||||
|
machine.send_key("ret")
|
||||||
|
|
||||||
|
|
||||||
def create_new_win():
|
def create_new_win():
|
||||||
@ -124,24 +142,32 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def test_new_win(description):
|
def test_new_win(description, url, window_name):
|
||||||
create_new_win()
|
create_new_win()
|
||||||
|
machine.wait_for_window("New Tab")
|
||||||
|
machine.send_chars(f"{url}\n")
|
||||||
|
machine.wait_for_window(window_name)
|
||||||
|
machine.screenshot(description)
|
||||||
|
machine.succeed(
|
||||||
|
ru(
|
||||||
|
"${xdo "copy-all" ''
|
||||||
|
key --delay 1000 Ctrl+a Ctrl+c
|
||||||
|
''}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
clipboard = machine.succeed(
|
||||||
|
ru("${pkgs.xclip}/bin/xclip -o")
|
||||||
|
)
|
||||||
|
print(f"{description} window content:\n{clipboard}")
|
||||||
with machine.nested(description):
|
with machine.nested(description):
|
||||||
yield
|
yield clipboard
|
||||||
# Close the newly created window:
|
# Close the newly created window:
|
||||||
machine.send_key("ctrl-w")
|
machine.send_key("ctrl-w")
|
||||||
|
|
||||||
|
|
||||||
machine.wait_for_x()
|
machine.wait_for_x()
|
||||||
|
|
||||||
url = "file://${startupHTML}"
|
launch_browser()
|
||||||
machine.succeed(ru(f'ulimit -c unlimited; "{get_browser_binary()}" "{url}" & disown'))
|
|
||||||
|
|
||||||
if get_browser_binary().startswith("google-chrome"):
|
|
||||||
# Need to click away the first window:
|
|
||||||
machine.wait_for_text("Make Google Chrome the default browser")
|
|
||||||
machine.screenshot("google_chrome_default_browser_prompt")
|
|
||||||
machine.send_key("ret")
|
|
||||||
|
|
||||||
machine.wait_for_text("startup done")
|
machine.wait_for_text("startup done")
|
||||||
machine.wait_until_succeeds(
|
machine.wait_until_succeeds(
|
||||||
@ -164,49 +190,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||||||
|
|
||||||
machine.screenshot("startup_done")
|
machine.screenshot("startup_done")
|
||||||
|
|
||||||
with test_new_win("check sandbox"):
|
with test_new_win("sandbox_info", "chrome://sandbox", "Sandbox Status") as clipboard:
|
||||||
machine.succeed(
|
|
||||||
ru(
|
|
||||||
"${xdo "type-url" ''
|
|
||||||
search --sync --onlyvisible --name "New Tab"
|
|
||||||
windowfocus --sync
|
|
||||||
type --delay 1000 "chrome://sandbox"
|
|
||||||
''}"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
machine.succeed(
|
|
||||||
ru(
|
|
||||||
"${xdo "submit-url" ''
|
|
||||||
search --sync --onlyvisible --name "New Tab"
|
|
||||||
windowfocus --sync
|
|
||||||
key --delay 1000 Return
|
|
||||||
''}"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
machine.screenshot("sandbox_info")
|
|
||||||
|
|
||||||
machine.succeed(
|
|
||||||
ru(
|
|
||||||
"${xdo "find-window" ''
|
|
||||||
search --sync --onlyvisible --name "Sandbox Status"
|
|
||||||
windowfocus --sync
|
|
||||||
''}"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
machine.succeed(
|
|
||||||
ru(
|
|
||||||
"${xdo "copy-sandbox-info" ''
|
|
||||||
key --delay 1000 Ctrl+a Ctrl+c
|
|
||||||
''}"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
clipboard = machine.succeed(
|
|
||||||
ru("${pkgs.xclip}/bin/xclip -o")
|
|
||||||
)
|
|
||||||
|
|
||||||
filters = [
|
filters = [
|
||||||
"layer 1 sandbox.*namespace",
|
"layer 1 sandbox.*namespace",
|
||||||
"pid namespaces.*yes",
|
"pid namespaces.*yes",
|
||||||
@ -253,6 +237,12 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||||||
|
|
||||||
machine.screenshot("after_copy_from_chromium")
|
machine.screenshot("after_copy_from_chromium")
|
||||||
|
|
||||||
|
|
||||||
|
with test_new_win("gpu_info", "chrome://gpu", "chrome://gpu"):
|
||||||
|
# To check the text rendering (catches regressions like #131074):
|
||||||
|
machine.wait_for_text("Graphics Feature Status")
|
||||||
|
|
||||||
|
|
||||||
machine.shutdown()
|
machine.shutdown()
|
||||||
'';
|
'';
|
||||||
}) channelMap
|
}) channelMap
|
||||||
|
@ -149,9 +149,11 @@ in stdenv.mkDerivation {
|
|||||||
+ "chromium${suffix}-${version}";
|
+ "chromium${suffix}-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
buildInputs = [
|
nativeBuildInputs = [
|
||||||
makeWrapper ed
|
makeWrapper ed
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
# needed for GSETTINGS_SCHEMAS_PATH
|
# needed for GSETTINGS_SCHEMAS_PATH
|
||||||
gsettings-desktop-schemas glib gtk3
|
gsettings-desktop-schemas glib gtk3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user