Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor session handling for better integration with BiDi #1608

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Jul 14, 2021

This is a large change, but it's almost entirely refactoring.

The main aim here is to split the session concept so that there's a base "session" which holds the session id and state that's appropriate to both WebDriver classic and BiDi. Then, we define a "HTTP Session" as one that has the HTTP Flag set and use that to compose-in any state that's only used in the classic HTTP-based protocol.

In addition, we rework the way state is passed around the spec so that we are using an explicit session object, rather than making use of a global "current session". This makes things clearer if we allow the possibility of multiple non-HTTP sessions.

There is also a bit of cleanup in the way we pass other variables around, and in the capabilites processing.


Preview | Diff


Preview | Diff

index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved

<li><p>Let <var>body</var> be a JSON <a>Object</a> initialised with:

<dl>
<dt>"<code>sessionId</code>"
<dd><var>session id</var>
<dd><var>session</var>'s <a>session ID</a>.

<dt>"<code>capabilities</code>"
<dd><var>capabilities</var>
Copy link
Contributor

@whimboo whimboo Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be similar to session id?

Suggested change
<dd><var>capabilities</var>
<dd><var>session</var>'s <a>capabilities</a>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same <var>capabilities</var> as defined above, so I don't think this change is required.

index.html Outdated
<li><p><a>Set the current top-level browsing context</a>
for <var>session</var> with the <a>top-level browsing context</a>
<li><p>Set the <a>current top-level browsing context</a>
of <var>session</var> to the <a>top-level browsing context</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add: of the currently selected tab? Otherwise it would be unclear in case the browser starts up with multiple tabs already open.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part generally doesn't make sense, we can't set the current top level browsing context to the current browsing context, because that doesn't exist. Basically I think the UA is free to pick any borwsing context at this point, but I've tried to add some language suggesting it should pick a reasonable one.

index.html Outdated Show resolved Hide resolved
@whimboo
Copy link
Contributor

whimboo commented Oct 15, 2021

CC'ing @foolip and @bwalderman for their reviews. It would be great to get this PR landed.

shs96c
shs96c previously requested changes Mar 14, 2022
Copy link
Contributor

@shs96c shs96c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to be particularly careful to make sure that it's possible to reformulate this spec on top of Bidi, and I've called out a few places where I'm not sure that would be possible with this PR.

index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated
to their corresponding values.
<li><p>If <var>request match</var> is of type <a>error</a>,
<a>send an error</a> with <var>request match</var>’s <a>error code</a>
and continue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the intent here is that the returned error is forwarded to the local end? We should also ensure that error's data is also returned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An error doesn't have data, only a code. But the send an error steps allow the implementation to provide an arbitary message so the intent is really that we give the user some useful information, without wanting to specify exactly what that must be.

[some time later after reading the spec again]

Ah, I see there's an error data concept that is apparently exclusively used with unexpected alert open. Unfortunately it looks like that isn't hooked up to the error handling infrastructure at all corrrectly. I don't really want to further scope-creep this PR by also fixing that, but it could be fixed. Mind filing an issue?

index.html Outdated
<ol>
<li><p>Let <var>session id</var> be the corresponding variable
from <var>command parameters</var>.
<li><p>If <var>URL variables</var> has an item named session id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to indicate that "session id" is a variable name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a variable name though; it's the name of the field in a struct. In other specs it seems like the fields of the struct are individually defined, so that they can be linked on use. But since the fields of the struct in this case depend on which template variables were populated it seems harder to use that pattern. So I'm not realy sure what the cleanest way to mark this up is.

index.html Outdated
<a>send an error</a> with <a>error code</a> <a>invalid session id</a>,
then jump to step 1 in this overall algorithm.
<ol>
<li><p>Let <var>session id</var> be <var>URL variables</var>'s session id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated
amongst <a>all associated cookies</a>
of the <a>current browsing context</a>’s <a>active document</a>,
return <a>success</a> with the <a>serialized cookie</a> as data.
<li><p>If the <var>URL variables</var>' name is equal to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing s after the apostrophe

@jgraham
Copy link
Member Author

jgraham commented Mar 18, 2022

I've done a round of fixup here.

One thing that apparently isn't very obvious from the text is how I'm thinking about the session flags. The basic idea was to have a single kind of session object, but let it compose together the HTTP session and BiDi session properties, so that we can have all of the combinations HTTP-only, BiDi-only, HTTP+BiDi, and extend to anything new we want in the future. So the idea was that the flags are used to specify which kind of session a given session is, and knowing that you can tell what properties it must have e.g. if a session is a HTTP session it must have a timeouts property that you can access, but a BiDi session doesn't. The idea wasn't to group together all the boolean properties of a session into a single flags object.

index.html Show resolved Hide resolved
@jgraham jgraham requested a review from shs96c June 16, 2023 14:33
@whimboo
Copy link
Contributor

whimboo commented Jun 21, 2023

Hi @shs96c. Would you mind following up on some of the replies from @jgraham? Not sure if you think that those issues are still relevant or can be closed. It would be nice to eventually get this massive PR merged. Thanks.

@OrKoN
Copy link
Contributor

OrKoN commented Oct 10, 2023

it looks like there are no remaining unanswered questions and this PR needs a rebase?

@jgraham jgraham force-pushed the http_session branch 2 times, most recently from 7e9826c to 37d2eb9 Compare February 21, 2024 15:58
With BiDi we want to support multiple sessions, at most one of which
can also enable the HTTP frontend. Therefore we add the concept of
multiple sessions, which can have different flags set according to the
protocols they support (http, bidi, etc.).

This explictly passes the session, parameters and url variables down
into each command. In addition the URL variables are handled as a
infra struct rather than as a custom thing with implied variables.

Instead of having a concept of the "current session" we explicitly
pass the session around where required.
Copy link
Contributor

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (@sadym-chromium PTAL)

index.html Outdated Show resolved Hide resolved
Co-authored-by: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com>
@jgraham jgraham dismissed shs96c’s stale review February 26, 2024 16:14

Review is outdated now; going to land this to prevent further bitrot, but if there are remaining issues we can handle those in followups.

@jgraham jgraham merged commit 63a397f into master Feb 26, 2024
2 checks passed
@jgraham jgraham deleted the http_session branch February 26, 2024 16:14
github-actions bot added a commit that referenced this pull request Feb 26, 2024
SHA: 63a397f
Reason: push, by jgraham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to soloinovator/webdriver that referenced this pull request Feb 26, 2024
SHA: 63a397f
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to xjc90s/webdriver that referenced this pull request Feb 27, 2024
SHA: 63a397f
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants