Skip to content

Commit d628276

Browse files
committed
Some fixes
1 parent 6cb6f28 commit d628276

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/PuppeteerSharp/Bidi/Core/BrowsingContext.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ private BrowsingContext(UserContext userContext, BrowsingContext parent, string
6565

6666
public event EventHandler<UserPromptEventArgs> UserPrompt;
6767

68+
public event EventHandler<WebDriverBiDi.Log.EntryAddedEventArgs> Log;
69+
6870
public UserContext UserContext { get; }
6971

7072
public string Id { get; }
7173

7274
public string Url { get; private set; }
7375

74-
public bool IsClosed => _reason != null;
76+
public bool IsClosed { get; private set; }
7577

7678
public Session Session => UserContext.Browser.Session;
7779

@@ -107,6 +109,13 @@ public static BrowsingContext From(UserContext userContext, BrowsingContext pare
107109

108110
public void Dispose()
109111
{
112+
if (IsClosed)
113+
{
114+
return;
115+
}
116+
117+
IsClosed = true;
118+
110119
_reason ??= "Browser was disconnected, probably because the session ended.";
111120
OnClosed(_reason);
112121
foreach (var context in _children.Values)
@@ -223,7 +232,7 @@ private void Initialize()
223232

224233
Session.BrowsingContextContextDestroyed += (_, args) =>
225234
{
226-
if (args.UserContextId != Id)
235+
if (args.BrowsingContextId != Id)
227236
{
228237
return;
229238
}

0 commit comments

Comments
 (0)