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 was merged in pull request #654.
This commit is contained in:
@@ -867,6 +867,14 @@ step(
|
||||
"the page was not told of the approved switch: " +
|
||||
JSON.stringify(events),
|
||||
);
|
||||
// The popup, open all along, shows the new network
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/650).
|
||||
await d.switchToWindow(env.popupWindow);
|
||||
await d.waitFor(
|
||||
"the open popup to show the testnet banner",
|
||||
`const banner = document.getElementById("debug-banner");
|
||||
return banner !== null && banner.textContent === "[TESTNET]";`,
|
||||
);
|
||||
|
||||
await openNetworkPrompt(env, "switch-restore", sepolia, mainnet);
|
||||
await d.click("#btn-approve-network");
|
||||
@@ -881,6 +889,10 @@ step(
|
||||
isDeepStrictEqual(await storedNetwork(env), before),
|
||||
"switching back did not restore the mainnet network and endpoints",
|
||||
);
|
||||
await d.waitFor(
|
||||
"the open popup to drop the testnet banner",
|
||||
`return document.getElementById("debug-banner") === null;`,
|
||||
);
|
||||
await d.switchToWindow(env.dappWindow);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -4865,6 +4865,12 @@ test("a site's network switch changes nothing until the user approves it (#408)"
|
||||
"the page was not told of the approved switch: " +
|
||||
JSON.stringify(events),
|
||||
);
|
||||
// The popup, open all along, shows the new network
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/650).
|
||||
await env.page.waitForFunction(() => {
|
||||
const banner = document.getElementById("debug-banner");
|
||||
return banner !== null && banner.textContent === "[TESTNET]";
|
||||
});
|
||||
|
||||
const restored = await openNetworkPrompt(
|
||||
env,
|
||||
@@ -4886,6 +4892,9 @@ test("a site's network switch changes nothing until the user approves it (#408)"
|
||||
isDeepStrictEqual(await storedNetwork(env.page), before),
|
||||
"switching back did not restore the mainnet network and endpoints",
|
||||
);
|
||||
await env.page.waitForFunction(
|
||||
() => document.getElementById("debug-banner") === null,
|
||||
);
|
||||
});
|
||||
|
||||
// Switching the network in Settings tells the page too, as an approved site
|
||||
|
||||
Reference in New Issue
Block a user