nixos/tests/chromium: Refactor launching the browser process
It should now be more flexible and less error-prone.
This commit is contained in:
parent
faec8bbbf7
commit
8c52061b1f
|
@ -63,8 +63,8 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||
return "su - ${user} -c " + shlex.quote(cmd)
|
||||
|
||||
|
||||
def get_browser_call():
|
||||
"""Returns the name of the browser binary as well as CLI options."""
|
||||
def launch_browser():
|
||||
"""Launches the web browser with the correct options."""
|
||||
# Determine the name of the binary:
|
||||
pname = "${getName chromiumPkg.name}"
|
||||
if pname.find("chromium") != -1:
|
||||
|
@ -76,12 +76,19 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||
else: # For google-chrome-beta and as fallback:
|
||||
binary = pname
|
||||
# Add optional CLI options:
|
||||
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"
|
||||
return f"{binary} {options}"
|
||||
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():
|
||||
|
@ -142,14 +149,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
|||
|
||||
machine.wait_for_x()
|
||||
|
||||
url = "file://${startupHTML}"
|
||||
machine.succeed(ru(f'ulimit -c unlimited; {get_browser_call()} "{url}" & disown'))
|
||||
|
||||
if get_browser_call().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")
|
||||
launch_browser()
|
||||
|
||||
machine.wait_for_text("startup done")
|
||||
machine.wait_until_succeeds(
|
||||
|
|
Loading…
Reference in a new issue