Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions dotnet/src/webdriver/BiDi/Communication/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,27 +275,7 @@ public async Task UnsubscribeAsync(Session.Subscription subscription, EventHandl

eventHandlers.Remove(eventHandler);

if (subscription is not null)
{
await _bidi.SessionModule.UnsubscribeAsync([subscription]).ConfigureAwait(false);
}
else
{
if (eventHandler.Contexts is not null)
{
if (!eventHandlers.Any(h => eventHandler.Contexts.Equals(h.Contexts)) && !eventHandlers.Any(h => h.Contexts is null))
{
await _bidi.SessionModule.UnsubscribeAsync([eventHandler.EventName], new() { Contexts = eventHandler.Contexts }).ConfigureAwait(false);
}
}
else
{
if (!eventHandlers.Any(h => h.Contexts is not null) && !eventHandlers.Any(h => h.Contexts is null))
{
await _bidi.SessionModule.UnsubscribeAsync([eventHandler.EventName]).ConfigureAwait(false);
}
}
}
await _bidi.SessionModule.UnsubscribeAsync([subscription]).ConfigureAwait(false);
}

public async ValueTask DisposeAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
[JsonSerializable(typeof(Session.SubscribeCommand))]
[JsonSerializable(typeof(Session.SubscribeResult))]
[JsonSerializable(typeof(Session.UnsubscribeByIdCommand))]
[JsonSerializable(typeof(Session.UnsubscribeByAttributesCommand))]

[JsonSerializable(typeof(Browser.CloseCommand), TypeInfoPropertyName = "Browser_CloseCommand")]
[JsonSerializable(typeof(Browser.CreateUserContextCommand))]
Expand Down
7 changes: 0 additions & 7 deletions dotnet/src/webdriver/BiDi/Session/SessionModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ public async Task<EmptyResult> UnsubscribeAsync(IEnumerable<Subscription> subscr
return await Broker.ExecuteCommandAsync<UnsubscribeByIdCommand, EmptyResult>(new UnsubscribeByIdCommand(@params), options).ConfigureAwait(false);
}

public async Task<EmptyResult> UnsubscribeAsync(IEnumerable<string> eventNames, UnsubscribeByAttributesOptions? options = null)
{
var @params = new UnsubscribeByAttributesParameters(eventNames, options?.Contexts);

return await Broker.ExecuteCommandAsync<UnsubscribeByAttributesCommand, EmptyResult>(new UnsubscribeByAttributesCommand(@params), options).ConfigureAwait(false);
}

public async Task<NewResult> NewAsync(CapabilitiesRequest capabilitiesRequest, NewOptions? options = null)
{
var @params = new NewParameters(capabilitiesRequest);
Expand Down
15 changes: 0 additions & 15 deletions dotnet/src/webdriver/BiDi/Session/UnsubscribeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Session;

internal sealed class UnsubscribeByIdCommand(UnsubscribeByIdParameters @params)
: Command<UnsubscribeByIdParameters, EmptyResult>(@params, "session.unsubscribe");

internal sealed class UnsubscribeByAttributesCommand(UnsubscribeByAttributesParameters @params)
: Command<UnsubscribeByAttributesParameters, EmptyResult>(@params, "session.unsubscribe");

internal sealed record UnsubscribeByIdParameters(IEnumerable<Subscription> Subscriptions) : Parameters;

public sealed class UnsubscribeByIdOptions : CommandOptions;

internal sealed record UnsubscribeByAttributesParameters(
IEnumerable<string> Events,
[property: Obsolete("Contexts param is deprecated and will be removed in the future versions")]
// https://w3c.github.io/webdriver-bidi/#type-session-UnsubscribeByAttributesRequest
IEnumerable<BrowsingContext.BrowsingContext>? Contexts) : Parameters;

public sealed class UnsubscribeByAttributesOptions : CommandOptions
{
public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; set; }
}
Loading