OLD | NEW |
(Empty) | |
| 1 import json |
| 2 |
| 3 RESPONSE = """ |
| 4 <!DOCTYPE html> |
| 5 <html> |
| 6 <head> |
| 7 <title>Clear-Site-Data</title> |
| 8 <script src="test_utils.js"></script> |
| 9 </head> |
| 10 <body> |
| 11 <script> |
| 12 /** |
| 13 * A map between a datatype name and whether it is empty. |
| 14 * @property Object.<string, boolean> |
| 15 */ |
| 16 var report = {}; |
| 17 |
| 18 Promise.all(TestUtils.DATATYPES.map(function(datatype) { |
| 19 return datatype.isEmpty().then(function(isEmpty) { |
| 20 report[datatype.name] = isEmpty; |
| 21 }); |
| 22 })).then(function() { |
| 23 window.top.postMessage(report, "*"); |
| 24 }); |
| 25 </script> |
| 26 </body> |
| 27 </html> |
| 28 """ |
| 29 |
| 30 # A support server that receives a list of datatypes in the GET query |
| 31 # and returns a Clear-Site-Data header with those datatypes. The content |
| 32 # of the response is a html site using postMessage to report the status |
| 33 # of the datatypes, so that if used in an iframe, it can inform the |
| 34 # embedder whether the data deletion succeeded. |
| 35 def main(request, response): |
| 36 types = [key for key in request.GET.keys()] |
| 37 header = json.dumps({ "types": types }) |
| 38 return ([("Clear-Site-Data", header), |
| 39 ("Content-Type", "text/html")], |
| 40 RESPONSE) |
OLD | NEW |