fix: switching the network in Settings tells open pages #503

Merged
clawbot merged 1 commits from issue-500-settings-chain-changed into next 2026-10-08 09:13:18 +02:00
Collaborator

Fixes #500.

Switching the network in Settings saved it but told no open page, so a connected page kept the old chain id until it asked eth_chainId again. Once the switch is saved, Settings now sends the background an AUTISTMASK_NETWORK_CHANGED message with the new chain id, and the background hands it to broadcastChainChanged(), the function an approved wallet_switchEthereumChain request already uses. The message is in the background's list of popup-only messages, so a web page sending it gets Unauthorized sender and no page is told anything.

Choosing the network already active now returns before switching, so it changes nothing and sends nothing. The selector only fires on a change, so this can only happen when it shows a network other than the one the popup holds.

tests/chainSwitchGate.test.js drives the real Settings view over the background's storage, with what it sends delivered to the real background: one chainChanged with Sepolia's chain id, nothing for the active network, and a page refused. All three fail against current next. The Chrome suite's test page now has to hear both Settings switches, to Sepolia and back.

Judgement call: the chain id travels in the message, as the removed site's origin does for the Settings site list, instead of the background reading it back from storage; the popup-only check is what makes it trusted.

Not done: the Firefox suite has no Settings network case and was not extended.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/AutistMask/issues/500. Switching the network in Settings saved it but told no open page, so a connected page kept the old chain id until it asked `eth_chainId` again. Once the switch is saved, Settings now sends the background an `AUTISTMASK_NETWORK_CHANGED` message with the new chain id, and the background hands it to `broadcastChainChanged()`, the function an approved `wallet_switchEthereumChain` request already uses. The message is in the background's list of popup-only messages, so a web page sending it gets `Unauthorized sender` and no page is told anything. Choosing the network already active now returns before switching, so it changes nothing and sends nothing. The selector only fires on a change, so this can only happen when it shows a network other than the one the popup holds. `tests/chainSwitchGate.test.js` drives the real Settings view over the background's storage, with what it sends delivered to the real background: one `chainChanged` with Sepolia's chain id, nothing for the active network, and a page refused. All three fail against current `next`. The Chrome suite's test page now has to hear both Settings switches, to Sepolia and back. Judgement call: the chain id travels in the message, as the removed site's origin does for the Settings site list, instead of the background reading it back from storage; the popup-only check is what makes it trusted. Not done: the Firefox suite has no Settings network case and was not extended. Model: opus-5-5
clawbot added the needs-review label 2026-10-08 08:20:27 +02:00
clawbot self-assigned this 2026-10-08 08:20:27 +02:00
clawbot added 1 commit 2026-10-08 08:20:27 +02:00
fix: switching the network in Settings tells open pages (closes #500)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
2d5f3bd19e
Once Settings has saved the new network it asks the background to send
chainChanged with the new chain id to every open tab, through the same
function an approved site switch request uses. Only the extension's own
pages can ask for that. Choosing the network already active changes
nothing and sends nothing.

Model: opus-5-5
Author
Collaborator

PASS

Model: opus-5-5

PASS Model: opus-5-5
clawbot merged commit b8b13ef5cd into next 2026-10-08 09:13:18 +02:00
clawbot deleted branch issue-500-settings-chain-changed 2026-10-08 09:13:19 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#503