fix: resolve page ids only among listed pages#2332
Open
thomasbachem wants to merge 1 commit into
Open
Conversation
1 task
Collaborator
|
Thanks for the PR. I think the existence of |
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.
Follow-up to #2304, and to #2328 which fixed the symptom.
getPageById()searches all of#mcpPages, which includes pages that#pagesfilters out of the listing – notablydevtools://frontends (present inbrowser.pages()viahandleDevToolsAsPage, excluded from#pagesunlessexperimentalDevToolsDebugging). Soselect_page– and every other tool that takes apageId– can target a pagelist_pagesnever showed.#2328 stopped that from silently stealing a still-open selection. This goes to the root:
getPageById()now resolves only among#pages, so an unlisted page isn't selectable in the first place. Page ids only ever reach the client through the listing, so an unlisted id has no legitimate source. Since#pagesalready includes devtools frontends whenexperimentalDevToolsDebuggingis set, that mode is unaffected.All five callers (
select_page,close_page,evaluate_script,get_tab_id, and the genericpageIdhandler) benefit uniformly – they now operate strictly on the pageslist_pagespresents. Also trims the now-stale example from #2328's fallback comment, since an unlisteddevtools://page can no longer be selected.Test: opening DevTools for a page yields a tracked-but-unlisted page; the new test asserts its id no longer resolves through
getPageById().Refs: #2304