Skip to content

Commit

Permalink
SetCacheEnable and WaitFor test updates (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Mar 7, 2019
1 parent f4f0a2e commit bddf0fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/PuppeteerSharp.Tests/FrameTests/WaitForFunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public async Task ShouldWorkWithStrictCSPPolicy()
{
Server.SetCSP("/empty.html", "script-src " + TestConstants.ServerUrl);
await Page.GoToAsync(TestConstants.EmptyPage);
var watchdog = Page.WaitForFunctionAsync("() => window.__FOO === 'hit'", new WaitForFunctionOptions
{
Polling = WaitForFunctionPollingOption.Raf
});
await Page.EvaluateExpressionAsync("window.__FOO = 'hit'");
await watchdog;
await Task.WhenAll(
Page.WaitForFunctionAsync("() => window.__FOO === 'hit'", new WaitForFunctionOptions
{
Polling = WaitForFunctionPollingOption.Raf
}),
Page.EvaluateExpressionAsync("window.__FOO = 'hit'"));
}

[Fact]
Expand Down
6 changes: 5 additions & 1 deletion lib/PuppeteerSharp.Tests/FrameTests/WaitForSelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public async Task ShouldWorkWithRemovedMutationObserver()
{
await Page.EvaluateExpressionAsync("delete window.MutationObserver");
var waitForSelector = Page.WaitForSelectorAsync(".zombo");
await Page.SetContentAsync("<div class='zombo'>anything</div>");

await Task.WhenAll(
waitForSelector,
Page.SetContentAsync("<div class='zombo'>anything</div>"));

Assert.Equal("anything", await Page.EvaluateFunctionAsync<string>("x => x.textContent", await waitForSelector));
}

Expand Down
5 changes: 2 additions & 3 deletions lib/PuppeteerSharp.Tests/PageTests/SetCacheEnabledTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ public async Task ShouldEnableOrDisableTheCacheBasedOnTheStatePassed()
var responses = new Dictionary<string, Response>();
Page.Response += (sender, e) => responses[e.Response.Url.Split('/').Last()] = e.Response;

await Page.GoToAsync(TestConstants.ServerUrl + "/cached/one-style.html",
waitUntil: new[] { WaitUntilNavigation.Networkidle2 });
await Page.ReloadAsync(waitUntil: new[] { WaitUntilNavigation.Networkidle2 });
await Page.GoToAsync(TestConstants.ServerUrl + "/cached/one-style.html");
await Page.ReloadAsync();
Assert.True(responses["one-style.css"].FromCache);

await Page.SetCacheEnabledAsync(false);
Expand Down

0 comments on commit bddf0fc

Please sign in to comment.