Skip to content

Commit 7ca5a89

Browse files
authored
chore: fix test server to disable cache (microsoft#282)
If pages are cached, then Firefox uses back-forward cache aggressively to serve the history navigations. Fixes microsoft/playwright#3693
1 parent 7580830 commit 7ca5a89

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tests/async/test_navigation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ async def test_wait_for_load_state_should_resolve_after_popup_load(context, serv
864864
assert popup.url == server.PREFIX + "/one-style.html"
865865

866866

867-
@pytest.mark.skip_browser("firefox")
868867
async def test_go_back_should_work(page, server):
869868
assert await page.goBack() is None
870869

tests/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ def process(self):
112112
file_content = (
113113
static_path / request.path.decode()[1:]
114114
).read_bytes()
115-
except (FileNotFoundError, IsADirectoryError):
116-
request.setResponseCode(HTTPStatus.NOT_FOUND)
117-
if file_content:
118-
request.setHeader("Content-Type", mimetypes.guess_type(uri)[0])
115+
request.setHeader(b"Content-Type", mimetypes.guess_type(uri)[0])
116+
request.setHeader(b"Cache-Control", "no-cache, no-store")
119117
if uri in gzip_routes:
120118
request.setHeader("Content-Encoding", "gzip")
121119
request.write(gzip.compress(file_content))
122120
else:
123121
request.write(file_content)
124122
self.setResponseCode(HTTPStatus.OK)
123+
except (FileNotFoundError, IsADirectoryError):
124+
request.setResponseCode(HTTPStatus.NOT_FOUND)
125125
self.finish()
126126

127127
class MyHttp(http.HTTPChannel):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy