test: set-cookie response header after route.fulfill (#11044)
This commit is contained in:
parent
a96cb5aff5
commit
2cc4dfc96f
|
|
@ -15,9 +15,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import url from 'url';
|
|
||||||
import { test as it, expect } from './pageTest';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import url from 'url';
|
||||||
|
import { expect, test as it } from './pageTest';
|
||||||
|
|
||||||
it('should work #smoke', async ({ page, server }) => {
|
it('should work #smoke', async ({ page, server }) => {
|
||||||
server.setRoute('/empty.html', (req, res) => {
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
|
@ -280,3 +280,41 @@ it('should provide a Response with a file URL', async ({ page, asset, isAndroid,
|
||||||
expect(response.status()).toBe(0);
|
expect(response.status()).toBe(0);
|
||||||
expect(response.ok()).toBe(true);
|
expect(response.ok()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return set-cookie header after route.fulfill', async ({ page, server, browserName }) => {
|
||||||
|
it.fail(browserName === 'webkit' || browserName === 'chromium', 'https://github.com/microsoft/playwright/issues/11035');
|
||||||
|
await page.route('**/*', async route => {
|
||||||
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
'set-cookie': 'a=b'
|
||||||
|
},
|
||||||
|
contentType: 'text/plain',
|
||||||
|
body: ''
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const response = await page.goto(server.EMPTY_PAGE);
|
||||||
|
const headers = await response.allHeaders();
|
||||||
|
expect(headers['set-cookie']).toBe('a=b');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return headers after route.fulfill', async ({ page, server }) => {
|
||||||
|
await page.route('**/*', async route => {
|
||||||
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
'foo': 'bar',
|
||||||
|
'content-language': 'en'
|
||||||
|
},
|
||||||
|
contentType: 'text/plain',
|
||||||
|
body: 'done'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const response = await page.goto(server.EMPTY_PAGE);
|
||||||
|
expect(await response.allHeaders()).toEqual({
|
||||||
|
'foo': 'bar',
|
||||||
|
'content-type': 'text/plain',
|
||||||
|
'content-length': '4',
|
||||||
|
'content-language': 'en'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue