mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
test: add a failing test for post data header override (#4397)
This commit is contained in:
parent
2158d6d073
commit
6b1d7dd1fd
@ -154,6 +154,30 @@ it('should work with binary post data and interception', async ({page, server})
|
||||
expect(buffer[i]).toBe(i);
|
||||
});
|
||||
|
||||
it('should override post data content type', (test, { browserName }) => {
|
||||
test.fixme(browserName === 'firefox', 'Always reports application/octet-stream');
|
||||
}, async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
let request = null;
|
||||
server.setRoute('/post', (req, res) => {
|
||||
request = req;
|
||||
res.end();
|
||||
});
|
||||
await page.route('**/post', (route, request) => {
|
||||
const headers = request.headers();
|
||||
headers['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
|
||||
route.continue({
|
||||
headers,
|
||||
postData: request.postData()
|
||||
});
|
||||
});
|
||||
await page.evaluate(async () => {
|
||||
await fetch('./post', { method: 'POST', body: 'foo=bar' });
|
||||
});
|
||||
expect(request).toBeTruthy();
|
||||
expect(request.headers['content-type']).toBe('application/x-www-form-urlencoded; charset=UTF-8');
|
||||
});
|
||||
|
||||
it('should be |undefined| when there is no post data', async ({page, server}) => {
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response.request().postData()).toBe(null);
|
||||
|
Loading…
Reference in New Issue
Block a user