Web panel host fix round 1: non-fatal process kinds, late failures, thread restart, focus and permission guards

- ProcessFailed: only BrowserProcessExited (teardown) and RenderProcessExited (about:blank, recreate on the next Open) fail the panel, as WebView2's docs describe the kinds; GPU, utility, sandbox, PPAPI and frame-only renderer exits are logged only. RenderProcessUnresponsive fails it at 3 reports within 30 s. The handler acts on the panel being served now.
- Fail decides "ignored" under the lock first and hides the panel only when the failure is live: a late failure for a superseded handle no longer hides the newer panel.
- The panel thread's finally restarts the thread when an Open is still queued and the host is not shutting down; _threadDone goes false only after StartStaThread returns.
- Show takes the foreground only when a window of this process (or of this panel's WebView2 browser process) holds it, never while the foreground is null. The visibility rule counts the browser process (CoreWebView2.BrowserProcessId) as ours, so the page's own dialogs do not hide the panel.
- ClipboardRead is allowed only for an allowlisted origin. NavigationStarting and NewWindowRequested fail closed on an exception.
- WebPanelApiRules: the ABI glue's pure parts (refusals, GetState Size check, state write), tested in WebPanelTests with WebPanelNativeArgs. WebPanelApi.LiveHandle and the browser pid in Describe for Task 4.
- Harness: GpuProcessCrashKeepsPanel and LateFailureForSupersededHandle (both RED before the fix), UnloadWhileVisibleCollected reports UNVERIFIED when the window was not visible, the game-side key count is informational. EngineSettingsTests: WebPanel default-on round trip and setter case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 15:26:37 -08:00
commit 388f3fd908
9 changed files with 427 additions and 64 deletions

View file

@ -58,6 +58,7 @@ namespace EngineSettingsTests
Run(nameof(MaxHotReloadsReadAndKept), MaxHotReloadsReadAndKept);
Run(nameof(CloseOnServerDisconnectDefaultOnAndSaved), CloseOnServerDisconnectDefaultOnAndSaved);
Run(nameof(TransitionGateDefaultOnAndSaved), TransitionGateDefaultOnAndSaved);
Run(nameof(WebPanelDefaultOnAndSaved), WebPanelDefaultOnAndSaved);
Run(nameof(HoldReloadInWorldOptInAndSaved), HoldReloadInWorldOptInAndSaved);
Run(nameof(IltServerNamesEdit), IltServerNamesEdit);
Run(nameof(DisplaySettingsDefaultsAndSaved), DisplaySettingsDefaultsAndSaved);
@ -118,6 +119,8 @@ namespace EngineSettingsTests
case "dcclose-on": EngineSettings.CloseOnServerDisconnect = true; break;
case "tgate-off": EngineSettings.TransitionGate = false; break;
case "tgate-on": EngineSettings.TransitionGate = true; break;
case "webpanel-off": EngineSettings.WebPanel = false; break;
case "webpanel-on": EngineSettings.WebPanel = true; break;
case "borderless-on": EngineSettings.BorderlessWindowed = true; break;
case "borderless-off": EngineSettings.BorderlessWindowed = false; break;
case "layout-on": EngineSettings.RememberWindowLayout = true; break;
@ -148,6 +151,7 @@ namespace EngineSettingsTests
Console.WriteLine("MaxHotReloads=" + EngineSettings.MaxHotReloads);
Console.WriteLine("CloseOnServerDisconnect=" + EngineSettings.CloseOnServerDisconnect);
Console.WriteLine("TransitionGate=" + EngineSettings.TransitionGate);
Console.WriteLine("WebPanel=" + EngineSettings.WebPanel);
Console.WriteLine("BorderlessWindowed=" + EngineSettings.BorderlessWindowed);
Console.WriteLine("RememberWindowLayout=" + EngineSettings.RememberWindowLayout);
Console.WriteLine("PanelLayoutPerCharacter=" + EngineSettings.PanelLayoutPerCharacter);
@ -415,6 +419,7 @@ namespace EngineSettingsTests
(new[] { "ilt-add", "Frosthaven" }, "IltServerNames", null),
(new[] { "autoid", "all" }, "AutoIdMode", "\"All\""),
(new[] { "tgate-off" }, "TransitionGate", "false"),
(new[] { "webpanel-off" }, "WebPanel", "false"),
(new[] { "add-plugin", plugin }, "PluginPaths", null),
(new[] { "remove-plugin", "0" }, "PluginPaths", null),
};
@ -622,6 +627,36 @@ namespace EngineSettingsTests
}
}
// engine.json WebPanel (2026-11-07, the v93 web panel kill switch): default on, only a hand-set false is
// written, other saves keep it, a value that is not a boolean is ignored.
private static void WebPanelDefaultOnAndSaved()
{
string dir = NewDir("webpanel");
string path = Path.Combine(dir, "engine.json");
File.WriteAllText(path, LauncherFile);
Eq(DumpValue(RunChild(path, "dump").Out, "WebPanel"), "True", "missing: on");
Eq(RunChild(path, "hook-off", "StartTooltip").Exit, 0, "save with the default");
Check(!ReadJson(path).TryGetProperty("WebPanel", out _), "the default isn't written to the file");
var (exit, output) = RunChild(path, "webpanel-off");
Eq(exit, 0, "turn off (" + output.Trim() + ")");
Eq(ReadJson(path).GetProperty("WebPanel").GetRawText(), "false", "off is saved");
Check(ReadJson(path).TryGetProperty("LauncherWindow", out _), "launcher keys kept");
Eq(DumpValue(RunChild(path, "dump").Out, "WebPanel"), "False", "off read back at the next start");
Eq(RunChild(path, "hook-off", "CheckTooltip").Exit, 0, "another save");
Eq(ReadJson(path).GetProperty("WebPanel").GetRawText(), "false", "off survives other saves");
Eq(RunChild(path, "webpanel-on").Exit, 0, "turn on");
Check(!ReadJson(path).TryGetProperty("WebPanel", out _), "on again: dropped from the file");
foreach (string bad in new[] { "\"no\"", "0", "null" })
{
File.WriteAllText(path, LauncherFile.Replace("\"LoggingLevel\"", $"\"WebPanel\": {bad}, \"LoggingLevel\""));
Eq(DumpValue(RunChild(path, "dump").Out, "WebPanel"), "True", $"{bad}: ignored, on");
}
}
// Settings > Display (2026-10-18): BorderlessWindowed off and RememberAcWindowPosition off by default,
// RememberWindowLayout on (panels have always been remembered). Only the non-default is written;
// other saves keep it; a value that is not a boolean is ignored.

