diff --git a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json index f851b5220..5d2a19c36 100644 --- a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -893,21 +893,6 @@ "FAIL" ] }, - { - "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", - "testIdPattern": "[page.spec] *Page.close*", - "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": "[page.spec] *Page.exposeFunction*", diff --git a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs index bc01d6ea1..275841903 100644 --- a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs +++ b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs @@ -102,7 +102,11 @@ private BidiBrowser(Core.Browser browserCore, LaunchOptions options, ILoggerFact public override Task GetUserAgentAsync() => Task.FromResult(BrowserCore.Session.Info.Capabilities.UserAgent); /// - public override void Disconnect() => throw new NotImplementedException(); + public override void Disconnect() + { + Driver.StopAsync().GetAwaiter().GetResult(); + Detach(); + } /// public override async Task CloseAsync() @@ -187,6 +191,15 @@ private void InitializeAsync() } } + private void Detach() + { + foreach (var context in _browserContexts) + { + context.TargetCreated -= (sender, args) => OnTargetCreated(args); + context.TargetDestroyed -= (sender, args) => OnTargetDestroyed(args); + } + } + private BidiBrowserContext CreateBrowserContext(UserContext userContext) { var browserContext = BidiBrowserContext.From(