diff --git a/tests/E2E.Agent.Tests/PlaywrightRoutes.cs b/tests/E2E.Agent.Tests/PlaywrightRoutes.cs
index 344f39e90..3cf9a77bf 100644
--- a/tests/E2E.Agent.Tests/PlaywrightRoutes.cs
+++ b/tests/E2E.Agent.Tests/PlaywrightRoutes.cs
@@ -14,11 +14,14 @@ namespace E2E.Playground;
/// The routes of the tests ported from Playwright, a port of upstream's apps/testbed/app/playwright/routes.mjs:
/// its test assets (copied from microsoft/playwright tests/assets at v1.64.1, Apache-2.0, under
/// Testbed/playwright/assets next to the test assembly) and the dynamic routes its test server sets per test.
-/// The playground serves them for any path it has no page for. This port has /content and the assets so far.
+/// The playground serves them for any path it has no page for. This port has /content, /never and the assets so far.
///
internal static class PlaywrightRoutes
{
- private static readonly string Root = Path.Combine(AppContext.BaseDirectory, "Testbed", "playwright", "assets");
+ private static readonly string Root = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "Testbed", "playwright", "assets"));
+
+ /// Cancelled when the process exits, which releases the requests a route holds.
+ private static readonly CancellationTokenSource Shutdown = CreateShutdown();
private static readonly Dictionary Types = new(StringComparer.Ordinal)
{
@@ -45,6 +48,23 @@ public static async Task HandleAsync(HttpListenerContext context)
return;
}
+ if (path == "/never")
+ {
+ // Holds the response and never answers, as upstream's /never. It ends when the run ends (the testbed never stops before that)
+ // or after upstream's longest delay, so a held request cannot outlive the run.
+ try
+ {
+ await Task.Delay(TimeSpan.FromSeconds(30), Shutdown.Token).ConfigureAwait(false);
+ }
+ catch (OperationCanceledException)
+ {
+ // The run is ending.
+ }
+
+ response.Abort();
+ return;
+ }
+
if (path == "/respond")
{
var query = context.Request.QueryString;
@@ -88,6 +108,13 @@ public static async Task HandleAsync(HttpListenerContext context)
await WriteAsync(response, await File.ReadAllBytesAsync(file).ConfigureAwait(false)).ConfigureAwait(false);
}
+ private static CancellationTokenSource CreateShutdown()
+ {
+ var source = new CancellationTokenSource();
+ AppDomain.CurrentDomain.ProcessExit += (_, _) => source.Cancel();
+ return source;
+ }
+
/// Answers a multipart form with the files it carried as JSON, as upstream's /upload: name, filename, mimetype, size, and the bytes (base64) of a file up to 64 KB.
private static async Task UploadAsync(HttpListenerContext context)
{
diff --git a/tests/E2E.Agent.Tests/Testbed.cs b/tests/E2E.Agent.Tests/Testbed.cs
index 02118f198..2e78b38bf 100644
--- a/tests/E2E.Agent.Tests/Testbed.cs
+++ b/tests/E2E.Agent.Tests/Testbed.cs
@@ -915,11 +915,17 @@ function submitForm() {
/// The base URL of the running playground, started on first use.
public static string Url => Server.Value;
+ /// Whether the app also answers on localhost, the second origin of the cross-origin cases. Starts the app when it is not running yet.
+ public static bool CrossOriginAvailable => Url.Length > 0 && s_crossOrigin;
+
+ private static bool s_crossOrigin;
+
private static string Start()
{
// HttpListener cannot bind port 0: take a free port, and try again when another test takes it first.
string url;
HttpListener listener;
+ bool crossOrigin;
for (var attempt = 0; ; attempt++)
{
var probe = new System.Net.Sockets.TcpListener(IPAddress.Loopback, 0);
@@ -933,7 +939,6 @@ private static string Start()
try
{
listener.Start();
- break;
}
catch (HttpListenerException)
{
@@ -945,8 +950,24 @@ private static string Start()
continue;
}
+
+ // The second origin of the cross-origin cases (upstream's CROSS), the same app under another host name. A host that cannot
+ // bind it (no mapping, no URL ACL) still serves the app; only the cross-origin tests skip themselves.
+ try
+ {
+ listener.Prefixes.Add("http://localhost:" + port.ToString(CultureInfo.InvariantCulture) + "/");
+ crossOrigin = true;
+ }
+ catch (Exception ex) when (ex is HttpListenerException or System.Net.Sockets.SocketException or ArgumentException)
+ {
+ crossOrigin = false;
+ }
+
+ break;
}
+ s_crossOrigin = crossOrigin;
+
_ = Task.Run(() => ListenAsync(listener));
return url.TrimEnd('/');
}
@@ -1015,7 +1036,42 @@ await WriteHtmlAsync(response, "Dashboard", """
}
else
{
- await PlaywrightRoutes.HandleAsync(context).ConfigureAwait(false);
+ // Its own task: a route that holds its response (upstream's /never) must not stall the other requests.
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ await PlaywrightRoutes.HandleAsync(context).ConfigureAwait(false);
+ }
+ catch (Exception ex) when (ex is HttpListenerException or InvalidOperationException or IOException or ObjectDisposedException)
+ {
+ // The client went away.
+ }
+ catch (Exception ex) when (ex is not OperationCanceledException)
+ {
+ // A route bug is a 500 the test can see, not an empty 200.
+ try
+ {
+ response.StatusCode = 500;
+ }
+ catch (Exception inner) when (inner is InvalidOperationException or ObjectDisposedException or System.Net.ProtocolViolationException)
+ {
+ // The response was already sent.
+ }
+ }
+ finally
+ {
+ try
+ {
+ response.Close();
+ }
+ catch (Exception ex) when (ex is HttpListenerException or InvalidOperationException or IOException or ObjectDisposedException)
+ {
+ // The response was aborted.
+ }
+ }
+ });
+ continue;
}
response.Close();
diff --git a/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs b/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs
new file mode 100644
index 000000000..bf3d7df0f
--- /dev/null
+++ b/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs
@@ -0,0 +1,34 @@
+// Copyright 2026 TesterArmy.
+// Modified by Dario Kondratiuk.
+// SPDX-License-Identifier: Apache-2.0
+
+using E2E.Engine;
+using static E2E.NUnit.Tests.Helpers;
+
+namespace E2E.NUnit.Tests.FrameGoto;
+
+///
+/// test.describe('frame goto') of upstream's apps/testbed/tests/frame-goto.e2e.ts (Playwright's
+/// frame-goto.spec.ts). The stalled /frames/script.js is a route that sends the request to /never. Not ported,
+/// as upstream: should navigate subframes, should reject when frame detaches, should return matching responses (no
+/// frame.goto and no Frame objects).
+///
+public sealed class FrameGotoTests : PlaywrightTest
+{
+ // Known difference, hardkoded/e2e-dotnet#1068: the timeout message has no `timed out in browser.goto` label.
+ [Test]
+ public async Task Should_continue_after_client_redirect()
+ {
+ await ExpectedToFailAsync("child-redirect.html: Timeout", async () =>
+ {
+ await Browser.RouteAsync("**/frames/script.js", route => route.ContinueAsync(new RouteContinueOverrides { Url = $"{PREFIX}/never" }));
+ var url = $"{PREFIX}/frames/child-redirect.html";
+ var error = await Record(() => Browser.GotoAsync(url, new GotoOptions { Timeout = TimeSpan.FromSeconds(5), WaitUntil = GotoWaitUntil.NetworkIdle }));
+
+ if (error is null || !error.Message.Contains("timed out in browser.goto", StringComparison.Ordinal))
+ {
+ throw new InvalidOperationException("Expected a message with 'timed out in browser.goto', but was: " + (error?.Message ?? "no error"));
+ }
+ });
+ }
+}
diff --git a/tests/E2E.NUnit.Tests/FrameHierarchy/FrameHierarchyTests.cs b/tests/E2E.NUnit.Tests/FrameHierarchy/FrameHierarchyTests.cs
new file mode 100644
index 000000000..572c479e7
--- /dev/null
+++ b/tests/E2E.NUnit.Tests/FrameHierarchy/FrameHierarchyTests.cs
@@ -0,0 +1,54 @@
+// Copyright 2026 TesterArmy.
+// Modified by Dario Kondratiuk.
+// SPDX-License-Identifier: Apache-2.0
+
+using static E2E.NUnit.Tests.Helpers;
+
+namespace E2E.NUnit.Tests.FrameHierarchy;
+
+///
+/// test.describe('frame hierarchy') of upstream's apps/testbed/tests/frame-hierarchy.e2e.ts (Playwright's
+/// frame-hierarchy.spec.ts). A frame the original finds in page.frames() is reached through FrameLocator. Not
+/// ported, as upstream: should send events when frames are manipulated dynamically, should persist mainFrame on cross-process
+/// navigation, should not send attach/detach events for main frame, should detach child frames on navigation, should support
+/// framesets, should report frame.name(), should report frame.parent(), should report different frame instance when frame
+/// re-attaches, should refuse to display x-frame-options:deny iframe, should return frame.page() (frame events, Frame objects,
+/// console events).
+///
+public sealed class FrameHierarchyTests : PlaywrightTest
+{
+ [Test]
+ public async Task Should_handle_nested_frames()
+ {
+ await Browser.GotoAsync("/frames/nested-frames.html");
+ await Expect.That(Browser.FrameLocator("[name=aframe]").Locator("div")).ToHaveTextAsync("Hi, I'm frame");
+ await Expect.That(Browser.FrameLocator("[name=\"2frames\"]").FrameLocator("[name=dos]").Locator("div")).ToHaveTextAsync("Hi, I'm frame");
+ await Expect.That(Browser.FrameLocator("[name=\"2frames\"]").FrameLocator("[name=uno]").Locator("div")).ToHaveTextAsync("Hi, I'm frame");
+ await Expect.That(Browser.FrameLocator("[name=\"2frames\"]").Locator("iframe")).ToHaveCountAsync(2);
+ await Expect.That(Browser.Locator("iframe")).ToHaveCountAsync(2);
+ }
+
+ [Test]
+ public async Task Partial_Should_send_framenavigated_when_navigating_on_anchor_URLs()
+ {
+ await Browser.GotoAsync("/empty.html");
+ await Browser.GotoAsync("/empty.html#foo");
+ Assert.That(await Browser.UrlAsync(), Is.EqualTo($"{PREFIX}/empty.html#foo"));
+ }
+
+ [Test]
+ public async Task Partial_Should_report_frame_from_inside_shadow_DOM()
+ {
+ await Browser.GotoAsync("/shadow.html");
+ await Browser.EvaluateAsync