-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Playwright: browser improvements, update #298944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import ./make-test-python.nix ( | ||
| { pkgs, ... }: | ||
| { | ||
| name = "playwright-python"; | ||
|
|
||
| meta = with pkgs.lib.maintainers; { | ||
| maintainers = [ phaer ]; | ||
| }; | ||
|
|
||
| nodes.machine = | ||
| { pkgs, ... }: | ||
| { | ||
| environment.variables = { | ||
| NIX_MANUAL_DOCROOT = "file://${pkgs.nix.doc}/share/doc/nix/manual/index.html"; | ||
| PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers; | ||
| }; | ||
| environment.systemPackages = [ | ||
| (pkgs.writers.writePython3Bin "test_playwright" | ||
| { | ||
| libraries = [ pkgs.python3Packages.playwright ]; | ||
| } | ||
| '' | ||
| import sys | ||
| from playwright.sync_api import sync_playwright | ||
| from playwright.sync_api import expect | ||
|
|
||
| browsers = { | ||
| "chromium": ["--headless", "--disable-gpu"], | ||
| "firefox": [], | ||
| "webkit": [] | ||
| } | ||
| if len(sys.argv) != 3 or sys.argv[1] not in browsers.keys(): | ||
| print(f"usage: {sys.argv[0]} [{'|'.join(browsers.keys())}] <url>") | ||
| sys.exit(1) | ||
| browser_name = sys.argv[1] | ||
| url = sys.argv[2] | ||
| browser_args = browsers.get(browser_name) | ||
| print(f"Running test on {browser_name} {' '.join(browser_args)}") | ||
| with sync_playwright() as p: | ||
| browser = getattr(p, browser_name).launch(args=browser_args) | ||
| context = browser.new_context() | ||
| page = context.new_page() | ||
| page.goto(url) | ||
| expect(page.get_by_text("Nix Reference Manual")).to_be_visible() | ||
| '' | ||
| ) | ||
| ]; | ||
| }; | ||
|
|
||
| testScript = '' | ||
| # FIXME: Webkit segfaults | ||
| for browser in ["firefox", "chromium"]: | ||
| with subtest(f"Render Nix Manual in {browser}"): | ||
| machine.succeed(f"test_playwright {browser} $NIX_MANUAL_DOCROOT") | ||
| ''; | ||
|
|
||
| } | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "comment": "This file is kept up to date via update.sh", | ||
| "browsers": { | ||
| "chromium": { | ||
| "revision": "1134", | ||
| "browserVersion": "129.0.6668.29" | ||
| }, | ||
| "firefox": { | ||
| "revision": "1463", | ||
| "browserVersion": "130.0" | ||
| }, | ||
| "webkit": { | ||
| "revision": "2070", | ||
| "revisionOverrides": { | ||
| "mac10.14": "1446", | ||
| "mac10.15": "1616", | ||
| "mac11": "1816", | ||
| "mac11-arm64": "1816", | ||
| "mac12": "2009", | ||
| "mac12-arm64": "2009" | ||
| }, | ||
| "browserVersion": "18.0" | ||
| }, | ||
| "ffmpeg": { | ||
| "revision": "1010" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| runCommand, | ||
| makeWrapper, | ||
| makeFontsConf, | ||
| chromium, | ||
| ... | ||
| }: | ||
| let | ||
| fontconfig = makeFontsConf { | ||
| fontDirectories = [ ]; | ||
| }; | ||
| in | ||
| runCommand "playwright-chromium" | ||
| { | ||
| nativeBuildInputs = [ | ||
| makeWrapper | ||
| ]; | ||
| } | ||
| '' | ||
| mkdir -p $out/chrome-linux | ||
|
|
||
| # See here for the Chrome options: | ||
| # https://github.com/NixOS/nixpkgs/issues/136207#issuecomment-908637738 | ||
| # We add --disable-gpu to be able to run in gpu-less environments such | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment is outdated but let's remove it in future PRs. |
||
| # as headless nixos test vms. | ||
| makeWrapper ${chromium}/bin/chromium $out/chrome-linux/chrome \ | ||
| --set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \ | ||
| --set-default FONTCONFIG_FILE ${fontconfig} | ||
| '' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| fetchzip, | ||
| suffix, | ||
| revision, | ||
| system, | ||
| throwSystem, | ||
| }: | ||
| fetchzip { | ||
| url = "https://playwright.azureedge.net/builds/ffmpeg/${revision}/ffmpeg-${suffix}.zip"; | ||
| stripRoot = false; | ||
| hash = | ||
| { | ||
| x86_64-linux = "sha256-FEm62UvMv0h6Sav93WmbPLw3CW1L1xg4nD26ca5ol38="; | ||
| aarch64-linux = "sha256-jtQ+NS++VHRiKoIV++PIxEnyVnYtVwUyNlSILKSH4A4="; | ||
| } | ||
| .${system} or throwSystem; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| lib, | ||
| stdenv, | ||
| fetchzip, | ||
| firefox-bin, | ||
| suffix, | ||
| revision, | ||
| system, | ||
| throwSystem, | ||
| }: | ||
| let | ||
| suffix' = | ||
| if lib.hasPrefix "linux" suffix then "ubuntu-22.04" + (lib.removePrefix "linux" suffix) else suffix; | ||
| in | ||
| stdenv.mkDerivation { | ||
| name = "playwright-firefox"; | ||
| src = fetchzip { | ||
| url = "https://playwright.azureedge.net/builds/firefox/${revision}/firefox-${suffix'}.zip"; | ||
| hash = | ||
| { | ||
| x86_64-linux = "sha256-Hd9LlSRLW51gDoFyszqvg46Q/sMizLRsVKAN9atbwsw="; | ||
| aarch64-linux = "sha256-SEXH3gLOfNjOcnNWQjQ5gaaow47veVs0BoTYSgXw+24="; | ||
| } | ||
| .${system} or throwSystem; | ||
| }; | ||
|
|
||
| inherit (firefox-bin.unwrapped) | ||
| nativeBuildInputs | ||
| buildInputs | ||
| runtimeDependencies | ||
| appendRunpaths | ||
| patchelfFlags | ||
| ; | ||
|
|
||
| buildPhase = '' | ||
| mkdir -p $out/firefox | ||
| cp -R . $out/firefox | ||
| ''; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this unconditional but whatever. Fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it won't hurt to be explicit about supported platforms. :)