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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/referrer-policy/generic/subresource/image.py

Issue 2780533002: Use Referrer-Policy headers for CSS stylesheets (Closed)
Patch Set: updates Created 3 years, 8 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 os, sys, array, json, math, StringIO 1 import os, sys, array, json, math, StringIO
2 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) 2 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
3 import subresource 3 import subresource
4 4
5 class Image: 5 class Image:
6 """This class partially implements the interface of the PIL.Image.Image. 6 """This class partially implements the interface of the PIL.Image.Image.
7 One day in the future WPT might support the PIL module or another imaging 7 One day in the future WPT might support the PIL module or another imaging
8 library, so this hacky BMP implementation will no longer be required. 8 library, so this hacky BMP implementation will no longer be required.
9 """ 9 """
10 def __init__(self, width, height): 10 def __init__(self, width, height):
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 img = Image.new("RGB", (sqrt, sqrt), "black") 81 img = Image.new("RGB", (sqrt, sqrt), "black")
82 img.putdata(color_data) 82 img.putdata(color_data)
83 83
84 # Flush image to string. 84 # Flush image to string.
85 f = StringIO.StringIO() 85 f = StringIO.StringIO()
86 img.save(f, "BMP") 86 img.save(f, "BMP")
87 f.seek(0) 87 f.seek(0)
88 88
89 return f.read() 89 return f.read()
90 90
91 def generate_payload(server_data): 91 def generate_payload(request, server_data):
92 data = ('{"headers": %(headers)s}') % server_data 92 data = ('{"headers": %(headers)s}') % server_data
93 return encode_string_as_bmp_image(data) 93 if "id" in request.GET:
94 request.server.stash.put(request.GET["id"], data)
95 data = encode_string_as_bmp_image(data)
96 return data
97
98 def generate_report_headers_payload(request, server_data):
99 stashed_data = request.server.stash.take(request.GET["id"])
100 return stashed_data
94 101
95 def main(request, response): 102 def main(request, response):
103 handler = lambda data: generate_payload(request, data)
104 content_type = 'image/bmp'
105
106 if "report-headers" in request.GET:
107 handler = lambda data: generate_report_headers_payload(request, data)
108 content_type = 'application/json'
109
96 subresource.respond(request, 110 subresource.respond(request,
97 response, 111 response,
98 payload_generator = generate_payload, 112 payload_generator = handler,
99 content_type = "image/bmp", 113 content_type = content_type,
100 access_control_allow_origin = "*") 114 access_control_allow_origin = "*")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698