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:
1 parent
c49df4ca7b
commit
654076d280
25 files changed
+505
-86
No files matched your search
@@ -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]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Febe.App;
|
||||
using Febe.Browser.Cdp;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Data;
|
||||
@@ -44,7 +45,10 @@ internal sealed class BrowserBed : IAsyncDisposable
|
||||
|
||||
/// <param name="name">Prefix of the temporary folder.</param>
|
||||
/// <param name="hosting">How WebView2 draws (S2).</param>
|
||||
/// <param name="startPage">Where «Pagina iniziale» goes; null: the login page of the options.</param>
|
||||
/// <param name="startPage">
|
||||
/// Where «Pagina iniziale» goes, opened as the connection would (here without an engine to wait for); null: the button
|
||||
/// does nothing (never the default login page of the options, which is Instagram's).
|
||||
/// </param>
|
||||
public static async Task<BrowserBed> CreateAsync(string name, BrowserHosting hosting = BrowserHosting.Window, Func<string>? startPage = null)
|
||||
{
|
||||
var folder = new TestFolder(name);
|
||||
@@ -56,11 +60,14 @@ internal sealed class BrowserBed : IAsyncDisposable
|
||||
var database = await FebeDatabase.OpenAsync(data.Root);
|
||||
var options = new FebeAppOptions { DataFolder = data.Root, LibraryFolder = folder.Combine("libreria") };
|
||||
var tracker = new BrowserUseTracker();
|
||||
var context = new FebePlatformContext(options, data, database, clock, log, tracker, startPage);
|
||||
WebView2Browser? built = null;
|
||||
Func<CancellationToken, Task>? openStartPage = startPage is null ? null : async ct => await built!.Cdp.NavigateAsync(startPage(), ct);
|
||||
var context = new FebePlatformContext(options, data, database, clock, log, tracker, openStartPage);
|
||||
var settings = new WebView2BrowserSettings(data.BrowserProfile, 1280, 900, hosting, BrowserArguments.ForWebView2());
|
||||
|
||||
// Built off the UI thread, as DesktopPlatform.CreateBrowserAsync does after its awaits.
|
||||
var browser = new WebView2Browser(ui.Dispatcher, settings, context, icon: null);
|
||||
built = browser;
|
||||
return new BrowserBed(folder, ui, lines, log, database, tracker, browser);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user