summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/resources/check-cookie.py
blob: 90551e92c336d7923450c4f86b92ee338d996d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def main(request, response):
    headers = [
        (b"Content-Type", b"text/javascript"),
        (b"Access-Control-Allow-Origin", request.GET.first(b"origin")),
        (b"Access-Control-Allow-Credentials", b"true")
    ]
    identifier = request.GET.first(b"id")
    cookie_name = request.GET.first(b"cookieName")
    cookie = request.cookies.first(cookie_name, None)
    if identifier is None or cookie_name is None:
        return headers, b""

    if cookie is None:
        result = b"not found"
    elif cookie.value == b"1":
        result = b"found"
    else:
        result = b"different value: " + cookie.value

    return headers, b"window." + identifier + b" = '" + result + b"';"