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:
@@ -461,13 +461,15 @@ address, the transaction assertions run against the raw signed transaction
|
||||
captured at `eth_sendRawTransaction` rather than against anything the extension
|
||||
reported, rejecting each prompt is required to return a rejection to the page
|
||||
rather than hang or resolve, a network switch request is required to leave the
|
||||
stored network unchanged and send no `chainChanged` until it is approved, a
|
||||
network switch in Settings is required to send the page `chainChanged` with the
|
||||
new chain id, a prompt raised while another approval window has focus is
|
||||
required to open a window of its own, and the password is required to be absent
|
||||
from every message the approval window sends to the background — with the
|
||||
message that would carry it required to be present, so that check cannot pass by
|
||||
observing nothing. That last one is the standing floor under
|
||||
stored network unchanged and send no `chainChanged` until it is approved, the
|
||||
popup open all along is required to show the `[TESTNET]` banner once a switch to
|
||||
Sepolia is approved and to drop it once the switch back is, a network switch in
|
||||
Settings is required to send the page `chainChanged` with the new chain id, a
|
||||
prompt raised while another approval window has focus is required to open a
|
||||
window of its own, and the password is required to be absent from every message
|
||||
the approval window sends to the background — with the message that would carry
|
||||
it required to be present, so that check cannot pass by observing nothing. That
|
||||
last one is the standing floor under
|
||||
[#157](https://git.eeqj.de/sneak/AutistMask/issues/157).
|
||||
|
||||
The limits of that coverage and of the rest of the Chrome suite, none of them
|
||||
@@ -603,9 +605,10 @@ suite), wallet creation through the UI, the Add Token screen, and the dApp round
|
||||
trips — `eth_requestAccounts`, `personal_sign`, `wallet_switchEthereumChain`
|
||||
rejected and then approved, `eth_sendTransaction`, and a closed approval window
|
||||
rejecting with EIP-1193 4001 — driven through the real content script,
|
||||
background page and approval windows. The `personal_sign` prompt is also
|
||||
required to fit its window without scrolling sideways, with the extension's
|
||||
pages at 170% zoom.
|
||||
background page and approval windows. The popup open all along is required to
|
||||
show the `[TESTNET]` banner once the switch to Sepolia is approved and to drop
|
||||
it once the switch back is. The `personal_sign` prompt is also required to fit
|
||||
its window without scrolling sideways, with the extension's pages at 170% zoom.
|
||||
|
||||
The suite lives in `tests/e2e/firefox/`. Its WebDriver client (`driver.js`) has
|
||||
**no npm dependencies at all**: it is built on global `fetch` and
|
||||
@@ -1564,20 +1567,29 @@ such as an edit typed into Settings and not yet saved. Home is the one screen
|
||||
"Back" always re-renders, so the wallet list reflects anything that changed
|
||||
while the user was away from it.
|
||||
|
||||
A network switch in Settings leaves every screen beneath Settings showing the
|
||||
previous network, so after it "Back" behaves as in a reopened popup: every
|
||||
screen on the stack counts as not yet rendered, and the stack is cut at the
|
||||
first screen that cannot be rendered from saved state, such as Send or AddToken,
|
||||
or at AddressToken for any token but the native one, because that token was
|
||||
picked on the previous network. The cut stack is saved with the switch, so a
|
||||
popup closed straight after it and reopened onto Settings lands in the same
|
||||
place. "Back" then renders the screen it lands on for the new network, and
|
||||
anything typed there and not saved, which belonged to the previous network, is
|
||||
dropped. ConfirmTx, WaitTx, SuccessTx, ErrorTx and TransactionDetail are
|
||||
rendered instead for the network of the transaction they show: the network it
|
||||
was reviewed on for ConfirmTx, and the network it was sent on for the others.
|
||||
Without a wallet the stack is not cut, because it starts at Welcome, which shows
|
||||
nothing from a network.
|
||||
A network switch leaves every screen on the page showing the previous network.
|
||||
The user makes it in Settings, or approves a site's request and the background
|
||||
saves it. Any other popup open meanwhile takes the switch from the stored
|
||||
record, even one saved while it was opening, and never switches the network
|
||||
itself. A switch the user picks in its Settings while it takes one is made after
|
||||
it, not overwritten by it. An approval window does not take the switch. After
|
||||
the switch, whichever way the page got it, "Back" behaves as in a reopened
|
||||
popup: every screen on the stack counts as not yet rendered, and the stack is
|
||||
cut at the first screen that cannot be rendered from saved state, such as Send
|
||||
or AddToken, or at AddressToken for any token but the native one, because that
|
||||
token was picked on the previous network and is no longer selected. The cut
|
||||
stack is saved with the popup's new network, so a popup closed straight after
|
||||
and reopened lands in the same place. The screen on top is drawn again for the
|
||||
new network: Settings in place, and any other screen as a reopened popup draws
|
||||
it, so Home takes the place of one that cannot be rendered from saved state or
|
||||
of AddressToken for a token no longer selected. "Back" then renders the screen
|
||||
it lands on for the new network, and anything typed there and not saved, which
|
||||
belonged to the previous network, is dropped. ConfirmTx, WaitTx, SuccessTx,
|
||||
ErrorTx and TransactionDetail are rendered instead for the network of the
|
||||
transaction they show: the network it was reviewed on for ConfirmTx, and the
|
||||
network it was sent on for the others. Without a wallet the stack is not cut and
|
||||
only Settings is drawn again, because the stack starts at Welcome, and Welcome
|
||||
and AddWallet show nothing from a network.
|
||||
|
||||
Every screen that holds secret material in the page registers a cleanup with
|
||||
`onViewLeave()` (`src/popup/views/helpers.js`), which `showView()` runs on every
|
||||
|
||||
Reference in New Issue
Block a user