diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py')
-rw-r--r-- | testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py b/testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py new file mode 100644 index 0000000000..6419d5bfad --- /dev/null +++ b/testing/web-platform/tests/clear-site-data/support/echo-clear-site-data.py @@ -0,0 +1,40 @@ +import json + +RESPONSE = u""" +<!DOCTYPE html> +<html> + <head> + <title>Clear-Site-Data</title> + <script src="test_utils.sub.js"></script> + </head> + <body> + <script> + /** + * A map between a datatype name and whether it is empty. + * @property Object.<string, boolean> + */ + var report = {}; + + Promise.all(TestUtils.DATATYPES.map(function(datatype) { + return datatype.isEmpty().then(function(isEmpty) { + report[datatype.name] = isEmpty; + }); + })).then(function() { + window.top.postMessage(report, "*"); + }); + </script> + </body> +</html> +""" + +# A support server that receives a list of datatypes in the GET query +# and returns a Clear-Site-Data header with those datatypes. The content +# of the response is a html site using postMessage to report the status +# of the datatypes, so that if used in an iframe, it can inform the +# embedder whether the data deletion succeeded. +def main(request, response): + types = [key for key in request.GET.keys()] + header = b",".join(b"\"" + type + b"\"" for type in types) + return ([(b"Clear-Site-Data", header), + (b"Content-Type", b"text/html")], + RESPONSE) |