diff --git a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json
index c93e1c722..3dc717be0 100644
--- a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json
+++ b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json
@@ -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] *",
diff --git a/lib/PuppeteerSharp.Tests/BrowserContextTests/DefaultBrowserContextTests.cs b/lib/PuppeteerSharp.Tests/BrowserContextTests/DefaultBrowserContextTests.cs
index 37893ad5d..bc09e5049 100644
--- a/lib/PuppeteerSharp.Tests/BrowserContextTests/DefaultBrowserContextTests.cs
+++ b/lib/PuppeteerSharp.Tests/BrowserContextTests/DefaultBrowserContextTests.cs
@@ -7,10 +7,6 @@ namespace PuppeteerSharp.Tests.BrowserContextTests
{
public class DefaultBrowserContextTests : PuppeteerPageBaseTest
{
- public DefaultBrowserContextTests() : base()
- {
- }
-
[SetUp]
public async Task CreateNewPageAsync()
{
diff --git a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs
index 35ffbab06..575dd43ed 100644
--- a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs
+++ b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs
@@ -58,6 +58,9 @@ private BidiBrowser(Core.Browser browserCore, LaunchOptions options, ILoggerFact
///
public override ITarget Target => _target;
+ ///
+ public override IBrowserContext DefaultContext => _browserContexts.FirstOrDefault(b => b.Id == BrowserCore.DefaultUserContext.Id);
+
internal static string[] SubscribeModules { get; } =
[
"browsingContext",
diff --git a/lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs b/lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs
index 67a78b7bc..c43f80ee1 100644
--- a/lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs
+++ b/lib/PuppeteerSharp/Bidi/BidiBrowserContext.cs
@@ -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;
}
diff --git a/lib/PuppeteerSharp/Bidi/Core/Browser.cs b/lib/PuppeteerSharp/Bidi/Core/Browser.cs
index 739cca12f..b5804353c 100644
--- a/lib/PuppeteerSharp/Bidi/Core/Browser.cs
+++ b/lib/PuppeteerSharp/Bidi/Core/Browser.cs
@@ -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;
@@ -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 UserContexts => _userContexts.Values;
public static async Task From(Session session)
diff --git a/lib/PuppeteerSharp/Bidi/Core/UserContext.cs b/lib/PuppeteerSharp/Bidi/Core/UserContext.cs
index 0debf81ad..5b553a368 100644
--- a/lib/PuppeteerSharp/Bidi/Core/UserContext.cs
+++ b/lib/PuppeteerSharp/Bidi/Core/UserContext.cs
@@ -30,6 +30,8 @@ namespace PuppeteerSharp.Bidi.Core;
internal class UserContext : IDisposable
{
+ public const string DEFAULT = "default";
+
private readonly ConcurrentDictionary _browsingContexts = new();
private string _reason;
diff --git a/lib/PuppeteerSharp/Browser.cs b/lib/PuppeteerSharp/Browser.cs
index 042679124..c91f87471 100644
--- a/lib/PuppeteerSharp/Browser.cs
+++ b/lib/PuppeteerSharp/Browser.cs
@@ -47,7 +47,7 @@ public abstract class Browser : IBrowser
public abstract bool IsClosed { get; }
///
- public IBrowserContext DefaultContext { get; protected set; }
+ public virtual IBrowserContext DefaultContext { get; protected set; }
///
public int DefaultWaitForTimeout { get; set; } = Puppeteer.DefaultTimeout;