diff --git a/service-workers/service-worker/request-headers.https.html b/service-workers/service-worker/request-headers.https.html new file mode 100644 index 00000000000000..6ebad4b7b10bcd --- /dev/null +++ b/service-workers/service-worker/request-headers.https.html @@ -0,0 +1,48 @@ + + +Test that cache is being bypassed/validated in no-cache mode on update + + + + diff --git a/service-workers/service-worker/resources/test-request-headers-worker.js b/service-workers/service-worker/resources/test-request-headers-worker.js new file mode 100644 index 00000000000000..71aff5e503745f --- /dev/null +++ b/service-workers/service-worker/resources/test-request-headers-worker.js @@ -0,0 +1,7 @@ +// The server injects the request headers here as a JSON string. +const headersAsJson = `%HEADERS%`; +const headers = JSON.parse(headersAsJson); + +self.addEventListener('message', async (e) => { + e.source.postMessage(headers); +}); diff --git a/service-workers/service-worker/resources/test-request-headers-worker.py b/service-workers/service-worker/resources/test-request-headers-worker.py new file mode 100644 index 00000000000000..5666f19e7904b0 --- /dev/null +++ b/service-workers/service-worker/resources/test-request-headers-worker.py @@ -0,0 +1,16 @@ +import json +import os + +def main(request, response): + path = os.path.join(os.path.dirname(__file__), + "test-request-headers-worker.js") + body = open(path, "rb").read() + + data = {key:request.headers[key] for key,value in request.headers.iteritems()} + body = body.replace("%HEADERS%", json.dumps(data)) + + headers = [] + headers.append(("ETag", "etag")) + headers.append(("Content-Type", 'text/javascript')) + + return headers, body