From 21bcd78659bdf9b99e7a37991426afa3ba8d5955 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 23 Sep 2026 13:21:36 +0000 Subject: [PATCH 1/4] Fix: return shadow host for text node in shadow root in SerializedAXNode.ElementHandle (#15451) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a StaticText AX node sits directly in a shadow root, parentElement is null. Fall back to the shadow host so ElementHandleAsync returns a usable ElementHandle instead of a null-wrapped JSHandle. Co-authored-by: Darío Kondratiuk --- .../AccessibilityTests/RootOptionTests.cs | 27 +++++++++++++++++++ .../PageAccessibility/AXNode.cs | 10 +++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/PuppeteerSharp.Tests/AccessibilityTests/RootOptionTests.cs b/lib/PuppeteerSharp.Tests/AccessibilityTests/RootOptionTests.cs index a68dc220f..d9d5f5808 100644 --- a/lib/PuppeteerSharp.Tests/AccessibilityTests/RootOptionTests.cs +++ b/lib/PuppeteerSharp.Tests/AccessibilityTests/RootOptionTests.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Threading.Tasks; using NUnit.Framework; using PuppeteerSharp.Nunit; @@ -172,6 +173,32 @@ public async Task ShouldGetTheParentElementHandleFromATextNodeAccessibilityNode( Assert.That(textNodeInnerHtml, Is.EqualTo("Hello, world!")); } + [Test, PuppeteerTest("accessibility.spec", "elementHandle()", "should get the shadow host ElementHandle from a text node in a shadow root")] + public async Task ShouldGetTheShadowHostElementHandleFromATextNodeInAShadowRoot() + { + await Page.SetContentAsync("
"); + await Page.EvaluateExpressionAsync(@" + document + .querySelector('#host') + .attachShadow({mode: 'open'}).textContent = 'Shadow text'; + "); + var host = await Page.QuerySelectorAsync("#host"); + + var snapshot = await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions + { + Root = host, + InterestingOnly = false, + }); + var textNode = snapshot.Children.First(child => child.Name == "Shadow text"); + Assert.That(textNode.Role, Is.EqualTo("StaticText")); + + var textNodeHandle = await textNode.ElementHandleAsync(); + Assert.That(textNodeHandle, Is.Not.Null); + Assert.That( + await textNodeHandle.EvaluateFunctionAsync("element => element.id"), + Is.EqualTo("host")); + } + [Test, PuppeteerTest("accessibility.spec", "root option", "should work with nested button inside h1 with interestingOnly:true")] public async Task ShouldWorkWithNestedButtonInsideH1WithInterestingOnlyTrue() { diff --git a/lib/PuppeteerSharp/PageAccessibility/AXNode.cs b/lib/PuppeteerSharp/PageAccessibility/AXNode.cs index 1403ca31d..ada1bf809 100644 --- a/lib/PuppeteerSharp/PageAccessibility/AXNode.cs +++ b/lib/PuppeteerSharp/PageAccessibility/AXNode.cs @@ -270,8 +270,14 @@ internal SerializedAXNode Serialize() // Since Text nodes are not elements, we want to // return a handle to the parent element for them. - return await ((ElementHandle)handle).EvaluateFunctionHandleAsync( - "node => node.nodeType === Node.TEXT_NODE ? node.parentElement : node").ConfigureAwait(false) as IElementHandle; + // A text node placed directly in a shadow root has no parent + // element, so fall back to the shadow host. + return await ((ElementHandle)handle).EvaluateFunctionHandleAsync(@"node => { + if (node.nodeType !== Node.TEXT_NODE) { + return node; + } + return node.parentElement ?? node.parentNode?.host ?? null; + }").ConfigureAwait(false) as IElementHandle; } : null, Role = _role, From 088dbbf36f402d2672090f1c7509002375541ba4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 23 Sep 2026 23:04:32 +0000 Subject: [PATCH 2/4] ci: retrigger after ShouldKeepConnectedAfterTheLastPageIsClosed flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Darío Kondratiuk From 727ca3b4445b81d47a1b4137fa2b18ea01864c3f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 23 Sep 2026 23:25:09 +0000 Subject: [PATCH 3/4] ci: requeue stuck build workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Darío Kondratiuk From d7033ef976d656918e199cf8a25290554d6c6c4a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 23 Sep 2026 23:41:28 +0000 Subject: [PATCH 4/4] ci: requeue stuck matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Darío Kondratiuk