The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
Quitting while an imported extension installs from the Web Store no longer crashes (#227)
Victor3fe0c5b9260c
diff --git a/Tests/Fixtures/WebStoreCopy/ID b/Tests/Fixtures/WebStoreCopy/IDnew file mode 100644index 0000000..301ee70--- /dev/null+++ b/Tests/Fixtures/WebStoreCopy/ID@@ -0,0 +1 @@+caklagheakgjegjifmfmjligclngmikgdiff --git a/Tests/Fixtures/WebStoreCopy/caklagheakgjegjifmfmjligclngmikg/manifest.json b/Tests/Fixtures/WebStoreCopy/caklagheakgjegjifmfmjligclngmikg/manifest.jsonnew file mode 100644index 0000000..b8b3b19--- /dev/null+++ b/Tests/Fixtures/WebStoreCopy/caklagheakgjegjifmfmjligclngmikg/manifest.json@@ -0,0 +1,8 @@+{+ "manifest_version": 3,+ "name": "Cra Web Store Copy Fixture",+ "version": "1.0",+ "description": "Made up for scripts/scenario.sh: a Web Store extension as an import copies it (the store's update_url, a folder named by its ID), so Cra installs it from the store.",+ "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoUXvuoORaGfgdQgkOKk3hh4RFYj/3wTBTef+bzL6CJuJckv2pUrcCHiG+N3fTJ6UCOkTa04hUvzNuRRzfnp+E0sCAIc4iQPItjuqMlF4ZT+s+JB8o5YCk2QBloPW4Z/8KMo7IOHEtRdrKreoOttcmib87bhoR2Os/Jur/WN+xemKZ373pvSp5UAUWicW7GJdPTMW0NVTbCp+S+fXoaxiUO/iXL4rO2BIWf90YPj3PwyNtuLwRl5UasjPsh1KNLNCCtZH8Wfcg9WIr+BNOlPIboIFCDGIqZAwm0lXIp67admID4FVvYqNMHS+3fEriA04SAGVj7YvrtL0ZnhzokLvtwIDAQAB",+ "update_url": "https://clients2.google.com/service/update2/crx"+}diff --git a/Tests/Scenarios/quit-during-web-store-install.scenario b/Tests/Scenarios/quit-during-web-store-install.scenarionew file mode 100644index 0000000..3180033--- /dev/null+++ b/Tests/Scenarios/quit-during-web-store-install.scenario@@ -0,0 +1,14 @@+# Cra quits while it is still installing an imported extension from the Web Store. The install's+# hidden page outlived Chromium's profile, and CefShutdown stopped on Chromium's check that every+# page closes first ("BrowserContext is getting destroyed without first closing all WebContents"):+# a crash report on each quit while an install ran or hung (GitHub #227).+# promise: #227+budget rss=600+extension ${FIXTURES}/WebStoreCopy/${WEB_STORE_COPY_ID}+# The store's download goes to an address that never answers, so the install is still running+# when the scenario quits.+arg --apps-gallery-download-url=${STALL}/%s.crx+cra://open?url=${PAGE}?n=store+expect-log extension ${WEB_STORE_COPY_ID}: installing from the Web Store in Default+wait 2+reject-log Web Store install in Default faileddiff --git a/Tests/promises.lock b/Tests/promises.lockindex 44b92da..931c69a 100644--- a/Tests/promises.lock+++ b/Tests/promises.lock@@ -351,3 +351,4 @@#220 Tests/Scenarios/blank-window.scenario cac94fd094a6#220 Tests/StoreTests.swift::blankWindowWithoutItsWindow 0de383e3d544#220 Tests/StoreTests.swift::blankWindows 2703cb42812a+#227 Tests/Scenarios/quit-during-web-store-install.scenario a3e3b0c8eb2bdiff --git a/docs/testing.md b/docs/testing.mdindex b8fe405..5d4ec5f 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -64,7 +64,8 @@ no page content), so it checks geometry, ink and fills.(`SidebarIntegrity`), main-thread stalls inside the scenario's budget, Cra's memory insideits budget, helper processes back to baseline five seconds after tabs close, the performancerecorder under 0.1 % of a core (`selfCost.cpuPct` in its perf.json, `budget perfcpu=`) with its- count of 250 ms stalls within a few of HitchMonitor's, and a quit within 20 seconds.+ count of 250 ms stalls within a few of HitchMonitor's, and a quit within 20 seconds that ends+ without a signal (#227: ReportCrash can take longer to write its report than the run waits).The budgets are for a release build (`scripts/build.sh`), which is what the nightly runs: adebug build's recorder costs about six times as much (0.16–0.22 % against 0.03–0.04 %, 6 Nov2026), so on a debug build the recorder line fails and means nothing.@@ -112,8 +113,8 @@ one. Every launch checks the sidebar and logs a fault for each broken link.scripts/scenario.sh all # every one, about 6 minutesA scenario (`Tests/Scenarios/*.scenario`) is a list of `cra://` commands plus a few-directives (`wait`, `repeat`, `budget`, `helpers`, `relaunch`, `expect-log`, `snapshot`, `seed`, `env`, `home`;-the header of `scripts/scenario.sh` lists them). It runs `build/Cra.app` on a throwaway data+directives (`wait`, `repeat`, `budget`, `helpers`, `relaunch`, `expect-log`, `snapshot`, `seed`, `env`,+`arg`, `extension`, `home`; the header of `scripts/scenario.sh` lists them). It runs `build/Cra.app` on a throwaway datafolder, behind your windows (`CRA_TEST_BACKGROUND`), with the fixture pages served from127.0.0.1. Logs, hitch log and snapshots land in `build/scenarios/<name>/`. Adding a journeyis a text file; the invariants come for free.diff --git a/scripts/cef-patches/freezing-vote.patch b/scripts/cef-patches/freezing-vote.patchindex 9827b8b..4c7ea3b 100644--- a/scripts/cef-patches/freezing-vote.patch+++ b/scripts/cef-patches/freezing-vote.patch@@ -11,10 +11,10 @@ index dd0a558c0..a54f79de4 100644"//components/pref_registry","//components/printing/browser",diff --git a/cef/libcef/browser/devtools/devtools_controller.cc b/cef/libcef/browser/devtools/devtools_controller.cc-index c60f22d..da94ae0 100644+index c60f22d1a..f0d609890 100644--- a/cef/libcef/browser/devtools/devtools_controller.cc+++ b/cef/libcef/browser/devtools/devtools_controller.cc-@@ -5,10 +5,416 @@+@@ -5,10 +5,435 @@#include "cef/libcef/browser/devtools/devtools_controller.h"#include "base/json/json_reader.h"@@ -22,6 +22,7 @@ index c60f22d..da94ae0 100644+#include "base/functional/callback_helpers.h"#include "base/json/json_writer.h"+#include "base/memory/ref_counted.h"++#include "base/scoped_observation.h"+#include "base/strings/string_number_conversions.h"+#include "base/supports_user_data.h"+#include "base/task/sequenced_task_runner.h"@@ -30,6 +31,7 @@ index c60f22d..da94ae0 100644+#include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.h"+#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"+#include "chrome/browser/profiles/profile.h"++#include "chrome/browser/profiles/profile_observer.h"+#include "components/crx_file/id_util.h"+#include "components/performance_manager/freezing/freezing_policy.h"+#include "components/performance_manager/public/freezing/freezing.h"@@ -213,17 +215,34 @@ index c60f22d..da94ae0 100644++// The page that downloads the store's CRX, as WebstoreInstallWithPrompt has+// one: never shown, so the download stays out of every window's UI. It lives-+// until the install is over.++// until the install is over, or until its profile goes away: a quit while an++// install still ran (or never ended) destroyed the profile with the page open,++// and Chromium stops on that ("BrowserContext is getting destroyed without++// first closing all WebContents", GitHub #227). WebstoreInstaller holds the++// page through a WeakPtr; an install cut off this way never replies, and the++// client asks for it again on the next launch.+struct CraWebStoreInstallPage-+ : public base::RefCountedThreadSafe<CraWebStoreInstallPage> {++ : public base::RefCountedThreadSafe<CraWebStoreInstallPage>,++ public ProfileObserver {+ explicit CraWebStoreInstallPage(Profile* profile)+ : contents(content::WebContents::Create(-+ content::WebContents::CreateParams(profile))) {}++ content::WebContents::CreateParams(profile))) {++ profile_observation_.Observe(profile);++ }+ std::unique_ptr<content::WebContents> contents;+++ // ProfileObserver: first thing in ~ProfileImpl, before its user data (the++ // list of the profile's WebContents) is checked and cleared.++ void OnProfileWillBeDestroyed(Profile* profile) override {++ profile_observation_.Reset();++ contents.reset();++ }+++ private:+ friend class base::RefCountedThreadSafe<CraWebStoreInstallPage>;-+ ~CraWebStoreInstallPage() = default;++ ~CraWebStoreInstallPage() override = default;++++ base::ScopedObservation<Profile, ProfileObserver> profile_observation_{this};+};++// Cra (GitHub #203): {"id":N,"method":"Cra.installFromWebStore","params":@@ -431,7 +450,7 @@ index c60f22d..da94ae0 100644CefDevToolsController::CefDevToolsController(content::WebContents* inspected_contents)-@@ -30,6 +436,38 @@ CefDevToolsController::~CefDevToolsController() {+@@ -30,6 +455,38 @@ CefDevToolsController::~CefDevToolsController() {bool CefDevToolsController::SendDevToolsMessage(const std::string_view& message) {CEF_REQUIRE_UIT();diff --git a/scripts/fetch-cef.sh b/scripts/fetch-cef.shindex 242eafc..44d3077 100755--- a/scripts/fetch-cef.sh+++ b/scripts/fetch-cef.sh@@ -13,7 +13,7 @@ CEF_VERSION="${CEF_VERSION:-156.0.15+gcf671c0+chromium-156.0.8078.80}"ARCH="${CEF_ARCH:-macosarm64}"NAME="cef_binary_${CEF_VERSION}_${ARCH}_minimal"# Bump the suffix (codecs2, …) when the build changes but CEF_VERSION does not.-CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs16}"+CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs17}"URL="${CEF_URL:-https://github.com/VictorKildahl/cra/releases/download/${CEF_RELEASE}/cef_binary_${ARCH}_minimal.tar.bz2}"mkdir -p vendordiff --git a/scripts/scenario.sh b/scripts/scenario.shindex f35110e..97a9f0b 100755--- a/scripts/scenario.sh+++ b/scripts/scenario.sh@@ -33,6 +33,10 @@# seed <file> <json> that data-folder file before launch (a seeded settings.json# replaces the default one)# env <NAME=value> passed to Cra+# arg <--switch=value> on Cra's command line, for Chromium (the first launch only: a+# relaunch drops it)+# extension <folder> copied into the data folder's Extensions/ before launch, as an+# import leaves an extension# home a throwaway home folder, so downloads stay out of ~/Downloads# requires screen# port <n> serve ${PAGE} on a fixed port (snapshots show the address)@@ -40,7 +44,9 @@# for developer mode and tab sleep), ${WEBKIT} (that server as http://localhost:<port>, a host the# run treats as a DRM service, so its pages open in WebKit), ${EXTENSION_ID} (Tests/Fixtures/Extension) and# ${SIDE_PANEL_EXTENSION_ID} (Tests/Fixtures/SidePanelExtension) and ${DOWNLOAD_EXTENSION_ID}-# (Tests/Fixtures/DownloadExtension) expand.+# (Tests/Fixtures/DownloadExtension) and ${WEB_STORE_COPY_ID} (Tests/Fixtures/WebStoreCopy) expand,+# and ${STALL}, an address on 127.0.0.1 that takes connections and never answers (a download+# that never ends).set -uo pipefailcd "$(dirname "$0")/.."ROOT="$PWD"@@ -49,6 +55,7 @@ FIXTURES="$ROOT/Tests/Fixtures"EXTENSION_ID="$(cat "$FIXTURES/Extension/ID")"SIDE_PANEL_EXTENSION_ID="$(cat "$FIXTURES/SidePanelExtension/ID")"DOWNLOAD_EXTENSION_ID="$(cat "$FIXTURES/DownloadExtension/ID")"+WEB_STORE_COPY_ID="$(cat "$FIXTURES/WebStoreCopy/ID")"if [ "${1:-}" = "all" ]; thenfailed=()@@ -118,21 +125,38 @@ s = Server(("127.0.0.1", int(sys.argv[2])), functools.partial(http.server.Simpleprint(f"Serving HTTP on 127.0.0.1 port {s.server_address[1]}", flush=True)s.serve_forever()' "$FIXTURES/Pages" "${FIXED_PORT:-0}" >"$OUT/server.log" 2>&1 &SERVER=$!+disown "$SERVER" # killed at the end without a "Terminated" linefor _ in $(seq 1 300); do PORT=$(sed -n 's/.*port \([0-9]*\).*/\1/p' "$OUT/server.log" | head -1); [ -n "$PORT" ] && break; sleep 0.1; donePAGE="http://127.0.0.1:${PORT:?http server did not start}/page.html"# The same server under another host, which the run lists as a DRM service (CRA_WEBKIT_HOSTS):# its pages open in WebKit, the way Spotify and Netflix do (ProtectedMediaSites).WEBKIT="http://localhost:${PORT}"+# A port that accepts connections (the kernel's backlog does) and never answers one.+python3 -I -u -c '+import socket, time+s = socket.socket()+s.bind(("127.0.0.1", 0))+s.listen(64)+print(s.getsockname()[1], flush=True)+time.sleep(86400)' >"$OUT/stall.log" 2>&1 &+STALLER=$!+disown "$STALLER"+for _ in $(seq 1 50); do STALL_PORT=$(head -1 "$OUT/stall.log"); [ -n "$STALL_PORT" ] && break; sleep 0.1; done+STALL="http://127.0.0.1:${STALL_PORT:?stalling port did not open}"+expand() { local s="$1"; s="${s//\$\{FIXTURES\}/$FIXTURES}"; s="${s//\$\{PAGE\}/$PAGE}"; s="${s//\$\{WEBKIT\}/$WEBKIT}"; s="${s//\$\{STALL\}/$STALL}"; s="${s//\$\{EXTENSION_ID\}/$EXTENSION_ID}"; s="${s//\$\{SIDE_PANEL_EXTENSION_ID\}/$SIDE_PANEL_EXTENSION_ID}"; s="${s//\$\{DOWNLOAD_EXTENSION_ID\}/$DOWNLOAD_EXTENSION_ID}"; s="${s//\$\{WEB_STORE_COPY_ID\}/$WEB_STORE_COPY_ID}"; printf '%s' "$s"; }+app_args=()+while read -r _ a; do app_args+=("$(expand "$a")"); done < <(grep '^arg ' "$FILE")+while read -r _ f; do mkdir -p "$DATA/Extensions" && cp -R "$(expand "$f")" "$DATA/Extensions/"; done < <(grep '^extension ' "$FILE")CRA_DATA_DIR="$DATA" CRA_COMMAND_FILE="$CMD" CRA_HITCH_LOG="$HITCH" CRA_TEST_BACKGROUND=1 CRA_WEBKIT_HOSTS=localhost \CRA_ARC_DIR="$FIXTURES/Arc" CRA_FLAGS="${CRA_FLAGS:-}" \- "${app_env[@]}" "$APP/Contents/MacOS/Cra" >"$OUT/stdout.log" 2>&1 &+ "${app_env[@]}" "$APP/Contents/MacOS/Cra" ${app_args[@]+"${app_args[@]}"} >"$OUT/stdout.log" 2>&1 &PID=$!PIDS+=("$PID")cleanup() {for p in "${PIDS[@]}"; do kill -KILL "$p" 2>/dev/null; done- kill "$SERVER" 2>/dev/null+ kill "$SERVER" "$STALLER" 2>/dev/nullcp "$DATA"/cra*.log "$OUT/" 2>/dev/nullrm -rf "$DATA"}@@ -162,7 +186,6 @@ sleep 2PACE=0.2RSS_BUDGET=1500 MAXSTALL=1500 STALLS50=10 LAUNCHSTALL=1000 PERFCPU=0.1BASELINE=""-expand() { local s="$1"; s="${s//\$\{FIXTURES\}/$FIXTURES}"; s="${s//\$\{PAGE\}/$PAGE}"; s="${s//\$\{WEBKIT\}/$WEBKIT}"; s="${s//\$\{EXTENSION_ID\}/$EXTENSION_ID}"; s="${s//\$\{SIDE_PANEL_EXTENSION_ID\}/$SIDE_PANEL_EXTENSION_ID}"; s="${s//\$\{DOWNLOAD_EXTENSION_ID\}/$DOWNLOAD_EXTENSION_ID}"; printf '%s' "$s"; }echo "$NAME (pid $PID, logs in ${OUT#$ROOT/})"while IFS= read -r raw || [ -n "$raw" ]; do@@ -223,7 +246,7 @@ while IFS= read -r raw || [ -n "$raw" ]; do[ -x "$OUT/compare-png" ] || xcrun swiftc -O "$ROOT/scripts/compare-png.swift" -o "$OUT/compare-png" 2>"$OUT/compare-png.log"verdict=$("$OUT/compare-png" "$ref" "$shot" "$OUT/snapshots/$3.diff.png" 2>&1) || budget_problem "snapshot $3: $verdict"fi ;;- fresh|requires|port|seed|env|home) ;;+ fresh|requires|port|seed|env|arg|extension|home) ;;*) problem "unknown scenario line: $line" ;;esacdone < "$FILE"@@ -280,6 +303,13 @@ if alive; thenfor _ in $(seq 1 100); do alive || break; sleep 0.2; donealive && problem "Cra did not quit within 20 s"fi+# How the Cra this script started ended: a crash on the way out (#227) shows here at once, while+# ReportCrash can take longer than the wait below to write its report. A relaunched Cra isn't+# this shell's child; its crash shows only as a report.+if [ "$PID" = "${PIDS[0]}" ] && ! alive; then+ wait "$PID" 2>/dev/null; status=$?+ [ "$status" -gt 128 ] && problem "Cra ended on signal $((status - 128)) (a crash; while quitting unless reported above)"+ficount_faults[ "$FAULTS" -eq 0 ] || problem "$FAULTS fault line(s) in cra.log (faults.txt)"