Browser vuoto: correzioni dopo la revisione (#52)

La revisione di c49df4c ha trovato alcuni punti deboli. Si correggono qui.

- Fuori vista la pagina torna al 100%. Lo zoom calcolato per uno schermo
  piccolo restava anche per le sessioni del motore, e le pagine vedevano un
  devicePixelRatio diverso (regola 4). Il rapporto si ricalcola solo quando
  la finestra viene sullo schermo.
- Pulsante nella barra delle applicazioni. WPF lo cambia nascondendo la
  finestra e mostrandola di nuovo (verificato con un aggancio a
  WM_WINDOWPOSCHANGED). Ora il pulsante cambia solo mentre la finestra è
  fuori vista. Sullo schermo la finestra chiede di ridisegnarsi
  (RedrawWindow), senza nulla che la pagina veda. Una prova con WebView2
  vero controlla che la finestra non si nasconda mai sullo schermo.
- Ridotta a icona troppo a lungo, la finestra si ripristina coperta (DWM) e
  senza prendere il fuoco, e si sposta fuori vista prima di scoprirsi. Prima
  ricompariva per un attimo dove stava. Spostare la posizione di ripristino
  non basta: Windows la riporta su uno schermo (provato).
- Dopo un riavvio del processo GPU i bordi della pagina cambiano davvero: un
  pixel in meno, poi quelli veri. Gli stessi bordi di nuovo potevano non
  servire a nulla.
- «Pagina iniziale», sulla barra di Windows e nella vista remota, passa da
  BrowserConnectionService.OpenStartPageAsync. Aspetta la fine della
  sessione del motore e il turno della pagina, come l'apertura dal riposo,
  e agisce solo mentre Alberto guida.
- Vista remota.
  - Dopo un riavvio dei fotogrammi la vista aspetta il primo fotogramma per
    mezzo secondo prima dell'immagine ferma: Chromium lo manda solo dopo la
    risposta allo start, e prima quasi ogni riavvio costava una cattura.
  - L'immagine ferma si scarta se nel frattempo arriva un fotogramma vero.
  - Il silenzio si conta dall'avvio.
  - Un riavvio del browser durante la chiusura non lascia eccezioni non
    osservate.
- Un POST vuoto senza Content-Length (a pezzi, HTTP/2) non dà più 400 su
  begin, cancel e browser/show (ApiHttp.OptionalBodyAsync).
- La pagina Browser toglie ?accesso=1 dall'indirizzo. Ricaricarla riapriva
  la pagina di accesso.
- RemoteViewFramesTests aspetta fino a 20 s invece di 5. Controlla che
  l'immagine arrivi, non quanto in fretta; il tempo va nell'uscita della
  prova.

Aggiornati PROTOCOLLO.md, la guida (Primo collegamento, Installazione
Windows) e docs/decisioni.md con le righe di #52.

Prove nuove:
- AFrameSoonAfterARestartNeedsNoStillPicture
- PaginaInizialeWaitsForThePageTurnAndActsOnlyWhileAlbertoIsAtTheBrowser
- ABodyWithoutALengthIsReadAndAnEmptyOneIsNoBody
- nella prova della finestra vera: nessun nascondere sullo schermo e pagina
  al 100% fuori vista

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-16 13:28:08 +01:00
1 parent c49df4ca7b
commit 654076d280
25 files changed
+505 -86

No files matched your search

+31 -2
View File
@@ -1,6 +1,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interop;
using Febe.Browser.Cdp;
using Febe.Desktop.Browser;
using Febe.SitoDiProva;
@@ -44,8 +45,9 @@ public sealed class BrowserWindowDecisionTests
/// <summary>
/// The window «Browser di Febe» on a real Windows (Gitea issue #52): on screen it has its taskbar button and says when
/// the page is the empty rest page, «Pagina iniziale» opens the start page, and a minimised window keeps Alberto at the
/// wheel until it has been minimised too long. The window comes on screen for a moment.
/// the page is the empty rest page, «Pagina iniziale» opens the start page, the window is never hidden while on screen
/// (WPF hides it to change its taskbar button) and out of view the page is at 100%, and a minimised window keeps Alberto
/// at the wheel until it has been minimised too long. The window comes on screen for a moment.
/// </summary>
[TestClass]
public sealed class BrowserWindowTests
@@ -67,6 +69,30 @@ public sealed class BrowserWindowTests
var window = await bed.OnUiAsync(() => bed.Browser.Host.Window) ?? throw new AssertFailedException("nessuna finestra");
Assert.IsFalse(await bed.OnUiAsync(() => window.ShowInTaskbar), "out of view, no taskbar button");
// Every hide of the window (SWP_HIDEWINDOW), and those while it is on screen, where Alberto would see it go.
var hides = 0;
var hidesOnScreen = 0;
await bed.OnUiAsync(() =>
{
var source = (HwndSource)PresentationSource.FromVisual(window);
source.AddHook((IntPtr _, int message, IntPtr _, IntPtr data, ref bool _) =>
{
const int WindowPosChanged = 0x0047;
const int HideWindow = 0x0080;
if (message == WindowPosChanged && (System.Runtime.InteropServices.Marshal.ReadInt32(data, (IntPtr.Size * 2) + 16) & HideWindow) != 0)
{
hides++;
if (window.IsOnScreen)
{
hidesOnScreen++;
}
}
return IntPtr.Zero;
});
return true;
});
await Task.Run(() => bed.Browser.ShowToUserAsync(ct), ct);
Assert.IsTrue(await bed.OnUiAsync(() => window.IsOnScreen));
Assert.IsTrue(await bed.OnUiAsync(() => window.ShowInTaskbar), "on screen, a taskbar button");
@@ -90,6 +116,9 @@ public sealed class BrowserWindowTests
await Task.Run(() => bed.Browser.HideFromUserAsync(ct), ct);
Assert.IsFalse(await bed.OnUiAsync(() => window.ShowInTaskbar), "out of view again, no taskbar button");
Assert.AreEqual(1.0, await bed.OnUiAsync(() => window.Fit), "out of view the page is at 100%, whatever the screen");
Assert.AreEqual(0, await bed.OnUiAsync(() => hidesOnScreen), $"never hidden on screen ({await bed.OnUiAsync(() => hides)} hides out of view)");
TestContext.WriteLine($"Nascosta fuori vista {await bed.OnUiAsync(() => hides)} volte per il pulsante nella barra delle applicazioni.");
}
[TestMethod]