Skip to content

Commit f9d2a9f

Browse files
authored
Add missing CDPSession test (#2302)
1 parent 33334a7 commit f9d2a9f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/PuppeteerSharp.Tests/CDPSessionTests/CreateCDPSessionTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ public async Task ShouldBeAbleToDetachSession()
9292
StringAssert.Contains("Session closed.", exception.Message);
9393
}
9494

95+
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should not report created targets for custom CDP sessions")]
96+
[Skip(SkipAttribute.Targets.Firefox)]
97+
public async Task ShouldNotReportCreatedTArgetsForCustomCDPSessions()
98+
{
99+
var called = 0;
100+
async void EventHandler(object sender, TargetChangedArgs e)
101+
{
102+
called++;
103+
if (called > 1)
104+
{
105+
throw new Exception("Too many targets created");
106+
}
107+
108+
await e.Target.CreateCDPSessionAsync();
109+
}
110+
Page.BrowserContext.TargetCreated += EventHandler;
111+
await Browser.NewPageAsync();
112+
Page.BrowserContext.TargetCreated -= EventHandler;
113+
}
114+
95115
[PuppeteerTest("CDPSession.spec.ts", "Target.createCDPSession", "should throw nice errors")]
96116
[Skip(SkipAttribute.Targets.Firefox)]
97117
public async Task ShouldThrowNiceErrors()

0 commit comments

Comments
 (0)