Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,6 @@
"FAIL"
]
},
{
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
"testIdPattern": "[defaultbrowsercontext.spec] *",
"platforms": [
"darwin",
"linux",
"win32"
],
"parameters": [
"webDriverBiDi"
],
"expectations": [
"FAIL"
]
},
{
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
"testIdPattern": "[browsercontext.spec] *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ namespace PuppeteerSharp.Tests.BrowserContextTests
{
public class DefaultBrowserContextTests : PuppeteerPageBaseTest
{
public DefaultBrowserContextTests() : base()
{
}

[SetUp]
public async Task CreateNewPageAsync()
{
Expand Down
3 changes: 3 additions & 0 deletions lib/PuppeteerSharp/Bidi/BidiBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private BidiBrowser(Core.Browser browserCore, LaunchOptions options, ILoggerFact
/// <inheritdoc />
public override ITarget Target => _target;

/// <inheritdoc/>
public override IBrowserContext DefaultContext => _browserContexts.FirstOrDefault(b => b.Id == BrowserCore.DefaultUserContext.Id);

internal static string[] SubscribeModules { get; } =
[
"browsingContext",
Expand Down
5 changes: 4 additions & 1 deletion lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ internal static BidiBrowserContext From(
UserContext userContext,
BidiBrowserContextOptions options)
{
var context = new BidiBrowserContext(browser, userContext, options);
var context = new BidiBrowserContext(browser, userContext, options)
{
Id = userContext.Id,
};
context.Initialize();
return context;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/PuppeteerSharp/Bidi/Core/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using PuppeteerSharp.Helpers;
using WebDriverBiDi.Browser;
Expand All @@ -49,6 +50,8 @@ internal sealed class Browser(Session session) : IDisposable

public string Reason { get; set; }

internal UserContext DefaultUserContext => _userContexts.TryGetValue(UserContext.DEFAULT, out var context) ? context : _userContexts.Values.FirstOrDefault();

internal ICollection<UserContext> UserContexts => _userContexts.Values;

public static async Task<Browser> From(Session session)
Expand Down
2 changes: 2 additions & 0 deletions lib/PuppeteerSharp/Bidi/Core/UserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace PuppeteerSharp.Bidi.Core;

internal class UserContext : IDisposable
{
public const string DEFAULT = "default";

private readonly ConcurrentDictionary<string, BrowsingContext> _browsingContexts = new();
private string _reason;

Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class Browser : IBrowser
public abstract bool IsClosed { get; }

/// <inheritdoc/>
public IBrowserContext DefaultContext { get; protected set; }
public virtual IBrowserContext DefaultContext { get; protected set; }

/// <inheritdoc/>
public int DefaultWaitForTimeout { get; set; } = Puppeteer.DefaultTimeout;
Expand Down
Loading