Skip to content

Commit d0e3dd2

Browse files
authored
Bidi: Set request interception support (#3021)
* Bidi: Set request interception support * fix * fix * fix golden * fix shouldIntercept * fix * fix tests * fix test description * fix tests * Fix test * fix * fix * fix build * fix * fix * ignore some tests and simplify code
1 parent 57fbccb commit d0e3dd2

File tree

16 files changed

+748
-274
lines changed

16 files changed

+748
-274
lines changed

lib/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ BROWSER=FIREFOX PROTOCOL=bidi dotnet build PuppeteerSharp.Tests/PuppeteerSharp.T
410410

411411
You can switch between CDP and Bidi by changing the PuppeteerTestAttribute.IsCdp property.
412412
You can switch between Chrome and Firefox by changing the PuppeteerTestAttribute.IsChrome property.
413+
If you are fixing one single test, then you must run the entire test suite to confirm that you didn't break other tests.
413414

414415
## Utilities and Helpers
415416

lib/PuppeteerSharp.Nunit/PuppeteerTestAttribute.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,19 @@ private bool ShouldSkipByExpectation(Test test, out TestExpectation output)
124124
// Join local and upstream in one variable
125125
var allExpectations = localExpectations.Concat(upstreamExpectations).ToArray();
126126

127+
var testIdStr = ToString();
128+
127129
foreach (var expectation in allExpectations)
128130
{
129-
if (expectation.TestIdRegex.IsMatch(ToString()))
131+
if (expectation.TestIdRegex.IsMatch(testIdStr))
130132
{
131-
if (expectation.Platforms.Contains(currentExpectationPlatform) &&
132-
expectation.Parameters.All(parameters.Contains) &&
133-
(
134-
expectation.Expectations.Contains(TestExpectation.TestExpectationResult.Skip) ||
133+
var platformMatch = expectation.Platforms.Contains(currentExpectationPlatform);
134+
var paramsMatch = expectation.Parameters.All(parameters.Contains);
135+
var expMatch = expectation.Expectations.Contains(TestExpectation.TestExpectationResult.Skip) ||
135136
expectation.Expectations.Contains(TestExpectation.TestExpectationResult.Fail) ||
136-
expectation.Expectations.Contains(TestExpectation.TestExpectationResult.Timeout)))
137+
expectation.Expectations.Contains(TestExpectation.TestExpectationResult.Timeout);
138+
139+
if (platformMatch && paramsMatch && expMatch)
137140
{
138141
output = expectation;
139142
return true;

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
[
2+
{
3+
"comment": "Firefox BiDi sends duplicate beforeRequestSent events with different request IDs for speculative/parallel loading during navigation",
4+
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should be abortable",
5+
"platforms": ["darwin", "linux", "win32"],
6+
"parameters": ["firefox", "webDriverBiDi"],
7+
"expectations": ["FAIL"]
8+
},
9+
{
10+
"comment": "Firefox BiDi sends duplicate beforeRequestSent events with different request IDs for speculative/parallel loading during navigation",
11+
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with encoded server - 2",
12+
"platforms": ["darwin", "linux", "win32"],
13+
"parameters": ["firefox", "webDriverBiDi"],
14+
"expectations": ["FAIL"]
15+
},
16+
{
17+
"comment": "Firefox BiDi sends duplicate beforeRequestSent events with different request IDs for speculative/parallel loading during navigation",
18+
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with redirects for subresources",
19+
"platforms": ["darwin", "linux", "win32"],
20+
"parameters": ["firefox", "webDriverBiDi"],
21+
"expectations": ["FAIL"]
22+
},
223
{
324
"comment": "Test depends on ConnectAsync which is not implemented for BiDi yet - see [connect.spec] expectations",
425
"testIdPattern": "[browser.spec] Browser.isConnected should set the browser connected state",
@@ -1034,21 +1055,6 @@
10341055
"FAIL"
10351056
]
10361057
},
1037-
{
1038-
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
1039-
"testIdPattern": "[requestinterception.spec] *",
1040-
"platforms": [
1041-
"darwin",
1042-
"linux",
1043-
"win32"
1044-
],
1045-
"parameters": [
1046-
"webDriverBiDi"
1047-
],
1048-
"expectations": [
1049-
"FAIL"
1050-
]
1051-
},
10521058
{
10531059
"comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one",
10541060
"testIdPattern": "[target.spec] *",

lib/PuppeteerSharp.Tests/RequestInterceptionTests/SetRequestInterceptionTests.cs

Lines changed: 69 additions & 47 deletions
Large diffs are not rendered by default.
6.63 KB
Loading

lib/PuppeteerSharp.Tests/TestConstants.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ public static class TestConstants
1111
{
1212
public const int DebuggerAttachedTestTimeout = 300_000;
1313
public const int DefaultPuppeteerTimeout = 10_000;
14-
public const int Port = 8081;
14+
public const int Port = 7081;
1515
public const int HttpsPort = Port + 1;
16-
public const string ServerUrl = "http://localhost:8081";
17-
public const string ServerIpUrl = "http://127.0.0.1:8081";
18-
public const string HttpsPrefix = "https://localhost:8082";
16+
public const string ServerUrl = "http://localhost:7081";
17+
public const string ServerIpUrl = "http://127.0.0.1:7081";
18+
public const string HttpsPrefix = "https://localhost:7082";
1919
public const string AboutBlank = "about:blank";
20-
public static readonly string CrossProcessHttpPrefix = "http://127.0.0.1:8081";
21-
public static readonly string CrossProcessHttpsPrefix = "https://127.0.0.1:8082";
20+
public static readonly string CrossProcessHttpPrefix = "http://127.0.0.1:7081";
21+
public static readonly string CrossProcessHttpsPrefix = "https://127.0.0.1:7082";
2222
public static readonly string EmptyPage = $"{ServerUrl}/empty.html";
2323
public static readonly string CrossProcessUrl = ServerIpUrl;
2424
public static readonly bool IsChrome = PuppeteerTestAttribute.IsChrome;

0 commit comments

Comments
 (0)