mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Update web-platform-tests to revision cb40575e1a57892476f3e326355674d492dedbd2
This commit is contained in:
parent
0afe412d63
commit
fa6a725a86
170 changed files with 1958 additions and 664 deletions
|
@ -1,17 +1,17 @@
|
|||
ETAG = '"123abc"'
|
||||
CONTENT_TYPE = "text/plain"
|
||||
CONTENT = "lorem ipsum dolor sit amet"
|
||||
ETAG = b'"123abc"'
|
||||
CONTENT_TYPE = b"text/plain"
|
||||
CONTENT = u"lorem ipsum dolor sit amet"
|
||||
|
||||
def main(request, response):
|
||||
# let caching kick in if possible (conditional GET)
|
||||
etag = request.headers.get("If-None-Match", None)
|
||||
etag = request.headers.get(b"If-None-Match", None)
|
||||
if etag == ETAG:
|
||||
response.headers.set("X-HTTP-STATUS", 304)
|
||||
response.status = (304, "Not Modified")
|
||||
return ""
|
||||
response.headers.set(b"X-HTTP-STATUS", 304)
|
||||
response.status = (304, b"Not Modified")
|
||||
return u""
|
||||
|
||||
# cache miss, so respond with the actual content
|
||||
response.status = (200, "OK")
|
||||
response.headers.set("ETag", ETAG)
|
||||
response.headers.set("Content-Type", CONTENT_TYPE)
|
||||
response.status = (200, b"OK")
|
||||
response.headers.set(b"ETag", ETAG)
|
||||
response.headers.set(b"Content-Type", CONTENT_TYPE)
|
||||
return CONTENT
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import time
|
||||
|
||||
_LOCK_KEY = "67966d2e-a847-41d8-b7c3-5f6aee3375ba"
|
||||
_LOCK_KEY = b"67966d2e-a847-41d8-b7c3-5f6aee3375ba"
|
||||
_TIMEOUT = 5 # seconds
|
||||
|
||||
def wait_for_lock(request):
|
||||
|
@ -24,9 +24,9 @@ def lock(request, report_id):
|
|||
with request.server.stash.lock:
|
||||
# Loop until the lock is free
|
||||
if not wait_for_lock(request):
|
||||
return (503, [], "Cannot obtain lock")
|
||||
return (503, [], b"Cannot obtain lock")
|
||||
request.server.stash.put(key=_LOCK_KEY, value=report_id)
|
||||
return "Obtained lock for %s" % report_id
|
||||
return b"Obtained lock for %s" % report_id
|
||||
|
||||
def unlock(request, report_id):
|
||||
with request.server.stash.lock:
|
||||
|
@ -34,15 +34,15 @@ def unlock(request, report_id):
|
|||
if lock_holder != report_id:
|
||||
# Return the lock holder to the stash
|
||||
request.server.stash.put(key=_LOCK_KEY, value=lock_holder)
|
||||
return (503, [], "Cannot release lock held by %s" % lock_holder)
|
||||
return "Released lock for %s" % report_id
|
||||
return (503, [], b"Cannot release lock held by %s" % lock_holder)
|
||||
return b"Released lock for %s" % report_id
|
||||
|
||||
def main(request, response):
|
||||
op = request.GET.first("op")
|
||||
report_id = request.GET.first("reportID")
|
||||
if op == "lock":
|
||||
op = request.GET.first(b"op")
|
||||
report_id = request.GET.first(b"reportID")
|
||||
if op == b"lock":
|
||||
return lock(request, report_id)
|
||||
elif op == "unlock":
|
||||
elif op == b"unlock":
|
||||
return unlock(request, report_id)
|
||||
else:
|
||||
return (400, [], "Invalid op")
|
||||
return (400, [], b"Invalid op")
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# Always redirects to no-policy-pass.png.
|
||||
def main(request, response):
|
||||
return 302, [("Location", "no-policy-pass.png")], ""
|
||||
return 302, [(b"Location", b"no-policy-pass.png")], u""
|
||||
|
|
|
@ -15,36 +15,36 @@ def retrieve_from_stash(request, key, timeout, min_count, default_value):
|
|||
|
||||
def main(request, response):
|
||||
# Handle CORS preflight requests
|
||||
if request.method == 'OPTIONS':
|
||||
if request.method == u'OPTIONS':
|
||||
# Always reject preflights for one subdomain
|
||||
if "www2" in request.headers["Origin"]:
|
||||
return (400, [], "CORS preflight rejected for www2")
|
||||
if b"www2" in request.headers[b"Origin"]:
|
||||
return (400, [], u"CORS preflight rejected for www2")
|
||||
return [
|
||||
("Content-Type", "text/plain"),
|
||||
("Access-Control-Allow-Origin", "*"),
|
||||
("Access-Control-Allow-Methods", "post"),
|
||||
("Access-Control-Allow-Headers", "Content-Type"),
|
||||
], "CORS allowed"
|
||||
(b"Content-Type", b"text/plain"),
|
||||
(b"Access-Control-Allow-Origin", b"*"),
|
||||
(b"Access-Control-Allow-Methods", b"post"),
|
||||
(b"Access-Control-Allow-Headers", b"Content-Type"),
|
||||
], u"CORS allowed"
|
||||
|
||||
op = request.GET.first("op");
|
||||
key = request.GET.first("reportID")
|
||||
op = request.GET.first(b"op");
|
||||
key = request.GET.first(b"reportID")
|
||||
|
||||
if op == "retrieve_report":
|
||||
if op == b"retrieve_report":
|
||||
try:
|
||||
timeout = float(request.GET.first("timeout"))
|
||||
timeout = float(request.GET.first(b"timeout"))
|
||||
except:
|
||||
timeout = 0.5
|
||||
try:
|
||||
min_count = int(request.GET.first("min_count"))
|
||||
min_count = int(request.GET.first(b"min_count"))
|
||||
except:
|
||||
min_count = 1
|
||||
return [("Content-Type", "application/json")], retrieve_from_stash(request, key, timeout, min_count, '[]')
|
||||
return [(b"Content-Type", b"application/json")], retrieve_from_stash(request, key, timeout, min_count, u'[]')
|
||||
|
||||
# append new reports
|
||||
new_reports = json.loads(request.body)
|
||||
for report in new_reports:
|
||||
report["metadata"] = {
|
||||
"content_type": request.headers["Content-Type"],
|
||||
report[u"metadata"] = {
|
||||
b"content_type": request.headers[b"Content-Type"],
|
||||
}
|
||||
with request.server.stash.lock:
|
||||
reports = request.server.stash.take(key=key)
|
||||
|
@ -54,4 +54,4 @@ def main(request, response):
|
|||
request.server.stash.put(key=key, value=reports)
|
||||
|
||||
# return acknowledgement report
|
||||
return [("Content-Type", "text/plain")], "Recorded report"
|
||||
return [(b"Content-Type", b"text/plain")], u"Recorded report"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue