From 33beb50903e5d7148eb2e8e1013e5d08646e6bbd Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Wed, 29 May 2024 10:47:40 +0200 Subject: [PATCH] test: Update expectations for firefox support of continueRequest (#12483) Co-authored-by: Alex Rudenko --- .../puppeteer-core/src/api/HTTPRequest.ts | 7 +- test/TestExpectations.json | 114 +----------------- test/src/requestinterception.spec.ts | 4 +- 3 files changed, 14 insertions(+), 111 deletions(-) diff --git a/packages/puppeteer-core/src/api/HTTPRequest.ts b/packages/puppeteer-core/src/api/HTTPRequest.ts index 674abc61f2e..29af3b69575 100644 --- a/packages/puppeteer-core/src/api/HTTPRequest.ts +++ b/packages/puppeteer-core/src/api/HTTPRequest.ts @@ -703,7 +703,12 @@ const errorReasons: Record = { * @internal */ export function handleError(error: ProtocolError): void { - if (error.originalMessage.includes('Invalid header')) { + // Firefox throws an invalid argument error with a message starting with + // 'Expected "header" [...]'. + if ( + error.originalMessage.includes('Invalid header') || + error.originalMessage.includes('Expected "header"') + ) { throw error; } // In certain cases, protocol will return error if the request was diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 02e220953a6..25fc6571f93 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -502,13 +502,6 @@ "expectations": ["FAIL"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, - { - "testIdPattern": "[network.spec] network Page.setExtraHTTPHeaders *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, { "testIdPattern": "[network.spec] network Request.initiator should return the initiator", "platforms": ["darwin", "linux", "win32"], @@ -737,13 +730,6 @@ "expectations": ["FAIL"], "comment": "BiDi spec expect the request to not trim the hash" }, - { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.continue *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "TODO: Needs full support for continueRequest in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1850680" - }, { "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.resourceType should work for document type", "platforms": ["darwin", "linux", "win32"], @@ -807,13 +793,6 @@ "expectations": ["FAIL"], "comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec" }, - { - "testIdPattern": "[requestinterception.spec] request interception Request.continue *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "TODO: Needs full support for continueRequest in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1850680" - }, { "testIdPattern": "[requestinterception.spec] request interception Request.resourceType should work for document type", "platforms": ["darwin", "linux", "win32"], @@ -2659,12 +2638,6 @@ "expectations": ["TIMEOUT"], "comment": "When navigating to page with authentication the command response (error) never comes without interception" }, - { - "testIdPattern": "[network.spec] network Page.setExtraHTTPHeaders should throw for non-string header values", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[network.spec] network Page.setExtraHTTPHeaders should work", "platforms": ["darwin", "linux", "win32"], @@ -3405,20 +3378,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs support for enabling cache in BiDi without CDP https://github.com/w3c/webdriver-bidi/issues/582" }, - { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should send referer", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, - { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should show custom HTTP headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, { "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work when header manipulation headers with redirect", "platforms": ["darwin", "linux", "win32"], @@ -3426,13 +3385,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs investigation, on Firefox the test is passing even if headers are not actually modified" }, - { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with custom referer headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, { "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with encoded server - 2", "platforms": ["darwin", "linux", "win32"], @@ -3440,13 +3392,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs support for data URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1805176" }, - { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with equal requests", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "TODO: Needs investigation, it looks like Firefox lets the request go also to the server" - }, { "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with file URLs", "platforms": ["darwin", "linux", "win32"], @@ -3476,10 +3421,11 @@ "comment": "Test requires CDP" }, { - "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.continue should work", + "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.continue should redirect in a way non-observable to page", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["PASS"] + "expectations": ["FAIL"], + "comment": "Firefox needs support for the url parameter of continueRequest" }, { "testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.respond should indicate already-handled if an intercept has been handled", @@ -3578,34 +3524,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs support for enabling cache in BiDi without CDP https://github.com/w3c/webdriver-bidi/issues/582" }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should send referer", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "Firefox does not support headers override" - }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should send referer", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should show custom HTTP headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "Firefox does not support headers override" - }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should show custom HTTP headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, { "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work when header manipulation headers with redirect", "platforms": ["darwin", "linux", "win32"], @@ -3613,20 +3531,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs investigation, on Firefox the test is passing even if headers are not actually modified" }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with custom referer headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "Firefox does not support headers override" - }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with custom referer headers", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["SKIP"], - "comment": "Firefox does not support headers override" - }, { "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with encoded server - 2", "platforms": ["darwin", "linux", "win32"], @@ -3634,13 +3538,6 @@ "expectations": ["SKIP"], "comment": "TODO: Needs support for data URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1805176" }, - { - "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with equal requests", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"], - "comment": "TODO: Needs investigation" - }, { "testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with file URLs", "platforms": ["darwin", "linux", "win32"], @@ -3677,10 +3574,11 @@ "comment": "CDP specific issue, maybe we can support it from BiDi+" }, { - "testIdPattern": "[requestinterception.spec] request interception Request.continue should work", + "testIdPattern": "[requestinterception.spec] request interception Request.continue should redirect in a way non-observable to page", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["PASS"] + "expectations": ["FAIL"], + "comment": "Firefox needs support for the url parameter of continueRequest" }, { "testIdPattern": "[screenshot.spec] Screenshots Cdp should use scale for clip", diff --git a/test/src/requestinterception.spec.ts b/test/src/requestinterception.spec.ts index 1308294ed4d..79314c5ffeb 100644 --- a/test/src/requestinterception.spec.ts +++ b/test/src/requestinterception.spec.ts @@ -760,7 +760,7 @@ describe('request interception', function () { await request.continue(); }); await page.goto(server.PREFIX + '/empty.html'); - expect(error.message).toMatch(/Invalid header/); + expect(error.message).toMatch(/Invalid header|Expected "header"/); }); }); @@ -928,7 +928,7 @@ describe('request interception', function () { }); }); await page.goto(server.PREFIX + '/empty.html'); - expect(error.message).toMatch(/Invalid header/); + expect(error.message).toMatch(/Invalid header|Expected "header"/); }); });