diff --git a/bin/Main.ml b/bin/Main.ml index e6057f9..5f77c1d 100644 --- a/bin/Main.ml +++ b/bin/Main.ml @@ -145,11 +145,10 @@ let default_cmd = in result in + Mirage_crypto_rng_unix.use_default (); handle_response @@ Eio_main.run @@ fun env -> - Mirage_crypto_rng_eio.run (module Mirage_crypto_rng.Fortuna) env - @@ fun () -> Lwt_eio.with_event_loop ~clock:(Eio.Stdenv.clock env) @@ fun _ -> Eio.Switch.run @@ fun sw -> run ~sw ~env in diff --git a/bin/dune b/bin/dune index 97940b4..ba45a4c 100644 --- a/bin/dune +++ b/bin/dune @@ -8,7 +8,7 @@ OSnap cmdliner mirage-crypto-rng - mirage-crypto-rng-eio + mirage-crypto-rng.unix lwt_eio eio eio.core diff --git a/docker/Dockerfile b/docker/Dockerfile index 0ac0340..36e66b5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,7 +28,7 @@ WORKDIR /usr/app COPY ./osnap.opam . -RUN opam install . --yes && eval $(opam env) +RUN opam install . --deps-only --working-dir --yes && eval $(opam env) COPY . . diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 3fff02f..71f5a19 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -1,14 +1,6 @@ FROM debian:bookworm -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=128.* && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=128.* && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=128.* && \ - mkdir -p ~/osnap_chromium_1331488/chrome-linux && \ - mv /usr/lib/chromium/* ~/osnap_chromium_1331488/chrome-linux && \ - mv ~/osnap_chromium_1331488/chrome-linux/chromium ~/osnap_chromium_1331488/chrome-linux/chrome && \ - rm -f /usr/bin/chromium - +COPY --from=chromedp/headless-shell:133.0.6943.142 /headless-shell ~/osnap_chromium_1402768/chrome-headless-shell-linux64 COPY _release /usr/local RUN chmod +x /usr/local/bin/osnap diff --git a/docker/Dockerfile.node-lts b/docker/Dockerfile.node-lts index 4a61b28..636ec29 100644 --- a/docker/Dockerfile.node-lts +++ b/docker/Dockerfile.node-lts @@ -1,13 +1,6 @@ FROM node:lts-bookworm -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=128.* && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=128.* && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=128.* && \ - mkdir -p ~/osnap_chromium_1331488/chrome-linux && \ - mv /usr/lib/chromium/* ~/osnap_chromium_1331488/chrome-linux && \ - mv ~/osnap_chromium_1331488/chrome-linux/chromium ~/osnap_chromium_1331488/chrome-linux/chrome && \ - rm -f /usr/bin/chromium +COPY --from=chromedp/headless-shell:133.0.6943.142 /headless-shell ~/osnap_chromium_1402768/chrome-headless-shell-linux64 COPY _release /usr/local diff --git a/dune-project b/dune-project index a06bb25..1a310a1 100644 --- a/dune-project +++ b/dune-project @@ -23,7 +23,7 @@ eio_main lwt_eio httpun-eio - mirage-crypto-rng-eio + mirage-crypto-rng base64 cdp cmdliner diff --git a/lib/OSnap_Browser/OSnap_Browser_Download.ml b/lib/OSnap_Browser/OSnap_Browser_Download.ml index 0c136aa..d28949d 100644 --- a/lib/OSnap_Browser/OSnap_Browser_Download.ml +++ b/lib/OSnap_Browser/OSnap_Browser_Download.ml @@ -1,14 +1,24 @@ open OSnap_Utils -let get_uri revision (platform : OSnap_Utils.platform) = +let get_uri ~version (platform : OSnap_Utils.platform) = let host = "storage.googleapis.com" in let port = 80 in let path = match platform with - | MacOS -> "/chromium-browser-snapshots/Mac/" ^ revision ^ "/chrome-mac.zip" - | MacOS_ARM -> "/chromium-browser-snapshots/Mac_Arm/" ^ revision ^ "/chrome-mac.zip" - | Linux -> "/chromium-browser-snapshots/Linux_x64/" ^ revision ^ "/chrome-linux.zip" - | Win64 -> "/chromium-browser-snapshots/Win_x64/" ^ revision ^ "/chrome-win.zip" + | MacOS -> + "/chrome-for-testing-public/" + ^ version + ^ "/mac-x64/chrome-headless-shell-mac-x64.zip" + | MacOS_ARM -> + "/chrome-for-testing-public/" + ^ version + ^ "/mac-arm64/chrome-headless-shell-mac-arm64.zip" + | Linux -> + "/chrome-for-testing-public/" + ^ version + ^ "/linux64/chrome-headless-shell-linux64.zip" + | Win64 -> + "/chrome-for-testing-public/" ^ version ^ "/win64/chrome-headless-shell-win64.zip" | Win32 -> print_endline "Error: x86 is currently not supported on Windows"; exit 1 @@ -19,13 +29,13 @@ let get_uri revision (platform : OSnap_Utils.platform) = let download ~revision dir = let zip_path = Eio.Path.(dir / "chromium.zip") in Eio.Path.rmtree ~missing_ok:true zip_path; - let revision_string = OSnap_Browser_Path.revision_to_string revision in - let host, port, path = get_uri revision_string (OSnap_Utils.detect_platform ()) in + let version = OSnap_Browser_Path.revision_to_version revision in + let host, port, path = get_uri ~version (OSnap_Utils.detect_platform ()) in print_endline (Printf.sprintf - "Downloading chromium revision %s.\n\ + "Downloading chromium version %s.\n\ This is a one time setup and will only happen, if there are updates from OSnap..." - revision_string); + version); Eio.Switch.run @@ fun sw -> let fd = Unix.socket ~cloexec:true Unix.PF_INET Unix.SOCK_STREAM 0 in @@ -142,10 +152,10 @@ let download ~env revision = Eio.Path.with_open_dir Eio.Path.(fs / temp_dir) (fun dir -> - let*? path = download dir ~revision in - extract_zip path ~dest:extract_path; - Eio.Path.rmtree ~missing_ok:true path; - Result.ok ())) + let*? path = download dir ~revision in + extract_zip path ~dest:extract_path; + Eio.Path.rmtree ~missing_ok:true path; + Result.ok ())) in cleanup_old_revisions (); Result.ok () diff --git a/lib/OSnap_Browser/OSnap_Browser_Launcher.ml b/lib/OSnap_Browser/OSnap_Browser_Launcher.ml index 0d2f871..1aac502 100644 --- a/lib/OSnap_Browser/OSnap_Browser_Launcher.ml +++ b/lib/OSnap_Browser/OSnap_Browser_Launcher.ml @@ -12,10 +12,14 @@ let make ~sw ~env () = let base_path = OSnap_Browser_Path.get_chromium_path latest_chromium_revision in let executable = match OSnap_Utils.detect_platform () with - | MacOS | MacOS_ARM -> - Filename.concat base_path "chrome-mac/Chromium.app/Contents/MacOS/Chromium" - | Linux -> Filename.concat base_path "chrome-linux/chrome" - | Win64 -> Filename.concat base_path "chrome-win/chrome.exe" + | MacOS -> + Filename.concat base_path "chrome-headless-shell-mac-x64/chrome-headless-shell" + | MacOS_ARM -> + Filename.concat base_path "chrome-headless-shell-mac-arm64/chrome-headless-shell" + | Linux -> + Filename.concat base_path "chrome-headless-shell-linux64/chrome-headless-shell" + | Win64 -> + Filename.concat base_path "chrome-headless-shell-win64/chrome-headless-shell.exe" | Win32 -> "" in let process_manager = Eio.Stdenv.process_mgr env in @@ -28,11 +32,11 @@ let make ~sw ~env () = process_manager [ executable ; "about:blank" - ; "--headless=old" + ; "--remote-debugging-address=0.0.0.0" + ; "--remote-debugging-port=0" ; "--disable-gpu" ; "--no-sandbox" ; "--hide-scrollbars" - ; "--remote-debugging-port=0" ; "--mute-audio" ; "--disable-background-networking" ; "--enable-features=NetworkService,NetworkServiceInProcess" diff --git a/lib/OSnap_Browser/OSnap_Browser_Path.ml b/lib/OSnap_Browser/OSnap_Browser_Path.ml index 062a87d..0a1e204 100644 --- a/lib/OSnap_Browser/OSnap_Browser_Path.ml +++ b/lib/OSnap_Browser/OSnap_Browser_Path.ml @@ -1,15 +1,25 @@ -type revision = string +type revision = string * string -let revision_to_string revision = revision +let revision_to_string (revision, _version) = revision +let revision_to_version (_revision, version) = version -(* https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json *) +(* https://googlechromelabs.github.io/chrome-for-testing/ *) let revisions = - [ "1331488"; "1298002"; "1289146"; "1056772"; "961656"; "960312"; "884014"; "856583" ] + [ "1402768", "133.0.6943.141" + ; "1331488", "128.0.6613.7" + ; "1298002", "126.0.6468.2" + ; "1289146", "126.0.6439.0" + ; "1056772", "108.0.5355.0" + ; "961656", "99.0.4844.11" + ; "960312", "99.0.4840.0" + ; "884014", "92.0.4512.4" + ; "856583", "90.0.4427.5" + ] ;; let get_latest_revision () = List.hd revisions let get_previous_revisions () = List.tl revisions -let get_folder_name revision = Printf.sprintf "osnap_chromium_%s" revision +let get_folder_name (revision, _version) = Printf.sprintf "osnap_chromium_%s" revision let get_chromium_path revision = match Sys.getenv_opt "HOME" with diff --git a/lib/OSnap_Browser/OSnap_Browser_Path.mli b/lib/OSnap_Browser/OSnap_Browser_Path.mli index 0841934..e705509 100644 --- a/lib/OSnap_Browser/OSnap_Browser_Path.mli +++ b/lib/OSnap_Browser/OSnap_Browser_Path.mli @@ -1,6 +1,7 @@ type revision val revision_to_string : revision -> string +val revision_to_version : revision -> string val get_latest_revision : unit -> revision val get_previous_revisions : unit -> revision list val get_chromium_path : revision -> string diff --git a/lib/OSnap_Diff/png/Osnap_Diff_Png.ml b/lib/OSnap_Diff/png/Osnap_Diff_Png.ml index 27c5b73..8659261 100644 --- a/lib/OSnap_Diff/png/Osnap_Diff_Png.ml +++ b/lib/OSnap_Diff/png/Osnap_Diff_Png.ml @@ -8,9 +8,16 @@ module PngIo = PngIo module IO = struct type t = data - let readDirectPixel ~(x : int) ~(y : int) (img : t ImageIO.img) = + let readRawPixelAtOffset offset (img : t Odiff.ImageIO.img) = let image = (img.image : data) in - Array1.get image ((y * img.width) + x) + Array1.unsafe_get image offset + [@@inline always] + ;; + + let readRawPixel ~(x : int) ~(y : int) (img : t Odiff.ImageIO.img) = + let image : data = img.image in + Array1.unsafe_get image ((y * img.width) + x) + [@@inline always] ;; let setImgColor ~x ~y color (img : t ImageIO.img) = diff --git a/lib/OSnap_Test/OSnap_Test.ml b/lib/OSnap_Test/OSnap_Test.ml index 5d07fc8..1269a93 100644 --- a/lib/OSnap_Test/OSnap_Test.ml +++ b/lib/OSnap_Test/OSnap_Test.ml @@ -68,12 +68,12 @@ let execute_actions ~env ~document ~target ?size_name actions = actions |> List.fold_left (fun acc curr -> - let result = run curr in - match result with - | Ok () -> acc - | Error (`OSnap_Selector_Not_Found _s) -> acc - | Error (`OSnap_Selector_Not_Visible _s) -> acc - | Error (`OSnap_CDP_Protocol_Error _) as e -> e) + let result = run curr in + match result with + | Ok () -> acc + | Error (`OSnap_Selector_Not_Found _s) -> acc + | Error (`OSnap_Selector_Not_Visible _s) -> acc + | Error (`OSnap_CDP_Protocol_Error _) as e -> e) (Result.ok ()) ;; diff --git a/osnap.opam b/osnap.opam index 9f89609..891a868 100644 --- a/osnap.opam +++ b/osnap.opam @@ -13,7 +13,7 @@ depends: [ "eio_main" "lwt_eio" "httpun-eio" - "mirage-crypto-rng-eio" + "mirage-crypto-rng" "base64" "cdp" "cmdliner" @@ -48,7 +48,7 @@ build: [ ] dev-repo: "git+https://github.com/eWert-Online/OSnap.git" pin-depends: [ - [ "cdp.dev" "git+https://github.com/eWert-Online/reason-cdp.git#80747e0b93d3dd81f162f2c7b37aae6bd96fe0c9"] + [ "cdp.dev" "git+https://github.com/eWert-Online/reason-cdp.git#44707c5bc90501935e130025594d86d203e50c71"] [ "libspng.dev" "git+https://github.com/eWert-Online/esy-libspng.git#opam"] - [ "odiff-core.dev" "git+https://github.com/dmtrKovalenko/odiff.git#v3.1.1"] + [ "odiff-core.dev" "git+https://github.com/dmtrKovalenko/odiff.git#ocaml-version"] ] \ No newline at end of file diff --git a/osnap.opam.template b/osnap.opam.template index 5cde66a..8874af6 100644 --- a/osnap.opam.template +++ b/osnap.opam.template @@ -1,5 +1,5 @@ pin-depends: [ - [ "cdp.dev" "git+https://github.com/eWert-Online/reason-cdp.git#80747e0b93d3dd81f162f2c7b37aae6bd96fe0c9"] + [ "cdp.dev" "git+https://github.com/eWert-Online/reason-cdp.git#44707c5bc90501935e130025594d86d203e50c71"] [ "libspng.dev" "git+https://github.com/eWert-Online/esy-libspng.git#opam"] - [ "odiff-core.dev" "git+https://github.com/dmtrKovalenko/odiff.git#v3.1.1"] + [ "odiff-core.dev" "git+https://github.com/dmtrKovalenko/odiff.git#ocaml-version"] ] \ No newline at end of file