public async Task ShouldWorkWhenSubframeIssuesWindowStop() { //This test is slightly different from the one in PW because of .NET Threads (or thanks to .NET Threads) var framesNavigated = new List <IFrame>(); IFrame frame = null; var frameAttachedTaskSource = new TaskCompletionSource <IFrame>(); Page.FrameAttached += (sender, e) => { frameAttachedTaskSource.SetResult(e.Frame); }; var frameNavigatedTaskSource = new TaskCompletionSource <bool>(); Page.FrameNavigated += (sender, e) => { if (frame != null) { if (e.Frame == frame) { frameNavigatedTaskSource.TrySetResult(true); } } else { framesNavigated.Add(frame); } }; Server.SetRoute("/frames/style.css", (context) => Task.CompletedTask); var navigationTask = Page.GoToAsync(TestConstants.ServerUrl + "/frames/one-frame.html"); frame = await frameAttachedTaskSource.Task; if (framesNavigated.Contains(frame)) { frameNavigatedTaskSource.TrySetResult(true); } await frameNavigatedTaskSource.Task; await Task.WhenAll( frame.EvaluateAsync("() => window.stop()"), navigationTask ); }
private async Task GiveItTimeToLogAsync(IFrame frame) { await frame.EvaluateAsync("() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))"); await frame.EvaluateAsync("() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))"); }