-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abort page.waitForRequest/Response when page closes (#1290)
* Abort page.waitForRequest/Response when page closes * cr * cr
- Loading branch information
Showing
3 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
lib/PuppeteerSharp.Tests/PuppeteerTests/BrowserCloseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace PuppeteerSharp.Tests.BrowserTests.Events | ||
{ | ||
[Collection(TestConstants.TestFixtureCollectionName)] | ||
public class BrowserCloseTests : PuppeteerBrowserBaseTest | ||
{ | ||
public BrowserCloseTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task ShouldTerminateNetworkWaiters() | ||
{ | ||
using (var browser = await Puppeteer.LaunchAsync(TestConstants.DefaultBrowserOptions())) | ||
using (var remote = await Puppeteer.ConnectAsync(new ConnectOptions { BrowserWSEndpoint = browser.WebSocketEndpoint })) | ||
{ | ||
var newPage = await remote.NewPageAsync(); | ||
var requestTask = newPage.WaitForRequestAsync(TestConstants.EmptyPage); | ||
var responseTask = newPage.WaitForResponseAsync(TestConstants.EmptyPage); | ||
|
||
await browser.CloseAsync(); | ||
|
||
var exception = await Assert.ThrowsAsync<TargetClosedException>(() => requestTask); | ||
Assert.Contains("Target closed", exception.Message); | ||
Assert.DoesNotContain("Timeout", exception.Message); | ||
|
||
exception = await Assert.ThrowsAsync<TargetClosedException>(() => responseTask); | ||
Assert.Contains("Target closed", exception.Message); | ||
Assert.DoesNotContain("Timeout", exception.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters