Skip to content

Commit

Permalink
chore: various channel follow-ups (#2796)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Dec 11, 2023
1 parent 71f74af commit dece69a
Show file tree
Hide file tree
Showing 45 changed files with 136 additions and 209 deletions.
5 changes: 2 additions & 3 deletions src/Playwright/Core/APIRequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@

namespace Microsoft.Playwright.Core;

internal class APIRequestContext : ChannelOwnerBase, IAPIRequestContext
internal class APIRequestContext : ChannelOwner, IAPIRequestContext
{
internal readonly Tracing _tracing;

internal APIRequest _request;

public APIRequestContext(ChannelOwnerBase parent, string guid, APIRequestContextInitializer initializer) : base(parent, guid)
public APIRequestContext(ChannelOwner parent, string guid, APIRequestContextInitializer initializer) : base(parent, guid)
{
_tracing = initializer.Tracing;
}
Expand Down Expand Up @@ -161,7 +161,6 @@ private bool IsJsonParsable(string dataString)
}
}


[MethodImpl(MethodImplOptions.NoInlining)]
public Task<IAPIResponse> DeleteAsync(string url, APIRequestContextOptions options = null) => FetchAsync(url, WithMethod(options, "DELETE"));

Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/AndroidDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

namespace Microsoft.Playwright.Core;

internal class AndroidDevice : ChannelOwnerBase
internal class AndroidDevice : ChannelOwner
{
internal AndroidDevice(ChannelOwnerBase parent, string guid, BrowserInitializer initializer) : base(parent, guid)
internal AndroidDevice(ChannelOwner parent, string guid, BrowserInitializer initializer) : base(parent, guid)
{
}
}
4 changes: 2 additions & 2 deletions src/Playwright/Core/Artifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

namespace Microsoft.Playwright.Core;

