[py] Add high-level BiDi permissions API#17631
Open
AutomatedTester wants to merge 2 commits into
Open
Conversation
aa9a317 to
df04f26
Compare
Introduces a PermissionsManager helper (py/private/_permissions_handlers.py) that layers grant/deny/reset/reset_all and a context manager (override) on top of the existing permissions.setPermission command, following the same handler-module pattern used for network and script. Changes: - New _permissions_handlers.py staged into the bidi package by Bazel - Permissions.__init__ now accepts an optional driver argument (same as Script) - bidi_enhancements_manifest.py wires up PermissionsManager and exposes the convenience methods on the generated Permissions class - BUILD.bazel adds _permissions_handlers.py to create-bidi-src extra_srcs - generate_bidi.py extends the driver-arg __init__ to the permissions module - New unit tests cover grant/deny/reset/reset_all and the context manager
df04f26 to
b0687ba
Compare
Aligns the low-level set_permission command with the grant/deny/reset/ override convenience methods, where origin and user_context are already keyword-only. Internal callers and tests updated accordingly.
Open
2 tasks
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.
Introduces a
PermissionsManagerhelper (py/private/_permissions_handlers.py)that layers convenience methods on top of the existing
permissions.setPermissioncommand, following the same handler-module pattern used for network and script.
Changes
_permissions_handlers.pystaged into the bidi package by BazelPermissions.__init__now accepts an optional driver argument (same asScript)bidi_enhancements_manifest.pywires upPermissionsManagerand exposes theconvenience methods on the generated
PermissionsclassBUILD.bazeladds_permissions_handlers.pytocreate-bidi-srcextra_srcsgenerate_bidi.pyextends the driver-arg__init__to the permissions moduleNew API
API comparison: Selenium BiDi vs. Playwright
BrowserContext)driver.permissions)grant_permissions(["geolocation"], origin=…)grant("geolocation", origin=…)grant_permissions(["geo", "camera"], origin=…)grant(["geo", "camera"], origin=…)deny("geolocation", origin=…)clear_permissions()reset("geolocation", origin=…)reset(["geolocation", "camera"], origin=…)clear_permissions()reset()— clears tracked overridesoverride("geolocation", "granted", origin=…)origin=origin=user_context=set_permission(descriptor, state, origin)https://claude.ai/code/session_018zDh8UVeD7rTyJQQZpAVne