nixos/tests/chromium: Print the content of chrome://{sandbox,gpu}
This can be very useful when running the test headless or e.g. when looking at Hydra logs. Especially the chrome://gpu content contains a lot of interesting information. I also decided to refactor the test_new_win() function to avoid duplicate code and rely less on xdo. (cherry picked from commit c33015a0c94777261ef054a3d7dacd53e744ceea)
This commit is contained in:
parent
90e44d2f1c
commit
24599a5ba6
nixos/tests
|
@ -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>
|
||||||
|
@ -139,10 +142,25 @@ 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")
|
||||||
|
|
||||||
|
@ -172,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",
|
||||||
|
@ -261,6 +237,11 @@ 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"):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
machine.shutdown()
|
machine.shutdown()
|
||||||
'';
|
'';
|
||||||
}) channelMap
|
}) channelMap
|
||||||
|
|
Loading…
Reference in New Issue