Repository navigation
fix(devicelab): connecting to Chrome leaves the tabs that were open before - #281
Open
luka-vladika-happening-xyz wants to merge 1 commit into
Conversation
…efore Each connect to Chrome's DevTools closed every page target but the one it kept (closeOtherTabs, added so that openLink's new tabs do not pile up). On a phone in use that closed all of its owner's tabs at the runner's first connect, with no option to turn it off. The manager now remembers the page targets Chrome listed the first time it read them, and never closes those: they are tabs the runner did not open. Later connects close the other page targets but the kept one, as before, so the tabs openLink opens after that first look are still cleaned up. The set survives openLink's disconnect and a cleanup. A runner process can leave up to two tabs of its own open: the page kept at its first look, when an openLink came before its first connect (it is one of the remembered ones), and the page kept at its last connect, which upstream also left. Upstream left that one only, and the next process closed it; now the next process takes both for tabs that were there before. A test with a fake DevTools endpoint on a Unix socket: the first connect closes nothing, a later one only the tab opened after the first look, across a disconnect and a cleanup. It fails without the change (the first connect closed the three tabs that were open).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In browser mode on Android, every connect to Chrome's DevTools closed every page target but the one the runner keeps (
closeOtherTabs, added in cba8e61 so that the tabsopenLinkopens do not pile up). On a phone a person also uses, the first connect closed all of their open tabs, with no option to turn it off. The manager now remembers the page targets Chrome lists the first time the runner reads them and never closes those; later connects close the other page targets but the kept one, as before, so the runner's ownopenLinktabs are still cleaned up, but for up to two a run (below).Type of Change
Changes Made
webViewManager.preexistingTabs: the page targets of the first/jsonread, kept acrossdisconnectandcleanup(whichopenLinkgoes through at every link).closeOtherTabs: the first call only remembers those targets; every later call closes the page targets that are neither remembered nor kept.openLinkcame before its first connect) and the page kept at its last connect, which upstream also left; upstream left that one only, and the next run closed it, where a later run on the same phone now takes both for tabs that were there before. A tab opened during the run by someone else is closed at the next connect, as today.Related Issues
None filed.
Testing
go test -race ./pkg/driver/devicelab/)TestCloseOtherTabsLeavesTabsOpenBeforeTheFirstLookruns a fake DevTools endpoint on a Unix socket and records the tabs it is asked to close: the first connect (three tabs that were open and the one anopenLinkopened) closes nothing, then after a disconnect and a cleanup, a later connect closes only the tab opened after the first look. Onmainthe first connect closes the three tabs that were open.Manually, on an Android 16 emulator's Chrome (this commit in a build carrying other, unrelated fixes): three tabs opened before the run stayed open after a flow that opens a link and asserts on it, where
mainclosed them; a second run left one more tab of its own, and a run of three links closed only its own middle one.Checklist