internal class Artifact : ChannelOwnerBase
internal class Artifact : ChannelOwner
{
internal Artifact(ChannelOwnerBase parent, string guid, ArtifactInitializer initializer) : base(parent, guid)
internal Artifact(ChannelOwner parent, string guid, ArtifactInitializer initializer) : base(parent, guid)
{
AbsolutePath = initializer.AbsolutePath;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Playwright/Core/AssertionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ public AssertionsBase(ILocator actual, bool isNot)
IsNot = isNot;
}

protected bool IsNot { get; private set; }
protected bool IsNot { get; }

internal Locator ActualLocator { get; private set; }
protected Locator ActualLocator { get; }

internal async Task ExpectImplAsync(string expression, ExpectedTextValue textValue, object expected, string message, FrameExpectOptions options)
protected async Task ExpectImplAsync(string expression, ExpectedTextValue textValue, object expected, string message, FrameExpectOptions options)
{
await ExpectImplAsync(expression, new ExpectedTextValue[] { textValue }, expected, message, options).ConfigureAwait(false);
}

internal async Task ExpectImplAsync(string expression, ExpectedTextValue[] expectedText, object expected, string message, FrameExpectOptions options)
protected async Task ExpectImplAsync(string expression, ExpectedTextValue[] expectedText, object expected, string message, FrameExpectOptions options)
{
options = options ?? new();
options ??= new();
options.ExpectedText = expectedText;
options.IsNot = IsNot;
await ExpectImplAsync(expression, options, expected, message).ConfigureAwait(false);
}

internal async Task ExpectImplAsync(string expression, FrameExpectOptions expectOptions, object expected, string message)
protected async Task ExpectImplAsync(string expression, FrameExpectOptions expectOptions, object expected, string message)
{
if (expectOptions.Timeout == null)
{
Expand All @@ -87,7 +87,7 @@ internal async Task ExpectImplAsync(string expression, FrameExpectOptions expect
}
}

internal ExpectedTextValue ExpectedRegex(Regex pattern, ExpectedTextValue options = null)
protected ExpectedTextValue ExpectedRegex(Regex pattern, ExpectedTextValue options = null)
{
if (pattern == null)
{
Expand All @@ -100,7 +100,7 @@ internal ExpectedTextValue ExpectedRegex(Regex pattern, ExpectedTextValue option
return textValue;
}

internal FrameExpectOptions ConvertToFrameExpectOptions(object source) => ClassUtils.Clone<FrameExpectOptions>(source);
protected FrameExpectOptions ConvertToFrameExpectOptions(object source) => ClassUtils.Clone<FrameExpectOptions>(source);

private string FormatValue(object value)
{
Expand All @@ -122,6 +122,6 @@ private string FormatValue(object value)
return value.ToString();
}

internal static void SetDefaultTimeout(float timeout)
public static void SetDefaultTimeout(float timeout)
=> _defaultTimeout = timeout;
}
4 changes: 2 additions & 2 deletions src/Playwright/Core/BindingCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

namespace Microsoft.Playwright.Core;

internal class BindingCall : ChannelOwnerBase
internal class BindingCall : ChannelOwner
{
private static readonly Type VoidTaskResultType = Type.GetType("System.Threading.Tasks.VoidTaskResult");

private readonly BindingCallInitializer _initializer;

public BindingCall(ChannelOwnerBase parent, string guid, BindingCallInitializer initializer) : base(parent, guid)
public BindingCall(ChannelOwner parent, string guid, BindingCallInitializer initializer) : base(parent, guid)
{
_initializer = initializer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

namespace Microsoft.Playwright.Core;

internal class Browser : ChannelOwnerBase, IBrowser
internal class Browser : ChannelOwner, IBrowser
{
private readonly BrowserInitializer _initializer;
private readonly TaskCompletionSource<bool> _closedTcs = new();
internal readonly List<BrowserContext> _contexts = new();
internal BrowserType _browserType;
internal string _closeReason;

internal Browser(ChannelOwnerBase parent, string guid, BrowserInitializer initializer) : base(parent, guid)
internal Browser(ChannelOwner parent, string guid, BrowserInitializer initializer) : base(parent, guid)
{
IsConnected = true;
_initializer = initializer;
Expand Down
6 changes: 3 additions & 3 deletions src/Playwright/Core/BrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@

namespace Microsoft.Playwright.Core;

internal class BrowserContext : ChannelOwnerBase, IBrowserContext
internal class BrowserContext : ChannelOwner, IBrowserContext
{
private readonly TaskCompletionSource<bool> _closeTcs = new();
private readonly Dictionary<string, Delegate> _bindings = new();
private readonly BrowserContextInitializer _initializer;
internal readonly Tracing _tracing;
private readonly Tracing _tracing;
internal readonly IAPIRequestContext _request;
private readonly IDictionary<string, HarRecorder> _harRecorders = new Dictionary<string, HarRecorder>();
internal readonly List<IWorker> _serviceWorkers = new();
Expand All @@ -55,7 +55,7 @@ internal class BrowserContext : ChannelOwnerBase, IBrowserContext

internal TimeoutSettings _timeoutSettings = new();

internal BrowserContext(ChannelOwnerBase parent, string guid, BrowserContextInitializer initializer) : base(parent, guid)
internal BrowserContext(ChannelOwner parent, string guid, BrowserContextInitializer initializer) : base(parent, guid)
{
_browser = parent as Browser;
_browser?._contexts.Add(this);
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/BrowserType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@

namespace Microsoft.Playwright.Core;

internal class BrowserType : ChannelOwnerBase, IBrowserType
internal class BrowserType : ChannelOwner, IBrowserType
{
private readonly BrowserTypeInitializer _initializer;

internal BrowserType(ChannelOwnerBase parent, string guid, BrowserTypeInitializer initializer) : base(parent, guid)
internal BrowserType(ChannelOwner parent, string guid, BrowserTypeInitializer initializer) : base(parent, guid)
{
_initializer = initializer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/CDPSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

namespace Microsoft.Playwright.Core;

internal class CDPSession : ChannelOwnerBase, ICDPSession
internal class CDPSession : ChannelOwner, ICDPSession
{
private readonly Dictionary<string, CDPSessionEvent> _cdpSessionEvents = new();

public CDPSession(ChannelOwnerBase parent, string guid) : base(parent, guid)
public CDPSession(ChannelOwner parent, string guid) : base(parent, guid)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

namespace Microsoft.Playwright.Core;

internal class Dialog : ChannelOwnerBase, IDialog
internal class Dialog : ChannelOwner, IDialog
{
private readonly DialogInitializer _initializer;

public Dialog(ChannelOwnerBase parent, string guid, DialogInitializer initializer) : base(parent, guid)
public Dialog(ChannelOwner parent, string guid, DialogInitializer initializer) : base(parent, guid)
{
_initializer = initializer;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Playwright/Core/ElementHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ namespace Microsoft.Playwright.Core;

internal class ElementHandle : JSHandle, IElementHandle
{

internal ElementHandle(ChannelOwnerBase parent, string guid, ElementHandleInitializer initializer) : base(parent, guid, initializer)
internal ElementHandle(ChannelOwner parent, string guid, ElementHandleInitializer initializer) : base(parent, guid, initializer)
{
}

Expand Down
30 changes: 0 additions & 30 deletions src/Playwright/Core/EvaluateArgumentGuidElement.cs

This file was deleted.

21 changes: 18 additions & 3 deletions src/Playwright/Core/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@

namespace Microsoft.Playwright.Core;

internal class Frame : ChannelOwnerBase, IFrame
internal class Frame : ChannelOwner, IFrame
{
private readonly List<WaitUntilState> _loadStates = new();
internal readonly List<Frame> _childFrames = new();

internal Frame(ChannelOwnerBase parent, string guid, FrameInitializer initializer) : base(parent, guid)
internal Frame(ChannelOwner parent, string guid, FrameInitializer initializer) : base(parent, guid)
{
Url = initializer.Url;
Name = initializer.Name;
Expand Down Expand Up @@ -1044,7 +1044,6 @@ public ILocator GetByTitle(Regex text, FrameGetByTitleOptions options = null)

internal class SelectOptionValueProtocol
{

#nullable enable
[JsonPropertyName("value")]
public string? Value { get; set; }
Expand All @@ -1069,3 +1068,19 @@ internal static SelectOptionValueProtocol From(SelectOptionValue value)
};
}
}

internal class FrameNavigatedEventArgs
{
public string Name { get; set; }

public string Url { get; set; }

public string Error { get; set; }

internal NavigateDocument NewDocument { get; set; }
}

internal class NavigateDocument
{
public Request Request { get; set; }
}
41 changes: 0 additions & 41 deletions src/Playwright/Core/FrameNavigatedEventArgs.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Playwright/Core/HarRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace Microsoft.Playwright.Core;

internal class HarRouter
internal sealed class HarRouter
{
private readonly LocalUtils _localUtils;

Expand Down
6 changes: 3 additions & 3 deletions src/Playwright/Core/JSHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

namespace Microsoft.Playwright.Core;

internal class JSHandle : ChannelOwnerBase, IJSHandle
internal class JSHandle : ChannelOwner, IJSHandle
{
internal JSHandle(ChannelOwnerBase parent, string guid, JSHandleInitializer initializer) : base(parent, guid)
internal JSHandle(ChannelOwner parent, string guid, JSHandleInitializer initializer) : base(parent, guid)
{
Preview = initializer.Preview;
}

internal string Preview { get; set; }
protected string Preview { get; set; }

[MethodImpl(MethodImplOptions.NoInlining)]
public IElementHandle AsElement() => this as IElementHandle;
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/JsonPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

namespace Microsoft.Playwright.Core;

internal class JsonPipe : ChannelOwnerBase
internal class JsonPipe : ChannelOwner
{
private readonly JsonPipeInitializer _initializer;

public JsonPipe(ChannelOwnerBase parent, string guid, JsonPipeInitializer initializer) : base(parent, guid)
public JsonPipe(ChannelOwner parent, string guid, JsonPipeInitializer initializer) : base(parent, guid)
{
_initializer = initializer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/LocalUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

namespace Microsoft.Playwright.Core;

internal class LocalUtils : ChannelOwnerBase
internal class LocalUtils : ChannelOwner
{
internal readonly Dictionary<string, BrowserNewContextOptions> _devices = new();

public LocalUtils(ChannelOwnerBase parent, string guid, LocalUtilsInitializer initializer) : base(parent, guid)
public LocalUtils(ChannelOwner parent, string guid, LocalUtilsInitializer initializer) : base(parent, guid)
{
foreach (var entry in initializer.DeviceDescriptors)
{
Expand Down
Loading

0 comments on commit dece69a

Please sign in to comment.