Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Dmitry Gozman04bf728364b6
diff --git a/test/page.spec.js b/test/page.spec.js
index d40534fd46..00cac23168 100644
--- a/test/page.spec.js
+++ b/test/page.spec.js
@@ -779,12 +779,11 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
});
describe('Page.setCacheEnabled', function() {
- // FIXME: 'if-modified-since' is not set for some reason even if cache is on.
- it.skip(WEBKIT)('should enable or disable the cache based on the state passed', async({page, server}) => {
+ it('should enable or disable the cache based on the state passed', async({page, server}) => {
await page.goto(server.PREFIX + '/cached/one-style.html');
const [cachedRequest] = await Promise.all([
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.
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);
const [nonCachedRequest] = await Promise.all([
server.waitForRequest('/cached/one-style.html'),
- page.reload(),
+ page.goto(server.PREFIX + '/cached/one-style.html'),
]);
expect(nonCachedRequest.headers['if-modified-since']).toBe(undefined);
});
diff --git a/utils/testserver/index.js b/utils/testserver/index.js
index 85f2d1fdd7..37ebf109a3 100644
--- a/utils/testserver/index.js
+++ b/utils/testserver/index.js
@@ -234,7 +234,7 @@ class TestServer {
response.end();
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());
} else {
response.setHeader('Cache-Control', 'no-cache, no-store');