Prove della vista remota aperta durante un cambio di pagina
Senza browser (RemoteViewStartTests, su FakeCdpSession e VirtualClock): un primo rifiuto «Not attached to an active page» dà comunque una vista aperta con i suoi fotogrammi; un rifiuto che non passa finisce in «non risponde» entro 5 s di orologio; collegamento chiuso o altri rifiuti non si ritentano; la sostituzione di una vista non lascia mai i permessi a zero. Nella prova con Chromium vero (TwoViewsOpenedAtTheSameMoment...) si controlla anche che durante la sostituzione il browser non resti mai senza conducente. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d07b072bf8
commit
1b767d517d
2 files changed
+279
-2
No files matched your search
@@ -250,20 +250,44 @@ public sealed partial class ServerEndToEndTests
|
||||
await server.Running.WaitAsync(TimeSpan.FromSeconds(60), ct);
|
||||
var host = server.RemoteView!;
|
||||
var gate = server.Browser!.UserDriving;
|
||||
var released = 0;
|
||||
void OnChanged(object? sender, bool driving)
|
||||
{
|
||||
if (!driving)
|
||||
{
|
||||
Interlocked.Increment(ref released);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
// Page.getFrameTree is answered by the page itself, which DevTools holds back while a navigation is pending:
|
||||
// «about:blank» here means the engine's rest has committed.
|
||||
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));
|
||||
// Two tabs restored together, or the phone and the PC at once: the newest wins, the other is ended — and the
|
||||
// engine never sees nobody at the browser in between (it would put the page to rest under the newer view).
|
||||
Volatile.Write(ref released, 0);
|
||||
gate.Changed += OnChanged;
|
||||
IRemoteViewConnection[] views;
|
||||
try
|
||||
{
|
||||
views = await Task.WhenAll(Task.Run(() => host.OpenAsync(ct), ct), Task.Run(() => host.OpenAsync(ct), ct));
|
||||
}
|
||||
finally
|
||||
{
|
||||
gate.Changed -= OnChanged;
|
||||
}
|
||||
|
||||
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.");
|
||||
Assert.AreEqual(0, Volatile.Read(ref released), $"Round {round}: the browser was never left without a driver while one view replaced the other.");
|
||||
|
||||
// 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();
|
||||
|
||||
Reference in new issue
Block a user