Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
#!/usr/bin/env bash
# Run the cross-platform external Chromium browser matrix in the caller's desktop session.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
RUST_ROOT="${REPO_ROOT}/libs/cua-driver/rust"
ARTIFACT_DIR="${CUA_E2E_ARTIFACT_DIR:-${REPO_ROOT}/artifacts/cua-driver/standalone-browser}"
if [[ -d "${ARTIFACT_DIR}" ]] \
&& [[ -n "$(find "${ARTIFACT_DIR}" -mindepth 1 -print -quit)" ]]; then
echo "Standalone-browser artifact directory is not empty: ${ARTIFACT_DIR}" >&2
echo "Use a fresh CUA_E2E_ARTIFACT_DIR so rows and videos cannot be mixed across runs." >&2
exit 2
fi
mkdir -p "${ARTIFACT_DIR}/recordings"
export CUA_E2E_DECLARATIONS_FILE="${ARTIFACT_DIR}/cases.jsonl"
export CUA_E2E_ENVIRONMENT_FILE="${ARTIFACT_DIR}/environment.jsonl"
export CUA_E2E_BROWSER_PROVENANCE_FILE="${ARTIFACT_DIR}/browser-provenance.jsonl"
export CUA_E2E_RESULTS_FILE="${ARTIFACT_DIR}/results.jsonl"
export CUA_E2E_RECORDINGS_ROOT="${ARTIFACT_DIR}/recordings"
export CUA_TEST_WORKSPACE_ROOT="${RUST_ROOT}"
export CUA_TEST_DRIVER_BIN="${CUA_TEST_DRIVER_BIN:-${RUST_ROOT}/target/release/cua-driver}"
export CUA_TEST_REQUIRE_EXTERNAL_BROWSERS=1
export CUA_E2E_FORBID_SKIPS=1
export CUA_TEST_DRIVER_STDERR=1
export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"
HOST_OS="$(uname -s)"
CARGO_DRIVER_FEATURE_ARGS=()
if [[ "${HOST_OS}" == Linux ]]; then
# Published Linux artifacts include the portal/libei route. Compile the
# browser matrix with the same feature set so GNOME/KDE setup cannot be
# misclassified from a default-feature test binary that falls back to wtype.
CARGO_DRIVER_FEATURE_ARGS=(--features portal-input)
fi
if [[ "${HOST_OS}" == Linux ]] \
&& [[ "${XDG_SESSION_TYPE:-}" == wayland ]] \
&& [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
# GNOME/KDE retain DISPLAY for XWayland even in native Wayland sessions.
# Session type and the Wayland socket are the authority; opt into the native
# backend so those desktops cannot silently exercise X11 enumeration.
export CUA_DRIVER_RS_ENABLE_WAYLAND=1
export ELECTRON_OZONE_PLATFORM_HINT=wayland
fi
case "${HOST_OS}" in
Darwin)
SENTINEL_FIXTURE="${RUST_ROOT}/test-apps/harness-electron/CuaTestHarness.Electron.app"
;;
Linux)
SENTINEL_FIXTURE="${RUST_ROOT}/test-apps/harness-electron/CuaTestHarness.Electron"
;;
MINGW*|MSYS*|CYGWIN*)
SENTINEL_FIXTURE="${RUST_ROOT}/test-apps/harness-electron/CuaTestHarness.Electron.exe"
;;
*)
echo "Unsupported standalone-browser host: ${HOST_OS}" >&2
exit 2
;;
esac
if [[ ! -e "${SENTINEL_FIXTURE}" ]]; then
echo "[FIXTURE] Staging the Electron foreground sentinel"
if [[ "${HOST_OS}" == MINGW* || "${HOST_OS}" == MSYS* || "${HOST_OS}" == CYGWIN* ]]; then
powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File \
"${REPO_ROOT}/libs/cua-driver/tests/fixtures/apps/cross-platform/electron/build.ps1"
else
"${REPO_ROOT}/libs/cua-driver/tests/fixtures/apps/cross-platform/electron/build.sh"
fi
fi
if [[ ! -e "${SENTINEL_FIXTURE}" ]]; then
echo "Electron foreground sentinel was not staged: ${SENTINEL_FIXTURE}" >&2
exit 1
fi
: > "${CUA_E2E_DECLARATIONS_FILE}"
: > "${CUA_E2E_ENVIRONMENT_FILE}"
: > "${CUA_E2E_BROWSER_PROVENANCE_FILE}"
: > "${CUA_E2E_RESULTS_FILE}"
SOURCE_MARKER="${REPO_ROOT}/.cua-e2e-source-sha"
if [[ -f "${SOURCE_MARKER}" ]]; then
export CUA_E2E_SOURCE_MARKER="${CUA_E2E_SOURCE_MARKER:-${SOURCE_MARKER}}"
if [[ -z "${CUA_E2E_SOURCE_SHA:-}" ]]; then
export CUA_E2E_SOURCE_SHA="$(tr -d '[:space:]' < "${SOURCE_MARKER}")"
fi
fi
if [[ "${CUA_E2E_SKIP_BUILD:-0}" != 1 ]]; then
cargo build --release -p cua-driver \
${CARGO_DRIVER_FEATURE_ARGS[@]+"${CARGO_DRIVER_FEATURE_ARGS[@]}"} \
--manifest-path "${RUST_ROOT}/Cargo.toml"
fi
if [[ ! -x "${CUA_TEST_DRIVER_BIN}" ]]; then
echo "Driver binary not found: ${CUA_TEST_DRIVER_BIN}" >&2
exit 1
fi
if [[ "${HOST_OS}" == Linux && "${CUA_E2E_WAYLAND_SESSION:-}" == generic ]]; then
if [[ "${XDG_SESSION_TYPE:-}" != wayland || -z "${WAYLAND_DISPLAY:-}" || -z "${SWAYSOCK:-}" ]]; then
echo "The generic Wayland lane requires native Wayland and an out-of-band Sway oracle" >&2
exit 2
fi
tests=(standalone_browser_generic_wayland_existing_profile_refusal)
else
tests=(
standalone_browser_background_type
standalone_browser_type_replace
standalone_browser_owned_permission_prompt
standalone_browser_dialogs
)
if [[ "${HOST_OS}" == Linux ]]; then
tests+=(
standalone_browser_dialog_background_refusal
standalone_browser_capture_bound_pixel_click_background_refusal
)
fi
tests+=(
standalone_browser_download
)
if [[ "${HOST_OS}" != Darwin ]]; then
tests+=(standalone_browser_existing_profile_standard_refusal)
fi
tests+=(
standalone_browser_existing_profile
standalone_browser_existing_profile_setup
standalone_browser_frames
standalone_browser_multi_tab
standalone_browser_pointer_actions
standalone_browser_prepare_isolated
standalone_browser_roundtrip
standalone_browser_same_title_tabs
standalone_browser_semantic_state
standalone_browser_stale_ref
standalone_browser_trust_gated_dom_click
standalone_browser_trusted_click
standalone_browser_upload
standalone_browser_window_collision
)
if [[ "${HOST_OS}" == Darwin ]]; then
# macOS-only native-chrome keyboard regressions.
tests+=(standalone_browser_native_omnibox_select_all)
fi
fi
# shellcheck source=lib/e2e-retry-once.sh
source "${REPO_ROOT}/scripts/ci/lib/e2e-retry-once.sh"
export CUA_E2E_PLATFORM=browsers
failure_count=0
for test_name in "${tests[@]}"; do
echo "[RUN] ${test_name}"
test_status=0
cua_e2e_run_case "${test_name}" "${ARTIFACT_DIR}/${test_name}.log" "${RUST_ROOT}" \
cargo test --release -p cua-driver-e2e \
${CARGO_DRIVER_FEATURE_ARGS[@]+"${CARGO_DRIVER_FEATURE_ARGS[@]}"} \
--test standalone_browser_behavior_test "${test_name}" -- \
--ignored --exact --nocapture --test-threads=1 || test_status=$?
if [[ "${test_status}" != 0 ]]; then
failure_count=$((failure_count + 1))
fi
done
set +e
(cd "${RUST_ROOT}" && cargo run --release -p cua-driver-testkit \
--bin cua-e2e-report -- \
--declarations "${CUA_E2E_DECLARATIONS_FILE}" \
--environment "${CUA_E2E_ENVIRONMENT_FILE}" \
--results "${CUA_E2E_RESULTS_FILE}" \
--artifact-root "${ARTIFACT_DIR}" \
--require-video \
--output "${ARTIFACT_DIR}/summary.md")
report_status=$?
set -e
if [[ "${report_status}" != 0 ]]; then
failure_count=$((failure_count + 1))
fi
if [[ "${failure_count}" != 0 ]]; then
echo "Standalone-browser E2E had ${failure_count} failing step(s)" >&2
exit 1
fi
echo "Standalone-browser E2E completed"