-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[🚀 Feature]: [dotnet] Provide a possibility to implement BiDi Permissions module #15329
Comments
@nvborisenko, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
I am thinking more about it and coming to a conclusion that "reusing" existing BiDi connection is "not possible". So, I think the following will be more appreciated: var bidi = await driver.AsBiDiAsync(); // W3C WebDriver implementation
var permissions = await driver.AsBiDiPermissionsAsync(); // It initializes new Broker/WebSocketConnection/JsonContext Then each I think this is a good solution. But semantic of this solution is not related to extensibility. |
And I am entirely OK with it! Appium is a separate topic, but seems yes, we consider Appium as yet another BiDi module (with his own isolated "context"). |
var bidi = await driver.AsBiDiAsync(opts => opts.WithPermissions(out var permissions));
await permissions.QueryAsync(); This way we inject JsonTypeInfoResolver, reusing entire core bidi infrastructure, and expose Researching continued. @RenderMichael what do you think? |
I think the configuration builder would work well, the main drawback is that it requires all of BiDi for an extension. If we want to have Permissions separate from BiDi, then we would need a separate flow. |
Trying to evaluate the statement "JsonOptions is immutable" and understood it is actually mutable. It is safe to inject Pseudo flow: var bidi = driver.GetBidi(); // existing functionality
var permissionsModule = bidi.AsPermissions(); // here it is safe to modify JsonOptions!
var bluetoothModule = bidi.AsBluetooth(); // even safe, just adds one more TypeInfoResolver I hope it will be useful. |
We can improve it even more with the |
Yes, kind of "inject TypeInfoResolver". I am more curios it helps us in general. From end user point of view this is absolutely legal operation. |
What do we think about a builder pattern: var bidi = await driver.AsBiDiBuilder()
.AddExtension(connection => new PermissionsModule(connection), out var permissions)
.BuildAsync(); Extension creator can provide nice extensions on public static BiDiBuilder AddPermissions(this BiDiBuilder builder, out PermissionsModule permissions)
{
return builder.AddExtension(connection =>
{
connection.AddSerializerContextAndConverters(PermissionsJsonSerializerContext.Default)
return new PermissionsModule(connection);
},
out permissions);
} var bidi = await driver.AsBiDiBuilder()
.AddPermissions(out var permissions)
.BuildAsync(); |
With the above pattern, we can do things like make the |
Usually builder pattern lives on top of existing functionality. I am still thinking the following is our primary way: var permissionsModule = bidi.AsPermissions(); But I understand selenium should expose "something" to be public. If my thoughts are true, then I just want to make this "something" hidden from regular users. When our users type |
One more point against pre-initialized pattern (builder): user should capture the reference to it even if he doesn't want it. Or if he wants it, he should keep this ref during application lifecycle. The following is still better: var permissionsModule = bidi.AsPermissions(); // here permissions module starts to live, pretty intuitive And now we also should remember about disposing permissions module, just removing |
Thinking more... "hidden something" could be |
If we want to create extension modules on the fly instead of at the same time as the bidi object lifecycle, then we cannot share a connection. We can do it that way too. |
Feature and motivation
https://www.w3.org/TR/permissions/
The implementation should not rely on
internal
members. The goal is to expose minimal required to make it possible to implement new extendable by the third-partied modules.Usage example
The text was updated successfully, but these errors were encountered: