[rb] Add support for beta chrome by aguspe · Pull Request #15874 · SeleniumHQ/selenium

def chrome(selected_version, workspace_prefix=""):
    content = ""
    chrome_downloads = selected_version["downloads"]["chrome"]

    url = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
    sha = calculate_hash(url)

    content += f"""
    http_archive(
        name = "linux_{workspace_prefix}chrome",
        url = "{url}",
        sha256 = "{sha}",
        build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

filegroup(
    name = "files",
    srcs = glob(["**/*"]),
)

exports_files(["chrome-linux64/chrome"])

js_library(
    name = "chrome-js",
    data = [":files"],
)
\"\"\",
    )
"""

    url = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
    sha = calculate_hash(url)  # Calculate SHA for Mac chrome

    content += f"""    http_archive(
        name = "mac_{workspace_prefix}chrome",
        url = "{url}",
        sha256 = "{sha}",
        strip_prefix = "chrome-mac-x64",
        patch_cmds = [
            "mv 'Google Chrome for Testing.app' Chrome.app",
            "mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
        ],
        build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

exports_files(["Chrome.app"])

js_library(
    name = "chrome-js",
    data = glob(["Chrome.app/**/*"]),
)
\"\"\",
    )
"""

    return content