Skip to content

Commit c4a9fa4

Browse files
authored
Bidi frame spec (#2975)
* Bidi implement frame tests * Apply suggestion from @kblok * fix * remove flaky code * fix * ignore some
1 parent cc93375 commit c4a9fa4

File tree

25 files changed

+136
-105
lines changed

25 files changed

+136
-105
lines changed

lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json

Lines changed: 24 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -330,21 +330,6 @@
330330
"FAIL"
331331
]
332332
},
333-
{
334-
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
335-
"testIdPattern": "[crash] *",
336-
"platforms": [
337-
"darwin",
338-
"linux",
339-
"win32"
340-
],
341-
"parameters": [
342-
"webDriverBiDi"
343-
],
344-
"expectations": [
345-
"FAIL"
346-
]
347-
},
348333
{
349334
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
350335
"testIdPattern": "[defaultbrowsercontext.spec] *",
@@ -375,51 +360,6 @@
375360
"FAIL"
376361
]
377362
},
378-
{
379-
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
380-
"testIdPattern": "[device-request-prompt.spec] *",
381-
"platforms": [
382-
"darwin",
383-
"linux",
384-
"win32"
385-
],
386-
"parameters": [
387-
"webDriverBiDi"
388-
],
389-
"expectations": [
390-
"FAIL"
391-
]
392-
},
393-
{
394-
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
395-
"testIdPattern": "[diffstyle] *",
396-
"platforms": [
397-
"darwin",
398-
"linux",
399-
"win32"
400-
],
401-
"parameters": [
402-
"webDriverBiDi"
403-
],
404-
"expectations": [
405-
"FAIL"
406-
]
407-
},
408-
{
409-
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
410-
"testIdPattern": "[drag-and-drop.spec] *",
411-
"platforms": [
412-
"darwin",
413-
"linux",
414-
"win32"
415-
],
416-
"parameters": [
417-
"webDriverBiDi"
418-
],
419-
"expectations": [
420-
"FAIL"
421-
]
422-
},
423363
{
424364
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
425365
"testIdPattern": "[elementhandle.spec] *",
@@ -767,7 +707,7 @@
767707
},
768708
{
769709
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
770-
"testIdPattern": "[frame.spec] *",
710+
"testIdPattern": "[acceptInsecureCerts.spec] *",
771711
"platforms": [
772712
"darwin",
773713
"linux",
@@ -782,7 +722,7 @@
782722
},
783723
{
784724
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
785-
"testIdPattern": "[acceptInsecureCerts.spec] *",
725+
"testIdPattern": "[injected.spec] *",
786726
"platforms": [
787727
"darwin",
788728
"linux",
@@ -797,7 +737,7 @@
797737
},
798738
{
799739
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
800-
"testIdPattern": "[injected.spec] *",
740+
"testIdPattern": "[input.spec] *",
801741
"platforms": [
802742
"darwin",
803743
"linux",
@@ -812,7 +752,7 @@
812752
},
813753
{
814754
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
815-
"testIdPattern": "[input.spec] *",
755+
"testIdPattern": "[jshandle.spec] *.clickablePoint*",
816756
"platforms": [
817757
"darwin",
818758
"linux",
@@ -827,7 +767,7 @@
827767
},
828768
{
829769
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
830-
"testIdPattern": "[jshandle.spec] *.clickablePoint*",
770+
"testIdPattern": "[jshandle.spec] *getProperties*",
831771
"platforms": [
832772
"darwin",
833773
"linux",
@@ -842,7 +782,7 @@
842782
},
843783
{
844784
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
845-
"testIdPattern": "[jshandle.spec] *getProperties*",
785+
"testIdPattern": "[jshandle.spec] *.getProperty*",
846786
"platforms": [
847787
"darwin",
848788
"linux",
@@ -857,7 +797,7 @@
857797
},
858798
{
859799
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
860-
"testIdPattern": "[jshandle.spec] *.getProperty*",
800+
"testIdPattern": "[jshandle.spec] *.jsonValue*",
861801
"platforms": [
862802
"darwin",
863803
"linux",
@@ -872,7 +812,7 @@
872812
},
873813
{
874814
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
875-
"testIdPattern": "[jshandle.spec] *.jsonValue*",
815+
"testIdPattern": "[jshandle.spec] *.evaluateHandle*",
876816
"platforms": [
877817
"darwin",
878818
"linux",
@@ -887,7 +827,22 @@
887827
},
888828
{
889829
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
890-
"testIdPattern": "[jshandle.spec] *.evaluateHandle*",
830+
"testIdPattern": "[frame.spec] Frame.evaluate *",
831+
"platforms": [
832+
"darwin",
833+
"linux",
834+
"win32"
835+
],
836+
"parameters": [
837+
"webDriverBiDi"
838+
],
839+
"expectations": [
840+
"FAIL"
841+
]
842+
},
843+
{
844+
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
845+
"testIdPattern": "[frame.spec] Frame specs Frame Management *",
891846
"platforms": [
892847
"darwin",
893848
"linux",

lib/PuppeteerSharp.Tests/AriaQueryHandlerTests/WaitForSelectorAriaTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public async Task PageWaitForSelectorIsShortcutForMainFrame()
108108
{
109109
await Page.GoToAsync(TestConstants.EmptyPage);
110110
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
111-
var otherFrame = Page.FirstChildFrame();
111+
var otherFrame = await Page.FirstChildFrameAsync();
112112
var watchdog = Page.WaitForSelectorAsync("aria/[role=\"button\"]");
113113
await otherFrame.EvaluateFunctionAsync(AddElement, "button");
114114
await Page.EvaluateFunctionAsync(AddElement, "button");

lib/PuppeteerSharp.Tests/ClickTests/ClickTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public async Task ShouldClickTheButtonInsideAnIframe()
334334
await Page.GoToAsync(TestConstants.EmptyPage);
335335
await Page.SetContentAsync("<div style=\"width:100px;height:100px\">spacer</div>");
336336
await FrameUtils.AttachFrameAsync(Page, "button-test", TestConstants.ServerUrl + "/input/button.html");
337-
var frame = Page.FirstChildFrame();
337+
var frame = await Page.FirstChildFrameAsync();
338338
var button = await frame.QuerySelectorAsync("button");
339339
await button.ClickAsync();
340340
Assert.That(await frame.EvaluateExpressionAsync<string>("window.result"), Is.EqualTo("Clicked"));
@@ -352,7 +352,7 @@ await Page.SetViewportAsync(new ViewPortOptions
352352
});
353353
await Page.SetContentAsync("<div style=\"width:100px;height:2000px\">spacer</div>");
354354
await FrameUtils.AttachFrameAsync(Page, "button-test", TestConstants.ServerUrl + "/input/button.html");
355-
var frame = Page.FirstChildFrame();
355+
var frame = await Page.FirstChildFrameAsync();
356356
await frame.QuerySelectorAsync("button").EvaluateFunctionAsync("button => button.style.setProperty('position', 'fixed')");
357357
await frame.ClickAsync("button");
358358
Assert.That(await frame.EvaluateExpressionAsync<string>("window.result"), Is.EqualTo("Clicked"));
@@ -365,7 +365,7 @@ public async Task ShouldClickTheButtonWithDeviceScaleFactorSet()
365365
Assert.That(await Page.EvaluateExpressionAsync<int>("window.devicePixelRatio"), Is.EqualTo(5));
366366
await Page.SetContentAsync("<div style=\"width:100px;height:100px\">spacer</div>");
367367
await FrameUtils.AttachFrameAsync(Page, "button-test", TestConstants.ServerUrl + "/input/button.html");
368-
var frame = Page.FirstChildFrame();
368+
var frame = await Page.FirstChildFrameAsync();
369369
var button = await frame.QuerySelectorAsync("button");
370370
await button.ClickAsync();
371371
Assert.That(await frame.EvaluateExpressionAsync<string>("window.result"), Is.EqualTo("Clicked"));

lib/PuppeteerSharp.Tests/CookiesTests/SetCookiesTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ await Page.EvaluateFunctionAsync(@"src => {
309309
}", TestConstants.CrossProcessHttpPrefix);
310310
await Page.SetCookieAsync(new CookieParam { Name = "127-cookie", Value = "worst", Url = TestConstants.CrossProcessHttpPrefix });
311311
Assert.That(await Page.EvaluateExpressionAsync<string>("document.cookie"), Is.EqualTo("localhost-cookie=best"));
312-
Assert.That(await Page.FirstChildFrame().EvaluateExpressionAsync<string>("document.cookie"), Is.EqualTo(string.Empty));
312+
var frame = await Page.FirstChildFrameAsync();
313+
Assert.That(await frame.EvaluateExpressionAsync<string>("document.cookie"), Is.EqualTo(string.Empty));
313314
var cookies = await Page.GetCookiesAsync();
314315
Assert.That(cookies, Has.Exactly(1).Items);
315316
var cookie = cookies.First();
@@ -363,7 +364,8 @@ await page.SetCookieAsync(
363364
Url = TestConstants.CrossProcessHttpsPrefix + "/grid.html",
364365
SameSite = SameSite.None,
365366
});
366-
Assert.That(await page.FirstChildFrame().EvaluateExpressionAsync<string>("document.cookie"), Is.EqualTo("127-cookie=best"));
367+
var frame = await page.FirstChildFrameAsync();
368+
Assert.That(await frame.EvaluateExpressionAsync<string>("document.cookie"), Is.EqualTo("127-cookie=best"));
367369
var cookies = await page.GetCookiesAsync(TestConstants.CrossProcessHttpsPrefix + "/grid.html");
368370
Assert.That(cookies, Has.Exactly(1).Items);
369371
var cookie = cookies.First();

lib/PuppeteerSharp.Tests/ElementHandleTests/BoxModelTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ await Page.EvaluateExpressionAsync(@"
2222
`;");
2323

2424
// Step 2: Add div and position it absolutely inside frame.
25-
var frame = Page.FirstChildFrame();
25+
var frame = await Page.FirstChildFrameAsync();
2626
var divHandle = (IElementHandle)await frame.EvaluateFunctionHandleAsync(@"() => {
2727
const div = document.createElement('div');
2828
document.body.appendChild(div);

lib/PuppeteerSharp.Tests/ElementHandleTests/ContentFrameTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task ShouldWork()
2121
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
2222
var elementHandle = await Page.QuerySelectorAsync("#frame1");
2323
var frame = await elementHandle.ContentFrameAsync();
24-
Assert.That(frame, Is.EqualTo(Page.FirstChildFrame()));
24+
Assert.That(frame, Is.EqualTo(await Page.FirstChildFrameAsync()));
2525
}
2626

2727
[Test, PuppeteerTest("elementhandle.spec", "PuppeteerSharp", "should work headful")]
@@ -32,7 +32,7 @@ public async Task ShouldWorkHeadful()
3232
await page.GoToAsync($"{TestConstants.ServerUrl}/frame-example.html");
3333
var elementHandle = await page.QuerySelectorAsync("iframe");
3434
var frame = await elementHandle.ContentFrameAsync();
35-
Assert.That(frame, Is.EqualTo(page.FirstChildFrame()));
35+
Assert.That(frame, Is.EqualTo(await Page.FirstChildFrameAsync()));
3636
}
3737
}
3838
}

lib/PuppeteerSharp.Tests/EvaluationTests/FrameEvaluateTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public async Task ShouldHaveDifferentExecutionContexts()
1515
Assert.That(Page.Frames, Has.Length.EqualTo(2));
1616

1717
var frame1 = Page.MainFrame;
18-
var frame2 = Page.FirstChildFrame();
18+
var frame2 = await Page.FirstChildFrameAsync();
1919

2020
await frame1.EvaluateExpressionAsync("window.FOO = 'foo'");
2121
await frame2.EvaluateExpressionAsync("window.FOO = 'bar'");
@@ -31,7 +31,7 @@ public async Task ShouldHaveCorrectExecutionContexts()
3131
Assert.That(Page.Frames, Has.Length.EqualTo(2));
3232

3333
var frame1 = Page.MainFrame;
34-
var frame2 = Page.FirstChildFrame();
34+
var frame2 = await Page.FirstChildFrameAsync();
3535

3636
Assert.That(await frame1.EvaluateExpressionAsync<string>("document.body.textContent.trim()"), Is.EqualTo(""));
3737
Assert.That(await frame2.EvaluateExpressionAsync<string>("document.body.textContent.trim()"), Is.EqualTo("Hi, I'm frame"));

lib/PuppeteerSharp.Tests/EvaluationTests/PageEvaluateTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public async Task ShouldThrowIfUnderlyingElementWasDisposed()
264264
public async Task ShouldThrowIfElementHandlesAreFromOtherFrames()
265265
{
266266
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
267-
var bodyHandle = await Page.FirstChildFrame().QuerySelectorAsync("body");
267+
var frame = await Page.FirstChildFrameAsync();
268+
var bodyHandle = await frame.QuerySelectorAsync("body");
268269
var exception = Assert.ThrowsAsync<PuppeteerException>(()
269270
=> Page.EvaluateFunctionAsync<string>("body => body.innerHTML", bodyHandle));
270271
Assert.That(exception.Message, Does.Contain("JSHandles can be evaluated only in the context they were created"));

lib/PuppeteerSharp.Tests/FrameTests/FrameEvaluateTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ namespace PuppeteerSharp.Tests.FrameTests
66
{
77
public class FrameEvaluateTests : PuppeteerPageBaseTest
88
{
9-
public FrameEvaluateTests() : base()
10-
{
11-
}
12-
139
[Test, PuppeteerTest("frame.spec", "Frame.evaluate", "should throw for detached frames")]
1410
public async Task ShouldThrowForDetachedFrames()
1511
{
1612
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
17-
var frame = Page.FirstChildFrame();
13+
var frame = await Page.FirstChildFrameAsync();
1814
await FrameUtils.DetachFrameAsync(Page, "frame1");
1915
var exception = Assert.ThrowsAsync<PuppeteerException>(
2016
() => frame.EvaluateExpressionAsync("5 * 8"));

lib/PuppeteerSharp.Tests/FrameTests/FrameManagementTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public async Task ShouldReturnUrlFragmentAsPartOfUrl()
6565
{
6666
await Page.GoToAsync(TestConstants.ServerUrl + "/frames/one-frame-url-fragment.html");
6767
Assert.That(Page.Frames, Has.Length.EqualTo(2));
68-
Assert.That(Page.FirstChildFrame().Url, Is.EqualTo(TestConstants.ServerUrl + "/frames/frame.html?param=value#fragment"));
68+
var frame = await Page.FirstChildFrameAsync();
69+
Assert.That(frame.Url, Is.EqualTo(TestConstants.ServerUrl + "/frames/frame.html?param=value#fragment"));
6970
}
7071

7172
[Test, PuppeteerTest("frame.spec", "Frame specs Frame Management", "should persist mainFrame on cross-process navigation")]

0 commit comments

Comments
 (0)