Skip to content

Commit cc42ae6

Browse files
authored
Add missing oopif tests (#1979)
* Add missing oopif tests * Some progress * tests implemented * code factor * Improve some tests * Add more timeouts * Add extra withTimeouts * Unique ports * cr * Add more timeouts * change docs * Fix screenshot * Is this how you debug a test in CI? * Timeout the dispose * Improve one test * Ignore one test * Skip another test * undo changes * Remove nunit warning * Ignore another test * self cr
1 parent b741fb3 commit cc42ae6

25 files changed

+926
-217
lines changed

lib/.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ csharp_space_between_square_brackets = false
148148
# Analyzers
149149
dotnet_code_quality.ca1802.api_surface = private, internal
150150

151-
# C++ Files
151+
# C++ Files
152+
153+
# Default severity for analyzer diagnostics with category 'Usage'
154+
dotnet_analyzer_diagnostic.category-Usage.severity = none
155+
152156
[*.{cpp,h,in}]
153157
curly_bracket_next_line = true
154158
indent_brace_style = Allman

lib/PuppeteerSharp.TestServer/wwwroot/dynamic-oopif.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const iframe = document.createElement('iframe');
44
const url = new URL(location.href);
55
url.hostname = url.hostname === 'localhost' ? '127.0.0.1' : 'localhost';
6-
url.pathname = '/grid.html';
6+
url.pathname = '/oopif.html';
77
iframe.src = url.toString();
88
document.body.appendChild(iframe);
99
}, false);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
window.addEventListener('DOMContentLoaded', () => {
3+
const iframe = document.createElement('iframe');
4+
const url = new URL(location.href);
5+
url.hostname = 'inner-frame2.test';
6+
url.pathname = '/inner-frame2.html';
7+
iframe.src = url.toString();
8+
document.body.appendChild(iframe);
9+
}, false);
10+
</script>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<button>click</button>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<iframe width="100%" height="300" src="about:blank"></iframe>
2+
<div style="height: 800vh"></div>
3+
<iframe width="100%" height="300" src='http://www.example.com' loading="lazy"></iframe>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
window.addEventListener('DOMContentLoaded', () => {
3+
const iframe = document.createElement('iframe');
4+
const url = new URL(location.href);
5+
url.hostname = 'inner-frame1.test';
6+
url.pathname = '/inner-frame1.html';
7+
iframe.src = url.toString();
8+
document.body.appendChild(iframe);
9+
}, false);
10+
</script>

lib/PuppeteerSharp.Tests/FrameUtils.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ namespace PuppeteerSharp.Tests
66
{
77
public static class FrameUtils
88
{
9-
public static async Task<Frame> AttachFrameAsync(Page page, string frameId, string url)
9+
public static Task<Frame> AttachFrameAsync(Page page, string frameId, string url)
10+
=> AttachFrameAsync(page.MainFrame, frameId, url);
11+
12+
public static async Task<Frame> AttachFrameAsync(Frame frame, string frameId, string url)
1013
{
11-
var handle = (ElementHandle)await page.EvaluateFunctionHandleAsync(@" async (frameId, url) => {
14+
var handle = (ElementHandle)await frame.EvaluateFunctionHandleAsync(@" async (frameId, url) => {
1215
const frame = document.createElement('iframe');
1316
frame.src = url;
1417
frame.id = frameId;
@@ -19,13 +22,14 @@ public static async Task<Frame> AttachFrameAsync(Page page, string frameId, stri
1922
return await handle.ContentFrameAsync();
2023
}
2124

22-
public static async Task DetachFrameAsync(Page page, string frameId)
23-
{
24-
await page.EvaluateFunctionAsync(@"function detachFrame(frameId) {
25-
const frame = document.getElementById(frameId);
26-
frame.remove();
27-
}", frameId);
28-
}
25+
public static Task DetachFrameAsync(Page page, string frameId)
26+
=> DetachFrameAsync(page.MainFrame, frameId);
27+
28+
public static Task DetachFrameAsync(Frame frame, string frameId)
29+
=> frame.EvaluateFunctionAsync(@"function detachFrame(frameId) {
30+
const frame = document.getElementById(frameId);
31+
frame.remove();
32+
}", frameId);
2933

3034
public static IEnumerable<string> DumpFrames(Frame frame, string indentation = "")
3135
{
@@ -43,9 +47,12 @@ public static IEnumerable<string> DumpFrames(Frame frame, string indentation = "
4347
return result;
4448
}
4549

46-
internal static async Task NavigateFrameAsync(Page page, string frameId, string url)
50+
internal static Task NavigateFrameAsync(Page page, string frameId, string url)
51+
=> NavigateFrameAsync(page.MainFrame, frameId, url);
52+
53+
internal static async Task NavigateFrameAsync(Frame frame, string frameId, string url)
4754
{
48-
await page.EvaluateFunctionAsync(@"function navigateFrame(frameId, url) {
55+
await frame.EvaluateFunctionAsync(@"function navigateFrame(frameId, url) {
4956
const frame = document.getElementById(frameId);
5057
frame.src = url;
5158
return new Promise(x => frame.onload = x);

0 commit comments

Comments
 (0)