Collegamento e motore: correzioni regole-1, regole-2, regole-6, websec-1, websec-5, websec-6, engine-1, engine-2, sched-1
Pagine aperte da Alberto non sono segnali (regole-1); cookie perso fuori sessione = disconnessione (regole-2); pagina a riposo quando Alberto lascia il browser (regole-6); la lease di «Accedi»/«Usa il browser» finisce da sola dopo 2 minuti senza vista remota né finestra (websec-1); ping con scadenza sulla vista remota (websec-5); aperture della vista remota serializzate (websec-6); orologio virtuale senza fine anticipata (engine-1); la sincronizzazione della coda non duplica il compito in corso (engine-2); raccolte in evidenza programmate (sched-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
19 files changed
+1122
-92
No files matched your search
@@ -240,6 +240,62 @@ public sealed partial class ServerEndToEndTests
|
||||
Assert.IsTrue(Febe.Browser.Hosting.LoopbackPortCheck.IsLoopbackOnly(bed.Options.DebugPort, out _));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(120_000, CooperativeCancellation = true)]
|
||||
public async Task TwoViewsOpenedAtTheSameMomentLeaveOneViewWithItsFramesAndOneLease()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await ServerTestBed.StartAsync();
|
||||
var server = bed.Server;
|
||||
await server.Running.WaitAsync(TimeSpan.FromSeconds(60), ct);
|
||||
var host = server.RemoteView!;
|
||||
var gate = server.Browser!.UserDriving;
|
||||
for (var round = 0; round < 5; round++)
|
||||
{
|
||||
// From the rest page: where the browser starts, and where the engine puts it once nobody is at the browser.
|
||||
await ServerTestBed.WaitUntilAsync(
|
||||
async () => await Febe.Browser.Cdp.CdpPageExtensions.GetMainFrameUrlAsync(server.Browser.Cdp, ct) == "about:blank",
|
||||
TimeSpan.FromSeconds(20),
|
||||
"la pagina di riposo");
|
||||
|
||||
// Two tabs restored together, or the phone and the PC at once: the newest wins, the other is ended.
|
||||
var views = await Task.WhenAll(Task.Run(() => host.OpenAsync(ct), ct), Task.Run(() => host.OpenAsync(ct), ct));
|
||||
var open = views.Where(v => v.Ended is null).ToList();
|
||||
Assert.HasCount(1, open, $"Round {round}: one view stays open.");
|
||||
Assert.AreEqual(RemoteViewEnd.Replaced, views.Single(v => v.Ended is not null).Ended);
|
||||
Assert.AreEqual(1, gate.Leases, $"Round {round}: only the open view holds the browser.");
|
||||
|
||||
// The page of the replaced view closes its socket: the open view still gets its frames.
|
||||
await views.Single(v => v.Ended is not null).DisposeAsync();
|
||||
await Febe.Browser.Cdp.CdpPageExtensions.NavigateAsync(server.Browser.Cdp, $"{bed.Site.SiteUrl}/?giro={round}", ct);
|
||||
Assert.IsTrue(await FrameArrivesAsync(open[0], ct), $"Round {round}: frames go on after the other view closed.");
|
||||
|
||||
await open[0].DisposeAsync();
|
||||
Assert.AreEqual(0, gate.Leases, $"Round {round}: no view, no lease.");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<bool> FrameArrivesAsync(IRemoteViewConnection view, CancellationToken ct)
|
||||
{
|
||||
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
timeout.CancelAfter(TimeSpan.FromSeconds(15));
|
||||
try
|
||||
{
|
||||
await foreach (var output in view.ReadAsync(timeout.Token))
|
||||
{
|
||||
if (output is RemoteViewFrame)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (!ct.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static async Task<bool> WaitRunningAsync(Febe.Server.FebeServer server)
|
||||
{
|
||||
for (var i = 0; i < 40 && !server.Engine!.Services.Runtime.IsRunning; i++)
|
||||
|
||||
Reference in new issue
Block a user