コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
ファイル: Support.cs プロジェクト: vivedu-lxzhai/mono
        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);
                }
            }
        }