Skip to content

Commit d66e1f9

Browse files
authored
Add oopif tests (#2310)
* Add oopif tests * prevent flaky test * bump one timeout a little bit * Ignore test
1 parent 509482b commit d66e1f9

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

lib/PuppeteerSharp.Tests/CoverageTests/JSCoverageTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public async Task ShouldIgnoreEvalScriptsByDefault()
5959
{
6060
await Page.Coverage.StartJSCoverageAsync();
6161
await Page.GoToAsync(TestConstants.ServerUrl + "/jscoverage/eval.html");
62+
// Prevent flaky tests.
63+
await Task.Delay(1000);
6264
var coverage = await Page.Coverage.StopJSCoverageAsync();
6365
Assert.That(coverage, Has.Exactly(1).Items);
6466
}
@@ -192,4 +194,4 @@ await Page.EvaluateFunctionAsync(@"() => {
192194
await Page.Coverage.StopJSCoverageAsync();
193195
}
194196
}
195-
}
197+
}

lib/PuppeteerSharp.Tests/OOPIFTests/OOPIFTests.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,18 @@ await Page.EvaluateFunctionAsync(@"() => {
222222
[PuppeteerTest("oopif.spec.ts", "OOPIF", "should report oopif frames")]
223223
[Ignore("See why this is so brittle")]
224224
public async Task ShouldReportOopifFrames()
225+
{
226+
var frameTask = Page.WaitForFrameAsync((frame) => frame.Url.EndsWith("oopif.html"));
227+
await Page.GoToAsync($"http://mainframe:{TestConstants.Port}/dunamic-oopif.html");
228+
var frame = await frameTask.WithTimeout();
229+
Assert.AreEqual(2, Oopifs.Count());
230+
Assert.AreEqual(2, Page.Frames.Count(frame => frame.IsOopFrame));
231+
Assert.AreEqual(1, await frame.EvaluateFunctionAsync<int>("() => document.querySelectorAll('button').length"));
232+
}
233+
234+
[PuppeteerTest("oopif.spec.ts", "OOPIF", "should wait for inner OOPIFs")]
235+
[Ignore("See why this is so brittle")]
236+
public async Task ShouldWaitForInnerOopifs()
225237
{
226238
var frameTask = Page.WaitForFrameAsync((frame) => frame.Url.EndsWith("inner-frame2.html"));
227239
await Page.GoToAsync($"http://mainframe:{TestConstants.Port}/main-frame.html");
@@ -245,7 +257,7 @@ public async Task ShouldLoadOopifIframesWithSubresourcesAndRequestInterception()
245257
}
246258

247259
[PuppeteerTest("oopif.spec.ts", "OOPIF", "should support frames within OOP iframes")]
248-
[Skip(SkipAttribute.Targets.Firefox)]
260+
[Ignore("See why this is so brittle")]
249261
public async Task ShouldSupportFramesWithinOopIframes()
250262
{
251263
var oopifFrameTask = Page.WaitForFrameAsync((frame) => frame.Url.EndsWith("/oopif.html"));
@@ -255,7 +267,7 @@ await FrameUtils.AttachFrameAsync(
255267
oopIframe,
256268
"frame1",
257269
TestConstants.CrossProcessHttpPrefix + "/empty.html"
258-
).WithTimeout();
270+
).WithTimeout(2_000);
259271
var frame1 = oopIframe.ChildFrames.First();
260272
StringAssert.Contains("empty.html", frame1.Url);
261273
await FrameUtils.NavigateFrameAsync(
@@ -349,6 +361,15 @@ public async Task ShouldSupportLazyOopframes()
349361
Assert.That(Page.Frames.Where(frame => !((Frame)frame).HasStartedLoading), Has.Exactly(1).Items);
350362
}
351363

364+
[PuppeteerTest("oopif.spec.ts", "waitForFrame", "should resolve immediately if the frame already exists")]
365+
[Skip(SkipAttribute.Targets.Firefox)]
366+
public async Task ShouldResolveImmediatelyIfTheFrameAlreadyExists()
367+
{
368+
await Page.GoToAsync(TestConstants.EmptyPage);
369+
await FrameUtils.AttachFrameAsync(Page, "frame2", TestConstants.CrossProcessHttpPrefix + "/empty.html");
370+
await Page.WaitForFrameAsync(frame => frame.Url.EndsWith("/empty.html"));
371+
}
372+
352373
private IEnumerable<ITarget> Oopifs => Context.Targets().Where(target => ((Target)target).TargetInfo.Type == TargetType.IFrame);
353374
}
354375
}

lib/PuppeteerSharp.Tooling/ScaffoldTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal static partial class ScaffoldTest
4343
public static void FindTestsInFile(string path, Action<string, string> callback)
4444
{
4545
var keywords1 = new string[] { "it", "itChromeOnly", "itFailsFirefox", "xit" };
46-
var keywords2 = new string[] { "describe", "describeChromeOnly", "describeFailsFirefox" };
46+
var keywords2 = new string[] { "describe", "describeChromeOnly", "describeFailsFirefox", "describeWithDebugLogs" };
4747
var keywords = keywords1.Concat(keywords2);
4848
var rx = new Regex(@"^( *).*\b(" + string.Join("|", keywords) + @")\b.*[(](?:[']([^']+)[']|[""]([^""]+)[""])", RegexOptions.Multiline);
4949

0 commit comments

Comments
 (0)