public DebugTestContext(InspectorClient cli, Inspector insp, CancellationToken token, Dictionary <string, string> scripts) { this.cli = cli; this.insp = insp; this.token = token; this.scripts = scripts; }
public async Task Ready(Func <InspectorClient, CancellationToken, Task> cb = null, TimeSpan?span = null) { using (var cts = new CancellationTokenSource()) { cts.CancelAfter(span?.Milliseconds ?? 60 * 1000); //tests have 1 minute to complete by default var uri = new Uri($"ws://{TestHarnessProxy.Endpoint.Authority}/launch-chrome-and-connect"); using var loggerFactory = LoggerFactory.Create( builder => builder.AddConsole().AddFilter(null, LogLevel.Information)); using (var client = new InspectorClient(loggerFactory.CreateLogger <Inspector>())) { await client.Connect(uri, OnMessage, async token => { Task[] init_cmds = { client.SendCommand("Profiler.enable", null, token), client.SendCommand("Runtime.enable", null, token), client.SendCommand("Debugger.enable", null, token), client.SendCommand("Runtime.runIfWaitingForDebugger", null, token), WaitFor(READY), }; // await Task.WhenAll (init_cmds); Console.WriteLine("waiting for the runtime to be ready"); await init_cmds[4]; Console.WriteLine("runtime ready, TEST TIME"); if (cb != null) { Console.WriteLine("await cb(client, token)"); await cb(client, token); } }, cts.Token); await client.Close(cts.Token); } } }
public async Task Ready(Func <InspectorClient, CancellationToken, Task> cb = null) { using (var cts = new CancellationTokenSource()) { cts.CancelAfter(60 * 1000); //tests have 1 minute to complete var uri = new Uri("ws://localhost:9300/launch-chrome-and-connect"); using (var client = new InspectorClient()) { await client.Connect(uri, OnMessage, async token => { Task[] init_cmds = new Task [] { client.SendCommand("Profiler.enable", null, token), client.SendCommand("Runtime.enable", null, token), client.SendCommand("Debugger.enable", null, token), client.SendCommand("Runtime.runIfWaitingForDebugger", null, token), WaitFor(READY), }; // await Task.WhenAll (init_cmds); Console.WriteLine("waiting for the runtime to be ready"); await init_cmds[4]; Console.WriteLine("runtime ready, TEST TIME"); if (cb != null) { Console.WriteLine("await cb(client, token)"); await cb(client, token); } }, cts.Token); await client.Close(cts.Token); } } }
public DebuggerTestBase(string driver = "debugger-driver.html") { insp = new Inspector(); cli = insp.Client; scripts = SubscribeToScripts(insp); startTask = TestHarnessProxy.Start(FindChromePath(), DebuggerTestAppPath, driver); }
public Inspector() { _cancellationTokenSource = new CancellationTokenSource(); Token = _cancellationTokenSource.Token; _loggerFactory = LoggerFactory.Create( builder => builder.AddConsole().AddFilter(null, LogLevel.Trace)); Client = new InspectorClient(_loggerFactory.CreateLogger <InspectorClient>()); _logger = _loggerFactory.CreateLogger <Inspector>(); }
public DebuggerTestBase(string driver = "debugger-driver.html") { // the debugger is working in locale of the debugged application. For example Datetime.ToString() // we want the test to mach it. We are also starting chrome with --lang=en-US System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("en-US"); insp = new Inspector(); cli = insp.Client; scripts = SubscribeToScripts(insp); startTask = TestHarnessProxy.Start(FindChromePath(), DebuggerTestAppPath, driver); }