From a8412a1e2d933527cc2687b28c467b6f8f80d91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Sat, 28 Mar 2026 15:20:05 -0300 Subject: [PATCH] Fix frame-hierarchy headful test failures by matching upstream behavior Two root causes fixed: 1. ShouldReportDifferentFrameInstanceWhenFrameReAttaches waited for FrameNavigated instead of FrameAttached (matching upstream), causing timeouts in headful mode where event timing differs. 2. DumpFrames did not sort child frames by URL then name, unlike upstream, leading to non-deterministic ordering in ShouldHandleNestedFrames. Added missing PageEvent.FrameAttached to enable WaitForEventAsync usage. Removed the [frame-hierarchy.spec.ts] expected-failure entry. Closes #122 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../TestExpectations/TestExpectations.local.json | 6 ------ src/PlaywrightSharp.Tests/FrameHierarchyTests.cs | 2 +- src/PlaywrightSharp.Tests/FrameUtils.cs | 7 ++++++- src/PlaywrightSharp/PageEvent.cs | 5 +++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json index 42a60d767a..5707275508 100644 --- a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -215,12 +215,6 @@ "parameters": ["headful"], "expectations": ["FAIL"] }, - { - "testIdPattern": "[frame-hierarchy.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["headful"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[page-check.spec.ts] *", "platforms": ["darwin", "linux", "win32"], diff --git a/src/PlaywrightSharp.Tests/FrameHierarchyTests.cs b/src/PlaywrightSharp.Tests/FrameHierarchyTests.cs index 2209e5ada2..831ef8157e 100644 --- a/src/PlaywrightSharp.Tests/FrameHierarchyTests.cs +++ b/src/PlaywrightSharp.Tests/FrameHierarchyTests.cs @@ -185,7 +185,7 @@ await Page.EvaluateAsync(@"() => { Assert.That(frame1.IsDetached, Is.True); var (frame2, _) = await TaskUtils.WhenAll( - Page.WaitForEventAsync(PageEvent.FrameNavigated), + Page.WaitForEventAsync(PageEvent.FrameAttached), Page.EvaluateAsync("() => document.body.appendChild(window.frame)") ); diff --git a/src/PlaywrightSharp.Tests/FrameUtils.cs b/src/PlaywrightSharp.Tests/FrameUtils.cs index 7921188f11..1982676e4c 100644 --- a/src/PlaywrightSharp.Tests/FrameUtils.cs +++ b/src/PlaywrightSharp.Tests/FrameUtils.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -35,7 +37,10 @@ public static IEnumerable DumpFrames(IFrame frame, string indentation = description += $" ({frame.Name})"; } var result = new List() { description }; - foreach (var child in frame.ChildFrames) + var childFrames = frame.ChildFrames.OrderBy(f => f.Url, StringComparer.Ordinal) + .ThenBy(f => f.Name, StringComparer.Ordinal) + .ToList(); + foreach (var child in childFrames) { result.AddRange(DumpFrames(child, " " + indentation)); } diff --git a/src/PlaywrightSharp/PageEvent.cs b/src/PlaywrightSharp/PageEvent.cs index 97eefdf0c6..a8cd28e322 100644 --- a/src/PlaywrightSharp/PageEvent.cs +++ b/src/PlaywrightSharp/PageEvent.cs @@ -48,6 +48,11 @@ public static class PageEvent /// public static PlaywrightEvent Popup { get; } = new PlaywrightEvent() { Name = "Popup" }; + /// + /// representing a . + /// + public static PlaywrightEvent