View file

@ -53,6 +53,8 @@ public static unsafe class PayloadEntry
public static int AcceleratorKeyEvents => _host!.AcceleratorKeyEventsForTests;
public static string Source => _host!.SourceForTests;
public static bool ThreadRunning => _host!.ThreadRunningForTests;
public static bool PanelOpen => _host!.PanelOpenForTests;
public static bool FailHandle(int handle) => _host!.FailForTests(handle);
public static string ProfileFolder(string world, string key) => WebPanelProfile.Folder(_env!.LocalAppData, world, key);

View file

@ -35,6 +35,7 @@
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelWindowPolicy.cs" Link="Engine\WebPanelWindowPolicy.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelProfile.cs" Link="Engine\WebPanelProfile.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelNativeArgs.cs" Link="Engine\WebPanelNativeArgs.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelApiRules.cs" Link="Engine\WebPanelApiRules.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelLayoutStore.cs" Link="Engine\WebPanelLayoutStore.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\IWebPanelEnvironment.cs" Link="Engine\IWebPanelEnvironment.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelNative.cs" Link="Engine\WebPanelNative.cs" />

View file

@ -103,6 +103,8 @@ internal static unsafe class Program
Guard("StaleHandles", () => handle = CheckStaleHandles(s, handle));
Guard("ProfileSwitchRecreates", () => handle = CheckProfileSwitch(s));
Guard("NoBrowserFallbackAfterNavigation", () => CheckNoFallbackAfterNavigation(s, handle));
Guard("GpuProcessCrashKeepsPanel", () => handle = CheckGpuCrash(s));
Guard("LateFailureForSupersededHandle", () => handle = CheckLateFailure(s));
Guard("CreateFailureFallsBack", () => CheckCreateFailure(s));
Guard("VisibilitySameProcess", () => handle = CheckVisibilitySameProcess(s));
Unverified("VisibilityOtherProcess", "needs another process to take the foreground (alt-tab); the harness never forces it. Owner in-game check.");
@ -214,8 +216,11 @@ internal static unsafe class Program
int g = _gameKeyMsgs - g0;
W($"page input value {value}; fake game key messages during the test: {g}; AcceleratorKeyPressed events {(int)s.Call("get_AcceleratorKeyEvents")! - k0}; panel visible={IsWindowVisible((IntPtr)s.Call("get_HostHwnd")!)}; {FgDesc()}");
Snap((IntPtr)s.Call("get_HostHwnd")!, Path.Combine(_root, "panel-keys.png"));
// The game-side count is informational only: the keys are posted straight to the Chromium window, so the
// game could not see them here whatever the host did. Input isolation (unowned popup, separate queue) is an
// owner in-game check: type in the panel, nothing reaches AC's chat.
W($"(informational, cannot fail: game key messages {g})");
if (!value.Contains("x1q")) Fail("KeysStayInPage", $"page input is {value}, want x1q");
else if (g != 0) Fail("KeysStayInPage", $"the game window saw {g} key message(s)");
else Ok("KeysStayInPage");
return h;
}
@ -244,7 +249,6 @@ internal static unsafe class Program
return;
}
if (!closed) { Fail("EscapeClosesAndRefocusesGame", $"AcceleratorKeyPressed fired but the panel is {st[2]}, not Closed"); return; }
if (g != 0) { Fail("EscapeClosesAndRefocusesGame", $"the game saw {g} key message(s)"); return; }
if (!panelFg) { Unverified("EscapeClosesAndRefocusesGame", "closed, game saw 0 keys; the foreground hand-back could not be checked (the panel did not hold the foreground)"); return; }
if (fg != _game) { Fail("EscapeClosesAndRefocusesGame", "closed, but the foreground is not the game"); return; }
Ok("EscapeClosesAndRefocusesGame");
@ -388,6 +392,92 @@ internal static unsafe class Program
else Fail("OpenAfterProcessFailedRecreates", $"[{string.Join(",", st2)}]");
}
private static int CheckGpuCrash(Session s)
{
var (h, _) = Open(s, "https://panel.test/index.html", Allow, title: "GPU crash");
if (!WaitStatus(s, h, StatusReady, 30000, out int[] a)) { Fail("GpuProcessCrashKeepsPanel", $"not Ready [{string.Join(",", a)}]"); return h; }
uint browser = (uint)(int)s.Call("get_BrowserProcessId")!;
int children = 0, readable = 0, gpu = 0;
foreach (Process p in Process.GetProcessesByName("msedgewebview2"))
{
using (p)
{
if (ParentPid(p.Id) != browser) continue;
children++;
string? cmd = CommandLine(p.Id);
if (cmd == null) continue;
readable++;
if (gpu == 0 && cmd.Contains("--type=gpu-process", StringComparison.Ordinal)) gpu = p.Id;
}
}
W($"browser pid {browser}: {children} child process(es), {readable} command line(s) readable, gpu-process pid {gpu}");
if (gpu == 0) { Unverified("GpuProcessCrashKeepsPanel", $"no msedgewebview2 child of browser pid {browser} with --type=gpu-process ({children} children, {readable} command lines read)"); return h; }
int logs0 = LogLines.Count;
try { using var p = Process.GetProcessById(gpu); p.Kill(); }
catch (Exception ex) { Unverified("GpuProcessCrashKeepsPanel", "could not kill the gpu process: " + ex.Message); return h; }
Thread.Sleep(3000);
int[] st = State(s, h);
string alive = (string)s.Call("Eval", "document.title", 5000)!;
bool open = (bool)s.Call("get_PanelOpen")!;
var newLogs = LogLines.Skip(logs0).ToList();
W($"killed gpu pid {gpu}: state [{string.Join(",", st)}], panel open {open}, page title {alive}; log: {string.Join(" | ", newLogs)}");
if (st[2] != StatusReady || st[4] != 0) Fail("GpuProcessCrashKeepsPanel", $"status {st[2]} error {st[4]}, want Ready with no error");
else if (!open) Fail("GpuProcessCrashKeepsPanel", "the panel closed");
else if (!newLogs.Any(l => l.Contains("GpuProcessExited"))) Unverified("GpuProcessCrashKeepsPanel", "panel stayed Ready, but no GpuProcessExited ProcessFailed event arrived within 3 s, so the handler path was not shown");
else Ok("GpuProcessCrashKeepsPanel");
return h;
}
private static int CheckLateFailure(Session s)
{
var (a, _) = Open(s, "https://panel.test/index.html", Allow, title: "Old");
bool ra = WaitStatus(s, a, StatusReady, 30000, out _);
var (b, _) = Open(s, "https://panel.test/b.html", Allow, title: "New");
bool rb = WaitStatus(s, b, StatusReady, 30000, out _);
bool open0 = (bool)s.Call("get_PanelOpen")!;
bool posted = (bool)s.Call("FailHandle", a)!;
Thread.Sleep(600);
int[] st = State(s, b);
bool open = (bool)s.Call("get_PanelOpen")!;
W($"late synthetic failure for superseded handle {a} (posted {posted}): newer handle {b} state [{string.Join(",", st)}], panel open before {open0} after {open}");
if (!ra || !rb || !open0) Fail("LateFailureForSupersededHandle", "setup: panels not Ready/open");
else if (st[2] != StatusReady) Fail("LateFailureForSupersededHandle", $"newer panel status {st[2]}, want Ready");
else if (!open) Fail("LateFailureForSupersededHandle", "the late failure hid the newer panel");
else Ok("LateFailureForSupersededHandle");
return b;
}
private static uint ParentPid(int pid)
{
IntPtr h = OpenProcess(0x1000 /* PROCESS_QUERY_LIMITED_INFORMATION */, false, pid);
if (h == IntPtr.Zero) return 0;
try
{
PROCESS_BASIC_INFORMATION pbi;
return NtQueryInformationProcess(h, 0, &pbi, sizeof(PROCESS_BASIC_INFORMATION), out _) == 0 ? (uint)pbi.InheritedFromUniqueProcessId.ToInt64() : 0;
}
finally { CloseHandle(h); }
}
/// <summary>ProcessCommandLineInformation (60): a UNICODE_STRING followed by its text, in our buffer.</summary>
private static string? CommandLine(int pid)
{
IntPtr h = OpenProcess(0x1000, false, pid);
if (h == IntPtr.Zero) return null;
try
{
byte[] buf = new byte[65536];
fixed (byte* b = buf)
{
if (NtQueryInformationProcess(h, 60, b, buf.Length, out _) != 0) return null;
int len = *(ushort*)b;
char* text = *(char**)(b + IntPtr.Size);
return text == null ? null : new string(text, 0, len / 2);
}
}
finally { CloseHandle(h); }
}
private static void CheckCreateFailure(Session s)
{
Drain(BrowserCalls);
@ -492,14 +582,15 @@ internal static unsafe class Program
_pumpSession = s;
var (h, _) = Open(s, "https://panel.test/launch.html?code=" + Secret, Allow);
if (!WaitStatus(s, h, StatusReady, 30000, out int[] st)) { Fail("UnloadWhileVisibleCollected", $"not Ready [{string.Join(",", st)}]"); }
W($"session 2 open: state [{string.Join(",", State(s, h))}] host visible {IsWindowVisible((IntPtr)s.Call("get_HostHwnd")!)}");
bool visible = IsWindowVisible((IntPtr)s.Call("get_HostHwnd")!);
W($"session 2 open: state [{string.Join(",", State(s, h))}] host visible {visible}");
var sd = Stopwatch.StartNew();
s.Call("Shutdown", 2000);
W($"Shutdown(2000) returned in {sd.ElapsedMilliseconds} ms (panel open; window shown only if the harness held the foreground)");
UnloadAndJudge("UnloadWhileVisibleCollected", ref s);
UnloadAndJudge("UnloadWhileVisibleCollected", ref s, visible ? null : "collected, but the panel window was not visible (the PID rule hid it: the harness did not hold the foreground), so the visible-teardown path was not shown");
}
private static void UnloadAndJudge(string name, ref Session s)
private static void UnloadAndJudge(string name, ref Session s, string? unverifiedIfCollected = null)
{
_pumpSession = null;
_pumpHandle = 0;
@ -511,6 +602,7 @@ internal static unsafe class Program
while (weak.IsAlive && sw.ElapsedMilliseconds < 3000) { GC.Collect(); GC.WaitForPendingFinalizers(); if (weak.IsAlive) Thread.Sleep(20); }
W($"{name}: context {(weak.IsAlive ? "STILL HELD" : "collected")} after {sw.ElapsedMilliseconds} ms");
if (weak.IsAlive) Fail(name, "the payload context was not collected within 3000 ms");
else if (unverifiedIfCollected != null) Unverified(name, unverifiedIfCollected);
else Ok(name);
}
@ -933,6 +1025,10 @@ internal static unsafe class Program
[DllImport("gdi32.dll")] private static extern bool DeleteObject(IntPtr o);
[DllImport("gdi32.dll")] private static extern bool DeleteDC(IntPtr dc);
[DllImport("gdi32.dll")] private static extern int GetDIBits(IntPtr dc, IntPtr bmp, uint start, uint lines, byte* bits, ref BITMAPINFOHEADER bi, uint usage);
[StructLayout(LayoutKind.Sequential)] private struct PROCESS_BASIC_INFORMATION { public IntPtr ExitStatus, PebBaseAddress, AffinityMask, BasePriority, UniqueProcessId, InheritedFromUniqueProcessId; }
[DllImport("ntdll.dll")] private static extern int NtQueryInformationProcess(IntPtr h, int cls, void* info, int len, out int ret);
[DllImport("kernel32.dll")] private static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
[DllImport("kernel32.dll")] private static extern bool CloseHandle(IntPtr h);
[DllImport("kernel32.dll")] private static extern uint GetCurrentThreadId();
[DllImport("kernel32.dll")] private static extern IntPtr GetModuleHandleW(IntPtr n);
}

