Updating build to https://github.com/mono/mono/commit/ae8e4b5b044 (#21034)
This commit is contained in:
parent
6c23730fa8
commit
2612ec89b2
|
|
@ -19,12 +19,21 @@ namespace WebAssembly.Net.Debugging {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hashset treats 0 as unset
|
||||||
public override int GetHashCode ()
|
public override int GetHashCode ()
|
||||||
=> sessionId?.GetHashCode () ?? 0;
|
=> sessionId?.GetHashCode () ?? -1;
|
||||||
|
|
||||||
public override bool Equals (object obj)
|
public override bool Equals (object obj)
|
||||||
=> (obj is SessionId) ? ((SessionId) obj).sessionId == sessionId : false;
|
=> (obj is SessionId) ? ((SessionId) obj).sessionId == sessionId : false;
|
||||||
|
|
||||||
|
public static bool operator == (SessionId a, SessionId b)
|
||||||
|
=> a.sessionId == b.sessionId;
|
||||||
|
|
||||||
|
public static bool operator != (SessionId a, SessionId b)
|
||||||
|
=> a.sessionId != b.sessionId;
|
||||||
|
|
||||||
|
public static SessionId Null { get; } = new SessionId ();
|
||||||
|
|
||||||
public override string ToString ()
|
public override string ToString ()
|
||||||
=> $"session-{sessionId}";
|
=> $"session-{sessionId}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,12 @@ using Microsoft.CodeAnalysis;
|
||||||
namespace WebAssembly.Net.Debugging {
|
namespace WebAssembly.Net.Debugging {
|
||||||
|
|
||||||
internal class MonoProxy : DevToolsProxy {
|
internal class MonoProxy : DevToolsProxy {
|
||||||
|
HashSet<SessionId> sessions = new HashSet<SessionId> ();
|
||||||
Dictionary<SessionId, ExecutionContext> contexts = new Dictionary<SessionId, ExecutionContext> ();
|
Dictionary<SessionId, ExecutionContext> contexts = new Dictionary<SessionId, ExecutionContext> ();
|
||||||
|
|
||||||
public MonoProxy (ILoggerFactory loggerFactory) : base(loggerFactory) { }
|
public MonoProxy (ILoggerFactory loggerFactory, bool hideWebDriver = true) : base(loggerFactory) { }
|
||||||
|
|
||||||
|
readonly bool hideWebDriver;
|
||||||
|
|
||||||
internal ExecutionContext GetContext (SessionId sessionId)
|
internal ExecutionContext GetContext (SessionId sessionId)
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +79,7 @@ namespace WebAssembly.Net.Debugging {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Debugger.scriptParsed":{
|
case "Debugger.scriptParsed": {
|
||||||
var url = args? ["url"]?.Value<string> () ?? "";
|
var url = args? ["url"]?.Value<string> () ?? "";
|
||||||
|
|
||||||
switch (url) {
|
switch (url) {
|
||||||
|
|
@ -89,7 +92,15 @@ namespace WebAssembly.Net.Debugging {
|
||||||
Log ("verbose", $"proxying Debugger.scriptParsed ({sessionId.sessionId}) {url} {args}");
|
Log ("verbose", $"proxying Debugger.scriptParsed ({sessionId.sessionId}) {url} {args}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "Target.attachedToTarget": {
|
||||||
|
if (args["targetInfo"]["type"]?.ToString() == "page")
|
||||||
|
await DeleteWebDriver (new SessionId (args["sessionId"]?.ToString ()), token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,10 +114,21 @@ namespace WebAssembly.Net.Debugging {
|
||||||
|
|
||||||
protected override async Task<bool> AcceptCommand (MessageId id, string method, JObject args, CancellationToken token)
|
protected override async Task<bool> AcceptCommand (MessageId id, string method, JObject args, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
// Inspector doesn't use the Target domain or sessions
|
||||||
|
// so we try to init immediately
|
||||||
|
if (hideWebDriver && id == SessionId.Null)
|
||||||
|
await DeleteWebDriver (id, token);
|
||||||
|
|
||||||
if (!contexts.TryGetValue (id, out var context))
|
if (!contexts.TryGetValue (id, out var context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
case "Target.attachToTarget": {
|
||||||
|
var resp = await SendCommand (id, method, args, token);
|
||||||
|
await DeleteWebDriver (new SessionId (resp.Value ["sessionId"]?.ToString ()), token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "Debugger.enable": {
|
case "Debugger.enable": {
|
||||||
var resp = await SendCommand (id, method, args, token);
|
var resp = await SendCommand (id, method, args, token);
|
||||||
|
|
||||||
|
|
@ -914,5 +936,19 @@ namespace WebAssembly.Net.Debugging {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async Task DeleteWebDriver (SessionId sessionId, CancellationToken token)
|
||||||
|
{
|
||||||
|
// see https://github.com/mono/mono/issues/19549 for background
|
||||||
|
if (hideWebDriver && sessions.Add (sessionId)) {
|
||||||
|
var res = await SendCommand (sessionId,
|
||||||
|
"Page.addScriptToEvaluateOnNewDocument",
|
||||||
|
JObject.FromObject (new { source = "delete navigator.constructor.prototype.webdriver"}),
|
||||||
|
token);
|
||||||
|
|
||||||
|
if (sessionId != SessionId.Null && !res.IsOk)
|
||||||
|
sessions.Remove (sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue