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 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-20 10:46:58 +02:00
1 parent 7b0b0339f7
commit e5e2b6864f
1 file changed
+4 -1
+4 -1
View File
@@ -112,8 +112,11 @@ public sealed class WebView2CdpTests
await Assert.ThrowsExactlyAsync<CdpCommandNotAllowedException>(() => cdp.SendAsync("Page.addScriptToEvaluateOnNewDocument", new JsonObject { ["source"] = "1" }, ct));
await Assert.ThrowsExactlyAsync<CdpCommandNotAllowedException>(() => cdp.SendAsync("Fetch.enable", null, ct));
await Assert.ThrowsExactlyAsync<CdpCommandNotAllowedException>(() => cdp.SendAsync("Target.createTarget", new JsonObject { ["url"] = "about:blank" }, ct));
var before = (await cdp.EvaluateAsync("window.scrollY", ct)).GetDouble();
await Assert.ThrowsExactlyAsync<CdpCommandNotAllowedException>(() => 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);