mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(webdriver): HTTPRequest redirect chain from first request (#12506)
This commit is contained in:
parent
bae3721e04
commit
68fd771293
@ -38,7 +38,8 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
request.#initialize();
|
request.#initialize();
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
#redirectBy: BidiHTTPRequest | undefined;
|
|
||||||
|
#redirectChain: BidiHTTPRequest[];
|
||||||
#response: BidiHTTPResponse | null = null;
|
#response: BidiHTTPResponse | null = null;
|
||||||
override readonly id: string;
|
override readonly id: string;
|
||||||
readonly #frame: BidiFrame;
|
readonly #frame: BidiFrame;
|
||||||
@ -47,7 +48,7 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
private constructor(
|
private constructor(
|
||||||
request: Request,
|
request: Request,
|
||||||
frame: BidiFrame,
|
frame: BidiFrame,
|
||||||
redirectBy?: BidiHTTPRequest
|
redirect?: BidiHTTPRequest
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
requests.set(request, this);
|
requests.set(request, this);
|
||||||
@ -56,7 +57,7 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
|
|
||||||
this.#request = request;
|
this.#request = request;
|
||||||
this.#frame = frame;
|
this.#frame = frame;
|
||||||
this.#redirectBy = redirectBy;
|
this.#redirectChain = redirect ? redirect.#redirectChain : [];
|
||||||
this.id = request.id;
|
this.id = request.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +68,8 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
#initialize() {
|
#initialize() {
|
||||||
this.#request.on('redirect', request => {
|
this.#request.on('redirect', request => {
|
||||||
const httpRequest = BidiHTTPRequest.from(request, this.#frame, this);
|
const httpRequest = BidiHTTPRequest.from(request, this.#frame, this);
|
||||||
|
this.#redirectChain.push(this);
|
||||||
|
|
||||||
request.once('success', () => {
|
request.once('success', () => {
|
||||||
this.#frame
|
this.#frame
|
||||||
.page()
|
.page()
|
||||||
@ -170,16 +173,7 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override redirectChain(): BidiHTTPRequest[] {
|
override redirectChain(): BidiHTTPRequest[] {
|
||||||
if (this.#redirectBy === undefined) {
|
return this.#redirectChain.slice();
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const redirects = [this.#redirectBy];
|
|
||||||
for (const redirect of redirects) {
|
|
||||||
if (redirect.#redirectBy !== undefined) {
|
|
||||||
redirects.push(redirect.#redirectBy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return redirects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override frame(): BidiFrame {
|
override frame(): BidiFrame {
|
||||||
|
@ -765,20 +765,6 @@
|
|||||||
"expectations": ["FAIL"],
|
"expectations": ["FAIL"],
|
||||||
"comment": "BiDi spec and WPT require expect the Hash"
|
"comment": "BiDi spec and WPT require expect the Hash"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with redirects",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"],
|
|
||||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with redirects for subresources",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"],
|
|
||||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Request.resourceType should work for document type",
|
"testIdPattern": "[requestinterception.spec] request interception Request.resourceType should work for document type",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3343,20 +3329,6 @@
|
|||||||
"expectations": ["SKIP"],
|
"expectations": ["SKIP"],
|
||||||
"comment": "TODO: Needs support for file URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1826210"
|
"comment": "TODO: Needs support for file URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1826210"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with redirects",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["SKIP"],
|
|
||||||
"comment": "TODO: Needs support for BidiHTTPRequest.resourceType"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with redirects for subresources",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["SKIP"],
|
|
||||||
"comment": "TODO: Needs support for BidiHTTPRequest.resourceType"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with requests without networkId",
|
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with requests without networkId",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3475,20 +3447,6 @@
|
|||||||
"expectations": ["SKIP"],
|
"expectations": ["SKIP"],
|
||||||
"comment": "TODO: Needs support for file URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1826210"
|
"comment": "TODO: Needs support for file URIs in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1826210"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with redirects",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["SKIP"],
|
|
||||||
"comment": "TODO: Needs support for BidiHTTPRequest.resourceType"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with redirects for subresources",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["firefox", "webDriverBiDi"],
|
|
||||||
"expectations": ["SKIP"],
|
|
||||||
"comment": "TODO: Needs support for BidiHTTPRequest.resourceType"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with requests without networkId",
|
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should work with requests without networkId",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3893,20 +3851,6 @@
|
|||||||
"expectations": ["FAIL"],
|
"expectations": ["FAIL"],
|
||||||
"comment": "`request.postData()` has no eqivalent in BiDi spec"
|
"comment": "`request.postData()` has no eqivalent in BiDi spec"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with redirects",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["chrome", "headless", "webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"],
|
|
||||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Page.setRequestInterception should work with redirects for subresources",
|
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
|
||||||
"parameters": ["chrome", "headless", "webDriverBiDi"],
|
|
||||||
"expectations": ["FAIL"],
|
|
||||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should be abortable",
|
"testIdPattern": "[requestinterception.spec] request interception Page.setRequestInterception should be abortable",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
@ -196,10 +196,10 @@ describe('cooperative request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
|
void request.continue({}, 0);
|
||||||
if (!isFavicon(request)) {
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
}
|
}
|
||||||
void request.continue({}, 0);
|
|
||||||
});
|
});
|
||||||
await page.goto(server.PREFIX + '/one-style.html');
|
await page.goto(server.PREFIX + '/one-style.html');
|
||||||
expect(requests[1]!.url()).toContain('/one-style.css');
|
expect(requests[1]!.url()).toContain('/one-style.css');
|
||||||
@ -386,7 +386,9 @@ describe('cooperative request interception', function () {
|
|||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
void request.continue({}, 0);
|
void request.continue({}, 0);
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
server.setRedirect(
|
server.setRedirect(
|
||||||
'/non-existing-page.html',
|
'/non-existing-page.html',
|
||||||
@ -526,7 +528,9 @@ describe('cooperative request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
void request.continue({}, 0);
|
void request.continue({}, 0);
|
||||||
});
|
});
|
||||||
const dataURL = 'data:text/html,<div>yo</div>';
|
const dataURL = 'data:text/html,<div>yo</div>';
|
||||||
@ -542,8 +546,10 @@ describe('cooperative request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
!isFavicon(request) && requests.push(request);
|
|
||||||
void request.continue({}, 0);
|
void request.continue({}, 0);
|
||||||
|
if (!isFavicon(request)) {
|
||||||
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const dataURL = 'data:text/html,<div>yo</div>';
|
const dataURL = 'data:text/html,<div>yo</div>';
|
||||||
const text = await page.evaluate((url: string) => {
|
const text = await page.evaluate((url: string) => {
|
||||||
@ -561,7 +567,9 @@ describe('cooperative request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
void request.continue({}, 0);
|
void request.continue({}, 0);
|
||||||
});
|
});
|
||||||
const response = await page.goto(server.EMPTY_PAGE + '#hash');
|
const response = await page.goto(server.EMPTY_PAGE + '#hash');
|
||||||
@ -606,7 +614,9 @@ describe('cooperative request interception', function () {
|
|||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
void request.continue({}, 0);
|
void request.continue({}, 0);
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const response = await page.goto(
|
const response = await page.goto(
|
||||||
`data:text/html,<link rel="stylesheet" href="${server.PREFIX}/fonts?helvetica|arial"/>`
|
`data:text/html,<link rel="stylesheet" href="${server.PREFIX}/fonts?helvetica|arial"/>`
|
||||||
|
@ -303,7 +303,9 @@ describe('request interception', function () {
|
|||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
void request.continue();
|
void request.continue();
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
server.setRedirect(
|
server.setRedirect(
|
||||||
'/non-existing-page.html',
|
'/non-existing-page.html',
|
||||||
@ -443,8 +445,10 @@ describe('request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
requests.push(request);
|
|
||||||
void request.continue();
|
void request.continue();
|
||||||
|
if (!isFavicon(request)) {
|
||||||
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const dataURL = 'data:text/html,<div>yo</div>';
|
const dataURL = 'data:text/html,<div>yo</div>';
|
||||||
const response = (await page.goto(dataURL))!;
|
const response = (await page.goto(dataURL))!;
|
||||||
@ -459,8 +463,10 @@ describe('request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
!isFavicon(request) && requests.push(request);
|
|
||||||
void request.continue();
|
void request.continue();
|
||||||
|
if (!isFavicon(request)) {
|
||||||
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const dataURL = 'data:text/html,<div>yo</div>';
|
const dataURL = 'data:text/html,<div>yo</div>';
|
||||||
const text = await page.evaluate((url: string) => {
|
const text = await page.evaluate((url: string) => {
|
||||||
@ -478,8 +484,10 @@ describe('request interception', function () {
|
|||||||
await page.setRequestInterception(true);
|
await page.setRequestInterception(true);
|
||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
requests.push(request);
|
|
||||||
void request.continue();
|
void request.continue();
|
||||||
|
if (!isFavicon(request)) {
|
||||||
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const response = (await page.goto(server.EMPTY_PAGE + '#hash'))!;
|
const response = (await page.goto(server.EMPTY_PAGE + '#hash'))!;
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
@ -525,7 +533,9 @@ describe('request interception', function () {
|
|||||||
const requests: HTTPRequest[] = [];
|
const requests: HTTPRequest[] = [];
|
||||||
page.on('request', request => {
|
page.on('request', request => {
|
||||||
void request.continue();
|
void request.continue();
|
||||||
|
if (!isFavicon(request)) {
|
||||||
requests.push(request);
|
requests.push(request);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const response = (await page.goto(
|
const response = (await page.goto(
|
||||||
`data:text/html,<link rel="stylesheet" href="${server.PREFIX}/fonts?helvetica|arial"/>`
|
`data:text/html,<link rel="stylesheet" href="${server.PREFIX}/fonts?helvetica|arial"/>`
|
||||||
|
Loading…
Reference in New Issue
Block a user