test: make network cache test pass on all browsers (#374)

This commit is contained in:
Dmitry Gozman 2020-01-03 15:34:51 -08:00 committed by Yury Semikhatsky
parent cf6f04893c
commit 04bf728364
2 changed files with 4 additions and 5 deletions

View File

@ -779,12 +779,11 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
}); });
describe('Page.setCacheEnabled', function() { describe('Page.setCacheEnabled', function() {
// FIXME: 'if-modified-since' is not set for some reason even if cache is on. it('should enable or disable the cache based on the state passed', async({page, server}) => {
it.skip(WEBKIT)('should enable or disable the cache based on the state passed', async({page, server}) => {
await page.goto(server.PREFIX + '/cached/one-style.html'); await page.goto(server.PREFIX + '/cached/one-style.html');
const [cachedRequest] = await Promise.all([ const [cachedRequest] = await Promise.all([
server.waitForRequest('/cached/one-style.html'), server.waitForRequest('/cached/one-style.html'),
page.reload(), page.goto(server.PREFIX + '/cached/one-style.html'),
]); ]);
// Rely on "if-modified-since" caching in our test server. // Rely on "if-modified-since" caching in our test server.
expect(cachedRequest.headers['if-modified-since']).not.toBe(undefined); expect(cachedRequest.headers['if-modified-since']).not.toBe(undefined);
@ -792,7 +791,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
await page.setCacheEnabled(false); await page.setCacheEnabled(false);
const [nonCachedRequest] = await Promise.all([ const [nonCachedRequest] = await Promise.all([
server.waitForRequest('/cached/one-style.html'), server.waitForRequest('/cached/one-style.html'),
page.reload(), page.goto(server.PREFIX + '/cached/one-style.html'),
]); ]);
expect(nonCachedRequest.headers['if-modified-since']).toBe(undefined); expect(nonCachedRequest.headers['if-modified-since']).toBe(undefined);
}); });

View File

@ -234,7 +234,7 @@ class TestServer {
response.end(); response.end();
return; return;
} }
response.setHeader('Cache-Control', 'public, max-age=31536000'); response.setHeader('Cache-Control', 'public, max-age=31536000, no-cache');
response.setHeader('Last-Modified', this._startTime.toISOString()); response.setHeader('Last-Modified', this._startTime.toISOString());
} else { } else {
response.setHeader('Cache-Control', 'no-cache, no-store'); response.setHeader('Cache-Control', 'no-cache, no-store');