mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
feat(webkit): support referrer parameter in Page.navigate (#286)
* add test for reference-policy: no-referrer
This commit is contained in:
parent
f854b09879
commit
83833f61c1
@ -10,7 +10,7 @@
|
||||
"playwright": {
|
||||
"chromium_revision": "724623",
|
||||
"firefox_revision": "1007",
|
||||
"webkit_revision": "1043"
|
||||
"webkit_revision": "1044"
|
||||
},
|
||||
"scripts": {
|
||||
"unit": "node test/test.js",
|
||||
|
@ -190,7 +190,7 @@ export class FrameManager implements PageDelegate {
|
||||
}
|
||||
|
||||
async navigateFrame(frame: frames.Frame, url: string, referrer: string | undefined): Promise<frames.GotoResult> {
|
||||
await this._session.send('Page.navigate', { url, frameId: frame._id });
|
||||
await this._session.send('Page.navigate', { url, frameId: frame._id, referrer });
|
||||
return {}; // We cannot get loaderId of cross-process navigation in advance.
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
|
||||
}
|
||||
expect(error.message).toContain(url);
|
||||
});
|
||||
it.skip(WEBKIT)('should send referer', async({page, server}) => {
|
||||
it('should send referer', async({page, server}) => {
|
||||
const [request1, request2] = await Promise.all([
|
||||
server.waitForRequest('/grid.html'),
|
||||
server.waitForRequest('/digits/1.png'),
|
||||
@ -429,6 +429,37 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
|
||||
expect(request2.headers['referer']).toBe(server.PREFIX + '/grid.html');
|
||||
expect(page.url()).toBe(server.PREFIX + '/grid.html');
|
||||
});
|
||||
it('should use referer option when setExtraHTTPHeaders provides referer', async({page, server}) => {
|
||||
await page.setExtraHTTPHeaders({ 'referer': 'http://microsoft.com/' });
|
||||
const [request1, request2] = await Promise.all([
|
||||
server.waitForRequest('/grid.html'),
|
||||
server.waitForRequest('/digits/1.png'),
|
||||
page.goto(server.PREFIX + '/grid.html', {
|
||||
referer: 'http://google.com/',
|
||||
}),
|
||||
]);
|
||||
expect(request1.headers['referer']).toBe('http://google.com/');
|
||||
// Make sure subresources use referer specified by setExtraHTTPHeaders.
|
||||
expect(request2.headers['referer']).toBe('http://microsoft.com/');
|
||||
expect(page.url()).toBe(server.PREFIX + '/grid.html');
|
||||
});
|
||||
it('should override referrer-policy', async({page, server}) => {
|
||||
server.setRoute('/grid.html', (req, res) => {
|
||||
res.setHeader('Referrer-Policy', 'no-referrer');
|
||||
server.serveFile(req, res, '/grid.html');
|
||||
});
|
||||
const [request1, request2] = await Promise.all([
|
||||
server.waitForRequest('/grid.html'),
|
||||
server.waitForRequest('/digits/1.png'),
|
||||
page.goto(server.PREFIX + '/grid.html', {
|
||||
referer: 'http://microsoft.com/',
|
||||
}),
|
||||
]);
|
||||
expect(request1.headers['referer']).toBe('http://microsoft.com/');
|
||||
// Make sure subresources do not inherit referer.
|
||||
expect(request2.headers['referer']).toBe(undefined);
|
||||
expect(page.url()).toBe(server.PREFIX + '/grid.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForNavigation', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user