Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python 3: port tests in clear-site-data etc. (#24081)
It includes porting tests for the following directories: clear-site-data signed-exchange web-animation scroll-to-text-fragment preload
- Loading branch information
Showing
8 changed files
with
46 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
def main(request, response): | ||
return ([("Content-Type", "text/html")], | ||
"FROM_NETWORK") | ||
return ([(b"Content-Type", b"text/html")], | ||
u"FROM_NETWORK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
def main(request, response): | ||
headers = [ | ||
("Content-Type", "text/javascript"), | ||
("Access-Control-Allow-Origin", request.headers.get("Origin")), | ||
("Timing-Allow-Origin", request.headers.get("Origin")), | ||
("Access-Control-Allow-Credentials", "true") | ||
(b"Content-Type", b"text/javascript"), | ||
(b"Access-Control-Allow-Origin", request.headers.get(b"Origin")), | ||
(b"Timing-Allow-Origin", request.headers.get(b"Origin")), | ||
(b"Access-Control-Allow-Credentials", b"true") | ||
] | ||
|
||
return headers, "// Cross-origin module, nothing to see here" | ||
return headers, u"// Cross-origin module, nothing to see here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import time | ||
|
||
def main(request, response): | ||
key = request.GET.first("key") | ||
key = request.GET.first(b"key") | ||
|
||
if request.method == "POST": | ||
if request.method == u"POST": | ||
# Received result data from target page | ||
request.server.stash.put(key, request.body, '/scroll-to-text-fragment/') | ||
return "ok" | ||
request.server.stash.put(key, request.body, u'/scroll-to-text-fragment/') | ||
return u"ok" | ||
else: | ||
# Request for result data from test page | ||
value = request.server.stash.take(key, '/scroll-to-text-fragment/') | ||
value = request.server.stash.take(key, u'/scroll-to-text-fragment/') | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import os | ||
|
||
from wptserve.utils import isomorphic_decode | ||
|
||
def main(request, response): | ||
CertChainMimeType = "application/cert-chain+cbor" | ||
CertChainMimeType = b"application/cert-chain+cbor" | ||
|
||
if request.headers.get("Accept") != CertChainMimeType: | ||
return 400, [], "Bad Request" | ||
if request.headers.get(b"Accept") != CertChainMimeType: | ||
return 400, [], u"Bad Request" | ||
|
||
path = os.path.join(os.path.dirname(__file__), "127.0.0.1.sxg.pem.cbor") | ||
body = open(path, "rb").read() | ||
return 200, [("Content-Type", CertChainMimeType)], body | ||
path = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"127.0.0.1.sxg.pem.cbor") | ||
body = open(path, u"rb").read() | ||
return 200, [(b"Content-Type", CertChainMimeType)], body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import os | ||
|
||
from wptserve.utils import isomorphic_decode | ||
|
||
def main(request, response): | ||
stash_id = request.GET.first("id") | ||
stash_id = request.GET.first(b"id") | ||
if request.server.stash.take(stash_id) is not None: | ||
response.status = (404, "Not Found") | ||
response.headers.set("Content-Type", "text/plain") | ||
return "not found" | ||
response.status = (404, u"Not Found") | ||
response.headers.set(b"Content-Type", b"text/plain") | ||
return u"not found" | ||
request.server.stash.put(stash_id, True) | ||
|
||
path = os.path.join(os.path.dirname(__file__), "127.0.0.1.sxg.pem.cbor") | ||
body = open(path, "rb").read() | ||
path = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"127.0.0.1.sxg.pem.cbor") | ||
body = open(path, u"rb").read() | ||
|
||
response.headers.set("Content-Type", "application/cert-chain+cbor") | ||
response.headers.set("Cache-Control", "public, max-age=600") | ||
response.headers.set(b"Content-Type", b"application/cert-chain+cbor") | ||
response.headers.set(b"Cache-Control", b"public, max-age=600") | ||
return body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import os | ||
|
||
from wptserve.utils import isomorphic_decode | ||
|
||
def main(request, response): | ||
stash_id = request.GET.first("id") | ||
stash_id = request.GET.first(b"id") | ||
if request.server.stash.take(stash_id) is not None: | ||
response.status = (404, "Not Found") | ||
response.headers.set("Content-Type", "text/plain") | ||
return "not found" | ||
response.status = (404, u"Not Found") | ||
response.headers.set(b"Content-Type", b"text/plain") | ||
return u"not found" | ||
request.server.stash.put(stash_id, True) | ||
|
||
path = os.path.join(os.path.dirname(__file__), "sxg", "sxg-prefetch-test.sxg") | ||
body = open(path, "rb").read() | ||
path = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"sxg", u"sxg-prefetch-test.sxg") | ||
body = open(path, u"rb").read() | ||
|
||
response.headers.set("Content-Type", "application/signed-exchange;v=b3") | ||
response.headers.set("X-Content-Type-Options", "nosniff") | ||
response.headers.set("Cache-Control", "public, max-age=600") | ||
response.headers.set(b"Content-Type", b"application/signed-exchange;v=b3") | ||
response.headers.set(b"X-Content-Type-Options", b"nosniff") | ||
response.headers.set(b"Cache-Control", b"public, max-age=600") | ||
|
||
return body.replace('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', stash_id) | ||
return body.replace(b'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', stash_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
def main(request, response): | ||
headers = [("Content-type", "text/html;charset=utf-8")] | ||
content = "<!doctype html><div id=test></div>" | ||
headers = [(b"Content-type", b"text/html;charset=utf-8")] | ||
content = u"<!doctype html><div id=test></div>" | ||
|
||
return headers, content |