fix: a popup save no longer undoes a network switch the background saved during it (closes #641)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

The popup's saveState() and the background's updateState() each read the
stored record, change it and write it back, and each was ordered only within
its own context, so a write by one could land between the other's read and
write and be lost. Both now hold the browser's lock (navigator.locks, shared
by every page and the background except a page in a Firefox private window)
from the read to the write, through withLock() in src/shared/browserApi.js;
the recovery screen's reset takes it too. The lock also orders a page's own
saves, so both per-context queues are gone. The unit tests get a small lock
from a Jest setup file.

Model: opus-5-5
This commit is contained in:
2026-10-20 16:58:12 +00:00
parent 4472746b89
commit db0d81e78e
16 changed files with 231 additions and 62 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ global.document = {
body: { prepend() {}, appendChild() {} },
addEventListener() {},
};
global.navigator = { clipboard: { writeText() {} } };
global.navigator.clipboard = { writeText() {} };
const { AbiCoder, parseUnits } = require("ethers");
const { fetchTokenBalances } = require("../src/shared/balances");