|
| 1 | +using System.Threading.Tasks; |
| 2 | +using PuppeteerSharp.Tests.Attributes; |
| 3 | +using Xunit; |
| 4 | +using Xunit.Abstractions; |
| 5 | + |
| 6 | +namespace PuppeteerSharp.Tests.Issues |
| 7 | +{ |
| 8 | + [Collection(TestConstants.TestFixtureCollectionName)] |
| 9 | + public class Issue1878 : PuppeteerBrowserContextBaseTest |
| 10 | + { |
| 11 | + public Issue1878(ITestOutputHelper output) : base(output) |
| 12 | + { |
| 13 | + } |
| 14 | + |
| 15 | + [PuppeteerFact] |
| 16 | + public async Task MultiplePagesShouldNotShareSameScreenshotTaskQueue() |
| 17 | + { |
| 18 | + // 1st page |
| 19 | + using (Page page = await Context.NewPageAsync()) |
| 20 | + { |
| 21 | + var html = "...some html.."; |
| 22 | + await page.GoToAsync($"data:text/html,{html}", new NavigationOptions |
| 23 | + { |
| 24 | + WaitUntil = new[] |
| 25 | + { |
| 26 | + WaitUntilNavigation.DOMContentLoaded, |
| 27 | + WaitUntilNavigation.Load, |
| 28 | + WaitUntilNavigation.Networkidle0, |
| 29 | + WaitUntilNavigation.Networkidle2 |
| 30 | + } |
| 31 | + }); |
| 32 | + |
| 33 | + await page.ScreenshotAsync("...some path..."); |
| 34 | + } |
| 35 | + |
| 36 | + //2nd page |
| 37 | + using (Page page = await Context.NewPageAsync()) |
| 38 | + { |
| 39 | + var html = "...some html..."; |
| 40 | + await page.GoToAsync($"data:text/html,{html}", new NavigationOptions |
| 41 | + { |
| 42 | + WaitUntil = new[] |
| 43 | + { |
| 44 | + WaitUntilNavigation.DOMContentLoaded, |
| 45 | + WaitUntilNavigation.Load, |
| 46 | + WaitUntilNavigation.Networkidle0, |
| 47 | + WaitUntilNavigation.Networkidle2 |
| 48 | + } |
| 49 | + }); |
| 50 | + |
| 51 | + await page.ScreenshotAsync("...some path..."); //<- will throw because Browser TaskQueue is disposed when 1st Page is disposed |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments