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 @@ -975,21 +975,6 @@
"FAIL"
]
},
{
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
"testIdPattern": "[page.spec] *Page.Events.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.Events.Console*",
Expand Down
4 changes: 4 additions & 0 deletions lib/PuppeteerSharp/Bidi/BidiPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,5 +547,9 @@ private async Task<IResponse> GoAsync(int delta, NavigationOptions options)

private void Initialize()
{
BidiMainFrame.BrowsingContext.Closed += (_, _) =>
{
OnClose();
};
}
}
11 changes: 9 additions & 2 deletions lib/PuppeteerSharp/Bidi/Core/BrowsingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private BrowsingContext(UserContext userContext, BrowsingContext parent, string

public string Url { get; private set; }

public bool IsClosed => _reason != null;
public bool IsClosed { get; private set; }

public Session Session => UserContext.Browser.Session;

Expand Down Expand Up @@ -107,6 +107,13 @@ public static BrowsingContext From(UserContext userContext, BrowsingContext pare

public void Dispose()
{
if (IsClosed)
{
return;
}

IsClosed = true;

_reason ??= "Browser was disconnected, probably because the session ended.";
OnClosed(_reason);
foreach (var context in _children.Values)
Expand Down Expand Up @@ -223,7 +230,7 @@ private void Initialize()

Session.BrowsingContextContextDestroyed += (_, args) =>
{
if (args.UserContextId != Id)
if (args.BrowsingContextId != Id)
{
return;
}
Expand Down
Loading