fix: an open popup follows a network switch the background saves (closes #650)
When the background saves a network switch after the user approves a site's request, or another popup page saves one, an open popup takes the new network from the stored record inside a save, holding the lock, and checks the record once at start-up for a switch saved before it listened. The network it takes is not counted as the popup's own change, even when that save fails to write. It then leaves the page as a switch in Settings does. A switch in Settings is now made inside its own save too, so one picked while a follow waits for the lock is made after it. The popup never switches the network itself. Model: opus-5-5
This commit is contained in:
@@ -97,9 +97,9 @@ test("a refresh that returns after a switch in Settings writes nothing, and the
|
||||
);
|
||||
});
|
||||
|
||||
// The stored record still holds Ethereum Mainnet while the refresh's save reads
|
||||
// it, so only this page's own network shows the switch.
|
||||
test("a refresh whose save is reading the stored record when the user switches in Settings writes nothing", async () => {
|
||||
// The switch is made only once the refresh's save, holding the lock, has
|
||||
// written Ethereum Mainnet's balances, and the switch then clears them.
|
||||
test("a refresh whose save is reading the stored record when the user switches in Settings leaves none of its balances stored", async () => {
|
||||
const page = await bootPopup(unversionedValidProfile());
|
||||
expect(page.pageErrors).toEqual([]);
|
||||
const { state } = require("../src/shared/state");
|
||||
@@ -145,7 +145,8 @@ test("a refresh that returns after the background switched the network writes no
|
||||
|
||||
const refresh = await holdRefresh(page);
|
||||
// The background writes the switch to Sepolia, as its updateState() does
|
||||
// once the user approves a site's request. This page is not told.
|
||||
// once the user approves a site's request. This page is not told of it
|
||||
// yet.
|
||||
const record = page.storage.read("autistmask");
|
||||
applyChainSwitchFields(record, "sepolia");
|
||||
page.storage.write("autistmask", record);
|
||||
|
||||
Reference in New Issue
Block a user