From 24e6f40bfbfec89b2d3bc22c26633eba980828ad Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 17 Apr 2024 11:38:23 +0200 Subject: [PATCH 1/2] fix(cdpSession): events without payload --- src/Playwright/Core/CDPSession.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Playwright/Core/CDPSession.cs b/src/Playwright/Core/CDPSession.cs index 0e2de9dbb4..3143b7edad 100644 --- a/src/Playwright/Core/CDPSession.cs +++ b/src/Playwright/Core/CDPSession.cs @@ -45,7 +45,8 @@ internal override void OnMessage(string method, JsonElement? serverParams) switch (method) { case "event": - OnCDPEvent(serverParams!.Value.GetProperty("method").ToString(), serverParams.Value.GetProperty("params")); + serverParams!.Value.TryGetProperty("params", out var cdpParams); + OnCDPEvent(serverParams!.Value.GetProperty("method").ToString(), cdpParams); break; } } From 55b01ca26f0a48e4ce3c39197d23939d96de34e0 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 17 Apr 2024 16:31:01 +0200 Subject: [PATCH 2/2] nit --- src/Playwright/Core/CDPSession.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Playwright/Core/CDPSession.cs b/src/Playwright/Core/CDPSession.cs index 3143b7edad..87c505a07f 100644 --- a/src/Playwright/Core/CDPSession.cs +++ b/src/Playwright/Core/CDPSession.cs @@ -45,8 +45,9 @@ internal override void OnMessage(string method, JsonElement? serverParams) switch (method) { case "event": - serverParams!.Value.TryGetProperty("params", out var cdpParams); - OnCDPEvent(serverParams!.Value.GetProperty("method").ToString(), cdpParams); + OnCDPEvent( + serverParams!.Value.GetProperty("method").ToString(), + serverParams!.Value.TryGetProperty("params", out var cdpParams) ? cdpParams : null); break; } }