diff --git a/service-workers/service-worker/registration-updateviacache.https.html b/service-workers/service-worker/registration-updateviacache.https.html new file mode 100644 index 000000000000000..7cfe06ed568f1f7 --- /dev/null +++ b/service-workers/service-worker/registration-updateviacache.https.html @@ -0,0 +1,150 @@ + +Service Worker: Registration-updateViaCache + + + + + diff --git a/service-workers/service-worker/registration-useCache.https.html b/service-workers/service-worker/registration-useCache.https.html deleted file mode 100644 index 1976fa117d6c3c3..000000000000000 --- a/service-workers/service-worker/registration-useCache.https.html +++ /dev/null @@ -1,223 +0,0 @@ - -Service Worker: Registration-useCache - - - - - diff --git a/service-workers/service-worker/resources/update-max-aged-worker-imported-script.py b/service-workers/service-worker/resources/update-max-aged-worker-imported-script.py index e166143e2bb2b0e..3f7f88bafaac618 100644 --- a/service-workers/service-worker/resources/update-max-aged-worker-imported-script.py +++ b/service-workers/service-worker/resources/update-max-aged-worker-imported-script.py @@ -1,22 +1,12 @@ import time def main(request, response): - headers = [('Cache-Control', 'max-age=86400'), - ('Content-Type', 'application/javascript'), - ('Last-Modified', time.strftime("%a, %d %b %Y %H:%M:%S GMT", - time.gmtime()))] - - - revalidate = request.headers.has_key('if-modified-since'); + headers = [('Content-Type', 'application/javascript'), + ('Cache-Control', 'max-age=86400'), + ('Last-Modified', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()))] body = ''' - self.addEventListener('message', function(e) { - e.data.port.postMessage({ - from: "imported", - type: "%s", - value: %s - }); - }); - ''' % ('revalidate' if revalidate else 'normal', time.time()) + const importTime = {time}; + '''.format(time=time.time()) return headers, body diff --git a/service-workers/service-worker/resources/update-max-aged-worker.py b/service-workers/service-worker/resources/update-max-aged-worker.py index 6eb7c343a269e37..a9acf1b6de547c2 100644 --- a/service-workers/service-worker/resources/update-max-aged-worker.py +++ b/service-workers/service-worker/resources/update-max-aged-worker.py @@ -1,26 +1,28 @@ import time +import json def main(request, response): headers = [('Content-Type', 'application/javascript'), ('Cache-Control', 'max-age=86400'), ('Last-Modified', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()))] - test = ''; - if 'Test' in request.GET: - test = request.GET['Test']; - - revalidate = request.headers.has_key('if-modified-since'); + test = request.GET['test']; body = ''' - importScripts('update-max-aged-worker-imported-script.py?Test=%s'); + const mainTime = {time}; + const testName = {test}; + importScripts('update-max-aged-worker-imported-script.py'); - self.addEventListener('message', function(e) { - e.data.port.postMessage({ - from: "main", - type: "%s", - value: %s - }); - }); - ''' % (test, 'revalidate' if revalidate else 'normal', time.time()) + addEventListener('message', event => {{ + event.source.postMessage({{ + mainTime, + importTime, + test: {test} + }}); + }}); + '''.format( + time=time.time(), + test=json.dumps(test) + ) return headers, body