diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-01-18 18:55:05 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-01-18 19:28:11 +0100 |
commit | 046b8a7b3e7259bf451926732e6221076b1d4153 (patch) | |
tree | 3746d157139ba88f7c78a7d17cd97a6e5cf48a6a /test/world_wide_library.py | |
parent | 17614206a6e23900e0ddd91c4e4e40ec08eaec99 (diff) | |
download | browser-extension-046b8a7b3e7259bf451926732e6221076b1d4153.tar.gz browser-extension-046b8a7b3e7259bf451926732e6221076b1d4153.zip |
facilitate caching repository responses in content scripts
Diffstat (limited to 'test/world_wide_library.py')
-rw-r--r-- | test/world_wide_library.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/world_wide_library.py b/test/world_wide_library.py index bed6ec3..14e3d2f 100644 --- a/test/world_wide_library.py +++ b/test/world_wide_library.py @@ -31,6 +31,7 @@ from hashlib import sha256 from pathlib import Path from shutil import rmtree from threading import Lock +import json from .misc_constants import here @@ -87,6 +88,18 @@ def dump_scripts(directory='./injected_scripts'): some_data = '{"some": "data"}' +# used by handler function of https://counterdoma.in +request_counter = 0 + +def serve_counter(command, get_params, post_params): + global request_counter + request_counter += 1 + return ( + 200, + {'Cache-Control': 'private, max-age=0, no-store'}, + json.dumps({'counter': request_counter}) + ) + catalog = { 'http://gotmyowndoma.in': (302, {'location': 'http://gotmyowndoma.in/index.html'}, None), @@ -108,6 +121,8 @@ catalog = { 'https://anotherdoma.in/resource/blocked/by/CORS.json': lambda command, get_params, post_params: (200, {}, some_data), + 'https://counterdoma.in/': serve_counter, + 'https://serve.scrip.ts/': serve_script, 'https://site.with.scripts.block.ed': |