There was no packaging target anywhere, no artifact, and no `key` in `manifest/chrome.json` — so an unpacked Chrome load derived its extension id, and therefore its `chrome.storage.local` partition, from the absolute checkout path. Moving or re-cloning the checkout presented an empty wallet, with no error and nothing in the UI to say so. `manifest/chrome.json` now carries a fixed `key`: the public half of an RSA keypair, which pins the extension id to `gipbhkogfopeahplcjhipkgpcimdpkip`. The private half is a credential and is not in this repo; no target generates one into the working tree, and `tests/extensionId.test.js` fails if a `.pem` is ever committed. Changing `key` changes the id and orphans every wallet stored under the old one. `make package` (script/package) runs `make build` — the only audited path to a release build — and writes one self-contained, versioned archive per browser into `release/`, plus `SHA256SUMS`. The archives are deterministic: entries sorted, timestamps fixed, compression level fixed, so two builds of one commit are byte-identical. Self-containment is checked rather than assumed: every path the manifests and the popup HTML reference is resolved and required to be inside the archive, a reference that climbs out of the extension root is a hard failure, and files left at the `dist/` root — `dist/styles.css`, which build.js copies into each browser directory — are reported as deliberately not shipped rather than dropped by a glob. The archive is then read back off disk and compared member by member against the directory it was built from. The zip writer and reader are stdlib zlib in `script/lib/zip.js`; no new dependency, and nothing unpinned. One version, enforced rather than generated. `script/lib/version.js` requires `package.json`, `manifest/chrome.json` and `manifest/firefox.json` to agree and fails the build naming each file and what it said, instead of reading from one of the three. `BUILD_COMMIT` now carries `-dirty` when the working tree does not match `HEAD`, and `-unknown` when git cannot say; the full hash behind the About screen's commit link stays clean so the link still resolves. Two real-browser observations, both run through the pinned harnesses: - `tests/e2e/storagePartition.js` loads the build from two different paths in one Chrome profile. With `key`: same id, and the second load reads the first load's storage. Without `key`: different ids, and the second load sees an empty partition. Loading both keyed copies at once yields one id, not two. - `tests/e2e/firefox/reinstall.js` installs the packaged XPI in a real Firefox, creates a wallet, quits the browser, restarts on the same profile, adds the add-on again, and decrypts the vault back to the original recovery phrase. It then observes that an explicit uninstall DESTROYS that storage — correct browser behaviour, but for a wallet it means Remove is irreversible except from the recovery phrase, so README.md says so. Firefox ships an UNSIGNED XPI. README.md states plainly that release Firefox and ESR will refuse it, that Developer Edition, Nightly or an Unbranded build is required, and that a temporary add-on does not survive a browser restart. AMO signing, CRX packing, tagging and any upload are deliberately out of scope.
91 lines
3.4 KiB
Bash
Executable File
91 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# script/test-e2e-firefox: build the extension and drive the real popup in
|
|
# a real Firefox inside a pinned container. The Firefox counterpart to
|
|
# script/test-e2e. Our own extension to scripts-to-rule-them-all.
|
|
#
|
|
# Deliberately NOT called by script/check or script/test, for the same
|
|
# reason as the Chrome suite: REPO_POLICIES.md caps make test at 20 seconds
|
|
# and a browser suite does not fit. .gitea/workflows/e2e.yml also runs it
|
|
# on every push, in a job separate from check.
|
|
#
|
|
# Unlike script/test-e2e this builds its base image locally, because no
|
|
# published image carries both a pinned Firefox and a matching geckodriver.
|
|
# All three external artifacts are pinned by digest inside the Dockerfile;
|
|
# see tests/e2e/firefox/Dockerfile, which also explains why the repo and
|
|
# the extension build are baked into the image rather than mounted.
|
|
#
|
|
# Docker is the only prerequisite: nothing here depends on the node, yarn
|
|
# or make on the machine that starts the run.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
|
|
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-firefox"
|
|
|
|
IIDFILE=""
|
|
|
|
cleanup() {
|
|
if [ -n "$IIDFILE" ]; then
|
|
rm -f "$IIDFILE"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
|
|
if ! command -v docker >/dev/null 2>&1; then
|
|
echo "test-e2e-firefox: docker is required to run the e2e suite" >&2
|
|
exit 1
|
|
fi
|
|
|
|
IIDFILE="$(mktemp)"
|
|
trap cleanup EXIT
|
|
trap 'cleanup; exit 130' INT TERM
|
|
|
|
echo "Building the pinned Firefox e2e image (extension included)..."
|
|
docker build --iidfile "$IIDFILE" -t "$IMAGE" \
|
|
-f tests/e2e/firefox/Dockerfile .
|
|
|
|
echo "Running the Firefox e2e suite..."
|
|
# The image is run by ID, not by tag: where two clones of this repo run
|
|
# the suite at once, the other build can move the tag between this
|
|
# build and this run, and the suite would then silently test the other
|
|
# checkout.
|
|
#
|
|
# --shm-size=1g: Firefox needs more than the default 64MB /dev/shm.
|
|
# --network none: the suite stubs nothing, so this is what keeps the
|
|
# run offline and deterministic. The extension swallows its own
|
|
# fetch failures, so the popup flows work unchanged; see the
|
|
# network note in README.md. Weaker than the Chrome suite's
|
|
# fixture interception, and honestly so — it proves no request
|
|
# escaped, but it cannot report which ones were attempted.
|
|
# HOME=/tmp: the image's root home is not a reliable place for the
|
|
# browser profile.
|
|
#
|
|
# No --privileged. Firefox's sandbox logs
|
|
# "CanCreateUserNamespace() clone() failure: EPERM" on startup here;
|
|
# it is cosmetic and headless Firefox runs fine without it.
|
|
docker run --rm \
|
|
--shm-size=1g \
|
|
--network none \
|
|
-e HOME=/tmp \
|
|
"$(cat "$IIDFILE")" \
|
|
node tests/e2e/firefox/run.js dist/firefox
|
|
|
|
# The install/uninstall/re-install property, against the packaged XPI
|
|
# rather than the unpacked directory: it is the artifact a user would be
|
|
# handed, and this is the only place a real Firefox is asked to load it.
|
|
# Its own browser session, because it takes the add-on away in the middle
|
|
# and the suite above shares one session throughout.
|
|
echo "Running the Firefox re-install suite against the packaged XPI..."
|
|
docker run --rm \
|
|
--shm-size=1g \
|
|
--network none \
|
|
-e HOME=/tmp \
|
|
"$(cat "$IIDFILE")" \
|
|
node tests/e2e/firefox/reinstall.js
|
|
}
|
|
|
|
main "$@"
|