You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: cp-12.15.0 Prevent fullscreen UI from opening every startup (#31332)
## **Description**
Prevent tab from opening upon every browser startup.
A [recent PR](#29826)
updated the logic for how we determine whether the extension was just
installed or not; we used to check state, but now we use the
`runtime.onInstalled` event instead to store a flag in session storage
indicating whether the extension was just installed.
Unfortunately this PR had a couple of bugs; the condition using this
flag was accidentally reversed, and the read from session storage was
never successful because of a race condition (the write had not finished
yet).
To address both problems, the logic for detecting first install was
refactored to use a global variable instead of session storage. Globals
can be accessed and written synchronously, preventing any possibility of
a race condition.
The solution was complicated by the fact that MV3 builds must add an
`onInstalled` listener in the root service worker module, otherwise the
listener is never called (we tested this experimentally). It was also
unclear whether the listener would always run before or after the
`background.js` script loading, and we need to trigger an action in
`background.js` on install. But we've accounted for both possibilities
in this solution.
[](https://codespaces.new/MetaMask/metamask-extension/pull/31332?quickstart=1)
## **Related issues**
Fixes: #30924
## **Manual testing steps**
* Create a production-like build (`yarn dist` and `yarn dist:mv2`), or
download the builds from the `metamaskbot` comment
* Test that the window opens only on first install, not on later browser
restarts.
## **Screenshots/Recordings**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
0 commit comments