From e5e2b6864fac6ea958d8616a1c160731ec0db132 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 20 Oct 2026 10:46:58 +0200 Subject: [PATCH] Prova di S1: il controllo sul comando rifiutato confronta letture fatte subito prima e subito dopo Il confronto con la posizione letta prima degli altri comandi poteva cogliere la fine di uno scorrimento ancora in corso; ora si misura solo l'effetto del window.scrollBy rifiutato, che avrebbe spostato la pagina di 500 pixel. Co-Authored-By: Claude Opus 5.5 --- tests/Febe.Tests.Windows/WebView2CdpTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Febe.Tests.Windows/WebView2CdpTests.cs b/tests/Febe.Tests.Windows/WebView2CdpTests.cs index a75bd47..920b1d4 100644 --- a/tests/Febe.Tests.Windows/WebView2CdpTests.cs +++ b/tests/Febe.Tests.Windows/WebView2CdpTests.cs @@ -112,8 +112,11 @@ public sealed class WebView2CdpTests await Assert.ThrowsExactlyAsync(() => cdp.SendAsync("Page.addScriptToEvaluateOnNewDocument", new JsonObject { ["source"] = "1" }, ct)); await Assert.ThrowsExactlyAsync(() => cdp.SendAsync("Fetch.enable", null, ct)); await Assert.ThrowsExactlyAsync(() => cdp.SendAsync("Target.createTarget", new JsonObject { ["url"] = "about:blank" }, ct)); + var before = (await cdp.EvaluateAsync("window.scrollY", ct)).GetDouble(); await Assert.ThrowsExactlyAsync(() => cdp.EvaluateAsync("window.scrollBy(0, 500)", ct)); - Assert.AreEqual(scrolled, (await cdp.EvaluateAsync("window.scrollY", ct)).GetDouble(), "the refused script did not run"); + await Task.Delay(300, ct); + var after = (await cdp.EvaluateAsync("window.scrollY", ct)).GetDouble(); + Assert.IsLessThan(100.0, Math.Abs(after - before), "the refused script did not run (it would have scrolled 500 px)"); var zone = (await cdp.EvaluateAsync("Intl.DateTimeFormat().resolvedOptions().timeZone", ct)).GetString(); Assert.AreNotEqual("America/New_York", zone);