[docs] decision: browsing contexts are exposed as handle objects#17681
[docs] decision: browsing contexts are exposed as handle objects#17681AutomatedTester wants to merge 4 commits into
Conversation
7a177ac to
6b5f6f8
Compare
Add user contexts (BiDi isolation unit) to the handle object model rather than a separate record: isolated= shortcut for the common case, the create_user_context() factory for shared partitions, session-option inheritance, and internal/private isolation types. Rename the file to use the PR number (17681) instead of an ADR number.
… contextCreated Point cross-references at the PR-number filenames, add expect_popup to the return-type change note, and list browsingContext.contextCreated (which backs expect_page/expect_popup) in the appendix for consistency with 17671.
Add a Java handle snippet alongside the JS one, and a subsection (with a Java example) stating that log/network events are scoped by subscription, not by the user context: global vs contexts=[tab] vs userContexts=[uc] (latter covers future tabs). Back it with the §3.6 subscription-matching fact in the appendix.
|
|
||
| ```python | ||
| # 80% — isolation on/off, zero config, returns a normal tab handle | ||
| tab = driver.browsing_context.create(type=WindowTypes.TAB, isolated=True) |
There was a problem hiding this comment.
browsing_context here is still verbose, simple accessor for couple of methods even without internal state... Can be simplified:
tab = driver.new_tab(...)
ctx = driver.new_context(...)
ctx.new_tab(...)
tab, context here is an example of alternate names, honestly for me as for end user it is not obvious what is BiDi's browsingContext and userContext. Tab or Page is cleaner.
There was a problem hiding this comment.
For the most part, I don't think users should need to understand contexts which is why I call it "isolation" in terms of browser context we already have the switchTo APIs which we can extend to understand isolation.
I don't really want too much on driver as we can head into the space of creating a god object which is worse.
There was a problem hiding this comment.
I think for the most part the UserContext doesn't need to be surfaced to the user. I would for the verbose case have this and for a more succinct API that allows people to do whatever they want
💥 What does this PR do?
Proposes a design decision record: browsing contexts are exposed as handle objects.
Working with multiple tabs/windows over BiDi is awkward because there is no object representing a single browsing context — every operation is called on one shared module instance and takes the context id explicitly (
browsing_context.navigate(context=id, ...)). For parallel work this means each worker repeatscontext=bookkeeping against shared state, with no per-tab unit to own. This record proposes a per-context handle object (returned bycreate/get_tree/expect_page) that carries the per-context operations as methods and scopes events to that context — matching the Playwright model where operations live on the object, which is exactly what makes one-context-per-worker parallelism clean. The flat module API stays as the compatibility surface.🔧 Implementation Notes
docs/decisions/process from [docs] add design decision record process and template #17665 — depends on [docs] add design decision record process and template #17665 landing (adds onlydocs/decisions/0008-*.md).expect_*primitive ([docs] decision: BiDi events are awaited with expect_* context managers #17671) forexpect_page/expect_popup.BrowserContext), and fixing per-context event-subscription scoping.Pagemodel is explicitly out of scope (its own RFC). No wire-protocol change.🤖 AI assistance
browsing_contextsurface and BiDi transport against Playwright's object/concurrency model; revised through discussion and review💡 Additional Considerations
Extends the set of BiDi ergonomics decision records (#17671–#17677) with the parallelisation/object-model concept. The cross-binding name of the handle (
Page-like /Tab/BrowsingContextHandle) is part of what's being decided. Cross-binding convergence is tracked in the binding-status table.🔄 Types of changes