mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision 0d4300c5045a5587c2eb3d1416b11ffeecf5dadc
This commit is contained in:
parent
555fa75b2c
commit
9f1d1e8b63
111 changed files with 1744 additions and 631 deletions
|
@ -63,6 +63,7 @@ def test_html_all_collection(session):
|
|||
""")
|
||||
html = session.find.css("html", all=False)
|
||||
head = session.find.css("head", all=False)
|
||||
meta = session.find.css("meta", all=False)
|
||||
body = session.find.css("body", all=False)
|
||||
ps = session.find.css("p")
|
||||
|
||||
|
@ -72,14 +73,15 @@ def test_html_all_collection(session):
|
|||
""")
|
||||
value = assert_success(response)
|
||||
assert isinstance(value, list)
|
||||
# <html>, <head>, <body>, <p>, <p>
|
||||
assert len(value) == 5
|
||||
# <html>, <head>, <meta>, <body>, <p>, <p>
|
||||
assert len(value) == 6
|
||||
|
||||
assert_same_element(session, html, value[0])
|
||||
assert_same_element(session, head, value[1])
|
||||
assert_same_element(session, body, value[2])
|
||||
assert_same_element(session, ps[0], value[3])
|
||||
assert_same_element(session, ps[1], value[4])
|
||||
assert_same_element(session, meta, value[2])
|
||||
assert_same_element(session, body, value[3])
|
||||
assert_same_element(session, ps[0], value[4])
|
||||
assert_same_element(session, ps[1], value[5])
|
||||
|
||||
|
||||
def test_html_collection(session):
|
||||
|
|
|
@ -56,20 +56,22 @@ def test_html_all_collection(session):
|
|||
""")
|
||||
html = session.find.css("html", all=False)
|
||||
head = session.find.css("head", all=False)
|
||||
meta = session.find.css("meta", all=False)
|
||||
body = session.find.css("body", all=False)
|
||||
ps = session.find.css("p")
|
||||
|
||||
response = execute_script(session, "return document.all")
|
||||
value = assert_success(response)
|
||||
assert isinstance(value, list)
|
||||
# <html>, <head>, <body>, <p>, <p>
|
||||
assert len(value) == 5
|
||||
# <html>, <head>, <meta>, <body>, <p>, <p>
|
||||
assert len(value) == 6
|
||||
|
||||
assert_same_element(session, html, value[0])
|
||||
assert_same_element(session, head, value[1])
|
||||
assert_same_element(session, body, value[2])
|
||||
assert_same_element(session, ps[0], value[3])
|
||||
assert_same_element(session, ps[1], value[4])
|
||||
assert_same_element(session, meta, value[2])
|
||||
assert_same_element(session, body, value[3])
|
||||
assert_same_element(session, ps[0], value[4])
|
||||
assert_same_element(session, ps[1], value[5])
|
||||
|
||||
|
||||
def test_html_collection(session):
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
"""Helpers for inlining extracts of documents in tests."""
|
||||
|
||||
import urllib
|
||||
|
||||
|
||||
def inline(doc,
|
||||
doctype="html",
|
||||
mime="text/html;charset=utf-8",
|
||||
**kwargs):
|
||||
from .fixtures import server_config, url
|
||||
build_url = url(server_config())
|
||||
|
||||
if doctype == "html":
|
||||
mime = "text/html;charset=utf-8"
|
||||
elif doctype == "xhtml":
|
||||
mime = "application/xhtml+xml"
|
||||
doc = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
BOILERPLATES = {
|
||||
"html": "<!doctype html>\n<meta charset={charset}>\n{src}",
|
||||
"xhtml": """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
@ -20,35 +13,77 @@ def inline(doc,
|
|||
</head>
|
||||
|
||||
<body>
|
||||
{}
|
||||
{src}
|
||||
</body>
|
||||
</html>""".format(doc)
|
||||
elif doctype == "xml":
|
||||
mime = "text/xml"
|
||||
doc = """<?xml version="1.0" encoding="UTF-8"?>{}""".format(doc)
|
||||
</html>""",
|
||||
"xml": """<?xml version="1.0" encoding="{charset}"?>\n{src}""",
|
||||
}
|
||||
MIME_TYPES = {
|
||||
"html": "text/html",
|
||||
"xhtml": "application/xhtml+xml",
|
||||
"xml": "text/xml",
|
||||
}
|
||||
|
||||
query = {"doc": doc}
|
||||
if mime != "text/html;charset=utf8":
|
||||
query["content-type"] = mime
|
||||
def inline(src, doctype="html", mime=None, charset=None, **kwargs):
|
||||
"""
|
||||
Takes a source extract and produces well-formed documents.
|
||||
|
||||
return build_url("/webdriver/tests/support/inline.py",
|
||||
query=urllib.urlencode(query),
|
||||
**kwargs)
|
||||
Based on the desired document type, the extract is embedded with
|
||||
predefined boilerplate in order to produce well-formed documents.
|
||||
The media type and character set may also be individually configured.
|
||||
|
||||
This helper function originally used data URLs, but since these
|
||||
are not universally supported (or indeed standardised!) across
|
||||
browsers, it now delegates the serving of the document to wptserve.
|
||||
This file also acts as a wptserve handler (see the main function
|
||||
below) which configures the HTTP response using query parameters.
|
||||
|
||||
This function returns a URL to the wptserve handler, which in turn
|
||||
will serve an HTTP response with the requested source extract
|
||||
inlined in a well-formed document, and the Content-Type header
|
||||
optionally configured using the desired media type and character set.
|
||||
|
||||
Any additional keyword arguments are passed on to the build_url
|
||||
function.
|
||||
"""
|
||||
from .fixtures import server_config, url
|
||||
build_url = url(server_config())
|
||||
|
||||
if mime is None:
|
||||
mime = MIME_TYPES[doctype]
|
||||
if charset is None:
|
||||
charset = "UTF-8"
|
||||
doc = BOILERPLATES[doctype].format(charset=charset, src=src)
|
||||
|
||||
query = {"doc": doc, "mime": mime, "charset": charset}
|
||||
return build_url(
|
||||
"/webdriver/tests/support/inline.py",
|
||||
query=urllib.urlencode(query),
|
||||
**kwargs)
|
||||
|
||||
|
||||
def iframe(doc, **kwargs):
|
||||
return "<iframe src='%s'></iframe>" % inline(doc, **kwargs)
|
||||
def iframe(src, **kwargs):
|
||||
"""Inlines document extract as the source document of an <iframe>."""
|
||||
return "<iframe src='{}'></iframe>".format(inline(src, **kwargs))
|
||||
|
||||
|
||||
def main(request, response):
|
||||
doc = request.GET.first("doc", None)
|
||||
content_type = request.GET.first("content-type", "text/html;charset=utf8")
|
||||
mime = request.GET.first("mime", None)
|
||||
charset = request.GET.first("charset", None)
|
||||
|
||||
if doc is None:
|
||||
rv = 404, [("Content-Type", "text/plain")], "Missing doc parameter in query"
|
||||
else:
|
||||
response.headers.update([
|
||||
("Content-Type", content_type),
|
||||
("X-XSS-Protection", "0")
|
||||
])
|
||||
rv = doc
|
||||
return rv
|
||||
return 404, [("Content-Type",
|
||||
"text/plain")], "Missing doc parameter in query"
|
||||
|
||||
content_type = []
|
||||
if mime is not None:
|
||||
content_type.append(mime)
|
||||
if charset is not None:
|
||||
content_type.append("charset={}".format(charset))
|
||||
|
||||
headers = {"X-XSS-Protection": "0"}
|
||||
if len(content_type) > 0:
|
||||
headers["Content-Type"] = ";".join(content_type)
|
||||
|
||||
return 200, headers.items(), doc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue