fix: a popup save no longer undoes a network switch the background saved during it (closes #641)
The popup's saveState() and the background's updateState() each read the stored record, change it and write it back, each 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) from the read to the write, through withLock() in src/shared/browserApi.js, and the recovery screen's reset takes it too. A page in a Firefox private window gets locks of its own and is not covered. 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:
+4
-1
@@ -367,11 +367,14 @@ async function leaveTransactionDetail(page) {
|
||||
await openAddressDetail(page);
|
||||
}
|
||||
|
||||
// Back out to Home from wherever the previous test finished.
|
||||
// Back out to Home from wherever the previous test finished, and wait for the
|
||||
// save that navigation makes, so a test reading the stored stack next reads
|
||||
// the one Home left.
|
||||
async function goHome(page) {
|
||||
await leaveTransactionDetail(page);
|
||||
await page.click("#btn-address-back");
|
||||
await visible(page, "#view-main");
|
||||
await waitForPersisted(page, "currentView", "main", "back on Home");
|
||||
}
|
||||
|
||||
// One field of the popup's state as it was actually persisted, read out of
|
||||
|
||||
Reference in New Issue
Block a user