Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/clear-site-data/support/echo-clear-site-data.py

Issue 2913553004: Add the 'cache' datatype to the clear-site-data WPT (Closed)
Patch Set: Rebase, syntax, cache busting. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 import json 1 import json
2 2
3 RESPONSE = """ 3 RESPONSE = """
4 <!DOCTYPE html> 4 <!DOCTYPE html>
5 <html> 5 <html>
6 <head> 6 <head>
7 <title>Clear-Site-Data</title> 7 <title>Clear-Site-Data</title>
8 <script src="test_utils.js"></script> 8 <script src="test_utils.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 TestUtils.setCachedResourceName("%s");
13
12 /** 14 /**
13 * A map between a datatype name and whether it is empty. 15 * A map between a datatype name and whether it is empty.
14 * @property Object.<string, boolean> 16 * @property Object.<string, boolean>
15 */ 17 */
16 var report = {}; 18 var report = {};
17 19
18 Promise.all(TestUtils.DATATYPES.map(function(datatype) { 20 Promise.all(TestUtils.DATATYPES.map(function(datatype) {
19 return datatype.isEmpty().then(function(isEmpty) { 21 return datatype.isEmpty().then(function(isEmpty) {
20 report[datatype.name] = isEmpty; 22 report[datatype.name] = isEmpty;
21 }); 23 });
22 })).then(function() { 24 })).then(function() {
23 window.top.postMessage(report, "*"); 25 window.top.postMessage(report, "*");
24 }); 26 });
25 </script> 27 </script>
26 </body> 28 </body>
27 </html> 29 </html>
28 """ 30 """
29 31
30 # A support server that receives a list of datatypes in the GET query 32 # 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 33 # 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 34 # 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 35 # of the datatypes, so that if used in an iframe, it can inform the
34 # embedder whether the data deletion succeeded. 36 # embedder whether the data deletion succeeded.
35 def main(request, response): 37 def main(request, response):
36 types = [key for key in request.GET.keys()] 38 if "cached_resource_name" not in request.GET.keys():
37 header = json.dumps({ "types": types }) 39 raise ("Invalid request: Please include the 'cached_resource_name' GET "
40 "parameter, otherwise cache emptiness can not be verified.")
41
42 types = [key for key in request.GET.keys()
43 if key != "cached_resource_name"]
44 header = ",".join("\"" + type + "\"" for type in types)
38 return ([("Clear-Site-Data", header), 45 return ([("Clear-Site-Data", header),
39 ("Content-Type", "text/html")], 46 ("Content-Type", "text/html")],
40 RESPONSE) 47 RESPONSE % request.GET["cached_resource_name"])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698