File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
lib/PuppeteerSharp.Tests/PuppeteerTests Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 11using System ;
2- using System . Collections . Generic ;
3- using System . Diagnostics ;
4- using System . IO ;
52using System . Linq ;
6- using System . Net ;
7- using System . Runtime . InteropServices ;
83using System . Threading . Tasks ;
94using PuppeteerSharp . Helpers ;
105using Xunit ;
@@ -110,6 +105,20 @@ await page.EvaluateFunctionHandleAsync(@"() => {
110105 }
111106 }
112107
108+ [ Fact ]
109+ public async Task ShouldCloseBrowserWithBeforeunloadPage ( )
110+ {
111+ var headfulOptions = TestConstants . DefaultBrowserOptions ( ) ;
112+ headfulOptions . Headless = false ;
113+ using ( var browser = await Puppeteer . LaunchAsync ( headfulOptions ) )
114+ using ( var page = await browser . NewPageAsync ( ) )
115+ {
116+ await page . GoToAsync ( TestConstants . ServerUrl + "/beforeunload.html" ) ;
117+ // We have to interact with a page so that 'beforeunload' handlers fire.
118+ await page . ClickAsync ( "body" ) ;
119+ }
120+ }
121+
113122 private Task < Target > WaitForBackgroundPageTargetAsync ( Browser browser )
114123 {
115124 var target = browser . Targets ( ) . FirstOrDefault ( t => t . Type == TargetType . BackgroundPage ) ;
You can’t perform that action at this time.
0 commit comments