Skip to content

Commit

Permalink
chore: fix test server to disable cache (#282)
Browse files Browse the repository at this point in the history
If pages are cached, then Firefox uses back-forward cache aggressively
to serve the history navigations.

Fixes microsoft/playwright#3693
  • Loading branch information
smilephoenix103 committed Nov 4, 2020
1 parent 42fbe0d commit bae0e2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion tests/async/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,6 @@ async def test_wait_for_load_state_should_resolve_after_popup_load(context, serv
assert popup.url == server.PREFIX + "/one-style.html"


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

Expand Down
8 changes: 4 additions & 4 deletions tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ def process(self):
file_content = (
static_path / request.path.decode()[1:]
).read_bytes()
except (FileNotFoundError, IsADirectoryError):
request.setResponseCode(HTTPStatus.NOT_FOUND)
if file_content:
request.setHeader("Content-Type", mimetypes.guess_type(uri)[0])
request.setHeader(b"Content-Type", mimetypes.guess_type(uri)[0])
request.setHeader(b"Cache-Control", "no-cache, no-store")
if uri in gzip_routes:
request.setHeader("Content-Encoding", "gzip")
request.write(gzip.compress(file_content))
else:
request.write(file_content)
self.setResponseCode(HTTPStatus.OK)
except (FileNotFoundError, IsADirectoryError):
request.setResponseCode(HTTPStatus.NOT_FOUND)
self.finish()

class MyHttp(http.HTTPChannel):
Expand Down

0 comments on commit bae0e2c

Please sign in to comment.