View file

@ -1,9 +1,11 @@
using System.Text;
using RynthCore.Engine.Plugins;
using RynthCore.Engine.WebPanel;
namespace WebPanelTests;
/// <summary>The web panel's pure policies: URL allowlist, redaction, visibility, layout, profile folder.</summary>
internal static class Program
internal static unsafe class Program
{
private static int _checks, _failed;
private static string _case = "";
@ -22,6 +24,8 @@ internal static class Program
Visibility();
Layout();
Profile();
ApiRules();
NativeArgs();
Console.WriteLine(_failed == 0 ? $"PASS ({_checks} assertions)" : $"FAIL ({_failed} of {_checks} assertions)");
return _failed == 0 ? 0 : 1;
@ -188,6 +192,88 @@ internal static class Program
Check(wild.X >= 0 && wild.Y >= 0 && wild.W <= 1 && wild.H <= 1 && wild.X + wild.W <= 1.000001, "FromUserRect clamps to 0..1");
}
// WebPanelApi's pure parts (WebPanelApiRules): the kill switch and shutdown refusals, the GetState Size check.
private static void ApiRules()
{
Case("ApiRules");
Eq(WebPanelApiRules.OpenRefusal(shuttingDown: false, enabled: true), 0, "enabled, running: go on");
Eq(WebPanelApiRules.OpenRefusal(false, false), (int)WebPanelCode.Unavailable, "engine.json WebPanel false: Unavailable");
Eq(WebPanelApiRules.OpenRefusal(true, true), (int)WebPanelCode.ShuttingDown, "shutting down: ShuttingDown");
Eq(WebPanelApiRules.OpenRefusal(true, false), (int)WebPanelCode.ShuttingDown, "shutting down wins over the kill switch");
Eq(WebPanelApiRules.CallRefusal(false), 0, "calls go on while running");
Eq(WebPanelApiRules.CallRefusal(true), (int)WebPanelCode.ShuttingDown, "calls refused after shutdown");
uint min = WebPanelApiRules.StateMinSize;
if (IntPtr.Size == 4) Eq(min, 28u, "OffsetOf(Reserved) of the state struct on x86");
Check(min > 0 && min < (uint)sizeof(WebPanelStateNative), "min size is inside the struct");
Check(!WebPanelApiRules.StateArgsOk(null), "null state refused");
WebPanelStateNative st = default;
st.Size = min - 1;
Check(!WebPanelApiRules.StateArgsOk(&st), "Size below OffsetOf(Reserved) refused");
st.Size = min;
Check(WebPanelApiRules.StateArgsOk(&st), "Size == OffsetOf(Reserved) accepted");
st.Size = (uint)sizeof(WebPanelStateNative);
Check(WebPanelApiRules.StateArgsOk(&st), "full Size accepted");
st.Reserved[0] = 0xDEADBEEF;
WebPanelApiRules.WriteState(&st, new WebPanelSnapshot(7, 3, 5, -9, 200, 4));
Eq(st.Handle, 7, "handle written");
Eq(st.Status, 3, "status written");
Eq(st.Flags, 5u, "flags written");
Eq(st.Error, -9, "error written");
Eq(st.LastHttpStatus, 200, "http written");
Eq(st.NavigationCount, 4u, "navigations written");
Eq(st.Reserved[0], 0xDEADBEEFu, "Reserved untouched");
Eq(WebPanelApiRules.NoPanel(9).Status, (int)WebPanelStatusCode.Superseded, "no panel yet: Superseded");
}
// WebPanelNativeArgs: the strings are copied out of the caller's buffers; bad arguments are BadArgs.
private static void NativeArgs()
{
Case("NativeArgs");
const string lad = @"C:\lad";
Eq(WebPanelNativeArgs.TryBuildRequest(null, lad, "W", out _), (int)WebPanelCode.BadArgs, "null struct");
int Build(string? url, string? allow, string? key, string? title, uint size, uint flags, out WebPanelRequest? req)
{
byte[] u = Z(url), a = Z(allow), k = Z(key), ti = Z(title);
fixed (byte* pu = u, pa = a, pk = k, pt = ti)
{
var o = new WebPanelOpenNative
{
Size = size, Flags = flags,
Url = url == null ? null : pu, Allowlist = allow == null ? null : pa,
ProfileKey = key == null ? null : pk, Title = title == null ? null : pt,
};
int rc = WebPanelNativeArgs.TryBuildRequest(&o, lad, "W", out req);
Array.Fill(u, (byte)'Z'); Array.Fill(a, (byte)'Z'); // the caller's buffers die right after the call
return rc;
}
}
static byte[] Z(string? s) => s == null ? new byte[1] : Encoding.UTF8.GetBytes(s + "\0");
uint full = (uint)sizeof(WebPanelOpenNative);
Eq(Build("https://a.test/x?code=1", "a.test", "k", "T", full, 0xFF, out var r), 0, "good request");
Eq(r?.Url, "https://a.test/x?code=1", "url copied before the buffer was overwritten");
Eq(r?.Allowlist.Length, 1, "allowlist parsed");
Eq(r?.Title, "T", "title copied");
Eq(r?.Flags, 3u, "unknown flag bits dropped");
Check(r != null && r.ProfileFolder.StartsWith(lad, StringComparison.Ordinal), "profile folder under LocalAppData");
Eq(Build("https://a.test/", "a.test", null, null, full, 0, out r), 0, "null key and title");
Eq(r?.Title, "", "null title is empty");
Eq(Build("https://a.test/", "a.test", null, null, 31, 0, out _), (int)WebPanelCode.BadArgs, "Size below OffsetOf(Reserved)");
Eq(Build(null, "a.test", null, null, full, 0, out _), (int)WebPanelCode.BadArgs, "no url");
Eq(Build("", "a.test", null, null, full, 0, out _), (int)WebPanelCode.BadArgs, "empty url");
Eq(Build("https://a.test/", null, null, null, full, 0, out _), (int)WebPanelCode.BadArgs, "no allowlist");
Eq(Build("https://a.test/", "*.com", null, null, full, 0, out _), (int)WebPanelCode.BadArgs, "bad allowlist");
Eq(Build("https://a.test/", "a.test", null, new string('t', 129), full, 0, out _), (int)WebPanelCode.BadArgs, "title over 128 bytes");
Eq(Build("https://a.test/", "a.test", new string('k', 257), null, full, 0, out _), (int)WebPanelCode.BadArgs, "key over 256 bytes");
Eq(Build("https://a.test/" + new string('p', 4096), "a.test", null, null, full, 0, out _), (int)WebPanelCode.BadArgs, "url over 4096 bytes");
byte[] bad = { 0x68, 0xC3, 0x28, 0 }; // invalid UTF-8
fixed (byte* pb = bad) Check(!WebPanelNativeArgs.TryReadUtf8(pb, 16, true, out _), "invalid UTF-8 refused");
}
private static void Profile()
{
Case("Profile");

View file

@ -13,12 +13,18 @@
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>WebPanelTests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);CS0649;CS0169</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelUrlPolicy.cs" Link="Engine\WebPanelUrlPolicy.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelWindowPolicy.cs" Link="Engine\WebPanelWindowPolicy.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelProfile.cs" Link="Engine\WebPanelProfile.cs" />
<!-- The ABI glue's pure parts (WebPanelApi.cs itself needs the engine): argument copy-out and refusals. -->
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PluginContract.cs" Link="Engine\PluginContract.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelNativeArgs.cs" Link="Engine\WebPanelNativeArgs.cs" />
<Compile Include="..\..\src\RynthCore.Engine\WebPanel\WebPanelApiRules.cs" Link="Engine\WebPanelApiRules.cs" />
</ItemGroup>
</Project>