ServerPack: one browser decision after the panel, pinned by scan
AfterPanel now asks ServerWebOpen.FallbackToBrowser first and opens the browser only there; the RefusedBeforeNavigate switch arm is gone. A source scan pins OpenInBrowser(r, done) to exactly two places (OpenWeb's browser route and right after the guard), so a browser open added to another arm (a spent code opened twice) fails the tests. Checked by mutation: an extra arm gives 3, a moved call fails the guard check. A newer Open answers the older waiting open Closed only once the engine has queued it; a refused or throwing second open leaves the first waiting (test added, RED against the old order). The SDK-name scan also covers the WebPanel*Fn table slots. Trailing newlines restored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ba3b5909e
commit
9a2cbb59c7
3 changed files with 58 additions and 12 deletions
|
|
@ -71,6 +71,14 @@ public sealed partial class ServerPackPlugin
|
|||
{
|
||||
try
|
||||
{
|
||||
// The one browser decision after the panel (ServerWebOpen.FallbackToBrowser: a refusal before
|
||||
// navigating only). Every other answer below ends without the browser: the code may be spent.
|
||||
if (ServerWebOpen.FallbackToBrowser(result))
|
||||
{
|
||||
LogTagged("web panel: " + result + ", using the browser");
|
||||
OpenInBrowser(r, done);
|
||||
return;
|
||||
}
|
||||
switch (result)
|
||||
{
|
||||
case PanelResult.Opened:
|
||||
|
|
@ -81,10 +89,6 @@ public sealed partial class ServerPackPlugin
|
|||
LogTagged("web panel: OpenedInBrowserByEngine");
|
||||
Finish(done, new WebOpenOutcome(WebOpenRoute.Browser, true, "Opened in your browser."));
|
||||
return;
|
||||
case PanelResult.RefusedBeforeNavigate:
|
||||
LogTagged("web panel: RefusedBeforeNavigate, using the browser");
|
||||
OpenInBrowser(r, done);
|
||||
return;
|
||||
case PanelResult.UrlNotAllowed:
|
||||
case PanelResult.BadArgs:
|
||||
// A plugin bug: the request did not pass the engine's checks. The browser would hide it.
|
||||
|
|
@ -225,4 +229,4 @@ public sealed partial class ServerPackPlugin
|
|||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private int WebPanelCloseCore(int handle) => Host.CloseWebPanel(handle);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,12 +128,11 @@ internal sealed class ServerWebPanel
|
|||
|
||||
/// <summary>
|
||||
/// Opens <paramref name="r"/> in the panel. <paramref name="then"/> gets the answer exactly once: now
|
||||
/// for a refusal, else later from Poll, Close or a newer Open. A newer Open answers the older one Closed.
|
||||
/// for a refusal, else later from Poll, Close or a newer Open. A newer Open that the engine queued
|
||||
/// answers the older one Closed (the engine superseded it); a refused one leaves the older one waiting.
|
||||
/// </summary>
|
||||
public void Open(WebOpenRequest r, long nowMs, Action<PanelResult> then)
|
||||
{
|
||||
Answer(Interlocked.Exchange(ref _waiting, null), PanelResult.Closed);
|
||||
|
||||
int code;
|
||||
try
|
||||
{
|
||||
|
|
@ -152,7 +151,7 @@ internal sealed class ServerWebPanel
|
|||
return;
|
||||
}
|
||||
Interlocked.Exchange(ref _handle, code);
|
||||
Interlocked.Exchange(ref _waiting, new WaitingOpen(code, nowMs + PollTimeoutMs, then));
|
||||
Answer(Interlocked.Exchange(ref _waiting, new WaitingOpen(code, nowMs + PollTimeoutMs, then)), PanelResult.Closed);
|
||||
}
|
||||
|
||||
/// <summary>The tick: answers the waiting open once its state decides, or at the timeout.</summary>
|
||||
|
|
@ -200,4 +199,4 @@ internal sealed class ServerWebPanel
|
|||
try { then(result); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue