Update web-platform-tests to revision 592e2ed83ecd717392d37047536250ba74f1bafa

This commit is contained in:
WPT Sync Bot 2018-03-28 21:12:37 -04:00
parent c8b0dc965d
commit 0a3e19aac8
65 changed files with 1906 additions and 106 deletions

View file

@ -12,6 +12,12 @@ def maximize(session):
return session.transport.send("POST", "session/%s/window/maximize" % session.session_id)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the Fullscreen API specification.
# Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
# 10.7.3 Maximize Window
@ -137,11 +143,11 @@ def test_fully_exit_fullscreen(session):
"""
session.window.fullscreen()
assert session.execute_script("return window.fullScreen") is True
assert is_fullscreen(session) is True
response = maximize(session)
assert_success(response)
assert session.execute_script("return window.fullScreen") is False
assert is_fullscreen(session) is False
def test_restore_the_window(session):

View file

@ -51,6 +51,39 @@ def test_find_element(session, using, value):
assert_success(response)
@pytest.mark.parametrize("document,value", [
("<a href=#>link text</a>", "link text"),
("<a href=#>&nbsp;link text&nbsp;</a>", "link text"),
("<a href=#>link<br>text</a>", "link\ntext"),
("<a href=#>link&amp;text</a>", "link&text"),
("<a href=#>LINK TEXT</a>", "LINK TEXT"),
("<a href=# style='text-transform: uppercase'>link text</a>", "LINK TEXT"),
])
def test_find_element_link_text(session, document, value):
# Step 8 - 9
session.url = inline(document)
response = find_element(session, "link text", value)
assert_success(response)
@pytest.mark.parametrize("document,value", [
("<a href=#>partial link text</a>", "link"),
("<a href=#>&nbsp;partial link text&nbsp;</a>", "link"),
("<a href=#>partial link text</a>", "k t"),
("<a href=#>partial link<br>text</a>", "k\nt"),
("<a href=#>partial link&amp;text</a>", "k&t"),
("<a href=#>PARTIAL LINK TEXT</a>", "LINK"),
("<a href=# style='text-transform: uppercase'>partial link text</a>", "LINK"),
])
def test_find_element_partial_link_text(session, document, value):
# Step 8 - 9
session.url = inline(document)
response = find_element(session, "partial link text", value)
assert_success(response)
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
@ -65,7 +98,8 @@ def test_no_element(session, using, value):
("tag name", "a"),
("xpath", "//*[name()='a']")])
def test_xhtml_namespace(session, using, value):
session.url = inline("""<a href="#" id="linkText">full link text</a>""", doctype="xhtml")
session.url = inline("""<a href="#" id="linkText">full link text</a>""",
doctype="xhtml")
expected = session.execute_script("return document.links[0]")
response = find_element(session, using, value)

View file

@ -31,7 +31,6 @@ def test_closed_context(session, create_window):
session.close()
response = find_element(session, "notReal", "css selector", "foo")
assert_error(response, "no such window")
@ -49,6 +48,41 @@ def test_find_element(session, using, value):
assert_success(response)
@pytest.mark.parametrize("document,value", [
("<a href=#>link text</a>", "link text"),
("<a href=#>&nbsp;link text&nbsp;</a>", "link text"),
("<a href=#>link<br>text</a>", "link\ntext"),
("<a href=#>link&amp;text</a>", "link&text"),
("<a href=#>LINK TEXT</a>", "LINK TEXT"),
("<a href=# style='text-transform: uppercase'>link text</a>", "LINK TEXT"),
])
def test_find_element_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<div>{0}</div>".format(document))
element = session.find.css("div", all=False)
response = find_element(session, element.id, "link text", value)
assert_success(response)
@pytest.mark.parametrize("document,value", [
("<a href=#>partial link text</a>", "link"),
("<a href=#>&nbsp;partial link text&nbsp;</a>", "link"),
("<a href=#>partial link text</a>", "k t"),
("<a href=#>partial link<br>text</a>", "k\nt"),
("<a href=#>partial link&amp;text</a>", "k&t"),
("<a href=#>PARTIAL LINK TEXT</a>", "LINK"),
("<a href=# style='text-transform: uppercase'>partial link text</a>", "LINK"),
])
def test_find_element_partial_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<div>{0}</div>".format(document))
element = session.find.css("div", all=False)
response = find_element(session, element.id, "partial link text", value)
assert_success(response)
@pytest.mark.parametrize("using,value",[("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
@ -65,7 +99,8 @@ def test_no_element(session, using, value):
("tag name", "a"),
("xpath", "//*[name()='a']")])
def test_xhtml_namespace(session, using, value):
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""",
doctype="xhtml")
from_element = session.execute_script("""return document.querySelector("p")""")
expected = session.execute_script("return document.links[0]")

View file

@ -30,10 +30,7 @@ def test_closed_context(session, create_window):
session.window_handle = new_window
session.close()
response = session.transport.send("POST",
"session/%s/elements" % session.session_id,
{"using": "css selector", "value": "foo"})
response = find_elements(session, "css selector", "foo")
assert_error(response, "no such window")
@ -52,6 +49,51 @@ def test_find_elements(session, using, value):
assert len(response.body["value"]) == 1
@pytest.mark.parametrize("document,value", [
("<a href=#>link text</a>", "link text"),
("<a href=#>&nbsp;link text&nbsp;</a>", "link text"),
("<a href=#>link<br>text</a>", "link\ntext"),
("<a href=#>link&amp;text</a>", "link&text"),
("<a href=#>LINK TEXT</a>", "LINK TEXT"),
("<a href=# style='text-transform: uppercase'>link text</a>", "LINK TEXT"),
])
def test_find_elements_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<a href=#>not wanted</a><br/>{0}".format(document))
expected = session.execute_script("return document.links[1];")
response = find_elements(session, "link text", value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
@pytest.mark.parametrize("document,value", [
("<a href=#>partial link text</a>", "link"),
("<a href=#>&nbsp;partial link text&nbsp;</a>", "link"),
("<a href=#>partial link text</a>", "k t"),
("<a href=#>partial link<br>text</a>", "k\nt"),
("<a href=#>partial link&amp;text</a>", "k&t"),
("<a href=#>PARTIAL LINK TEXT</a>", "LINK"),
("<a href=# style='text-transform: uppercase'>partial link text</a>", "LINK"),
])
def test_find_elements_partial_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<a href=#>not wanted</a><br/>{0}".format(document))
expected = session.execute_script("return document.links[1];")
response = find_elements(session, "partial link text", value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
@ -67,8 +109,9 @@ def test_no_element(session, using, value):
("tag name", "a"),
("xpath", "//*[name()='a']")])
def test_xhtml_namespace(session, using, value):
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
expected = session.execute_script("return document.links[0]")
session.url = inline("""<a href="#" id="linkText">full link text</a>""",
doctype="xhtml")
expected = session.execute_script("return document.links[0];")
response = find_elements(session, using, value)
value = assert_success(response)

View file

@ -48,6 +48,53 @@ def test_find_elements(session, using, value):
assert_success(response)
@pytest.mark.parametrize("document,value", [
("<a href=#>link text</a>", "link text"),
("<a href=#>&nbsp;link text&nbsp;</a>", "link text"),
("<a href=#>link<br>text</a>", "link\ntext"),
("<a href=#>link&amp;text</a>", "link&text"),
("<a href=#>LINK TEXT</a>", "LINK TEXT"),
("<a href=# style='text-transform: uppercase'>link text</a>", "LINK TEXT"),
])
def test_find_elements_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<div><a href=#>not wanted</a><br/>{0}</div>".format(document))
element = session.find.css("div", all=False)
expected = session.execute_script("return document.links[1];")
response = find_elements(session, element.id, "link text", value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
@pytest.mark.parametrize("document,value", [
("<a href=#>partial link text</a>", "link"),
("<a href=#>&nbsp;partial link text&nbsp;</a>", "link"),
("<a href=#>partial link text</a>", "k t"),
("<a href=#>partial link<br>text</a>", "k\nt"),
("<a href=#>partial link&amp;text</a>", "k&t"),
("<a href=#>PARTIAL LINK TEXT</a>", "LINK"),
("<a href=# style='text-transform: uppercase'>partial link text</a>", "LINK"),
])
def test_find_elements_partial_link_text(session, document, value):
# Step 8 - 9
session.url = inline("<div><a href=#>not wanted</a><br/>{0}</div>".format(document))
element = session.find.css("div", all=False)
expected = session.execute_script("return document.links[1];")
response = find_elements(session, element.id, "partial link text", value)
value = assert_success(response)
assert isinstance(value, list)
assert len(value) == 1
found_element = value[0]
assert_same_element(session, found_element, expected)
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
def test_no_element(session, using, value):
# Step 8 - 9
@ -64,7 +111,8 @@ def test_no_element(session, using, value):
("tag name", "a"),
("xpath", "//*[name()='a']")])
def test_xhtml_namespace(session, using, value):
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""", doctype="xhtml")
session.url = inline("""<p><a href="#" id="linkText">full link text</a></p>""",
doctype="xhtml")
from_element = session.execute_script("""return document.querySelector("p")""")
expected = session.execute_script("return document.links[0]")

View file

@ -16,6 +16,12 @@ def fullscreen(session):
return session.transport.send("POST", "session/%s/window/fullscreen" % session.session_id)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the Fullscreen API specification.
# Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
# 10.7.5 Fullscreen Window
@ -135,11 +141,6 @@ def test_handle_prompt_missing_value(session, create_dialog):
assert read_global(session, "dismiss3") == None
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the Fullscreen API specification.
# Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
def test_fullscreen(session):
"""
4. Call fullscreen an element with the current top-level browsing

View file

@ -10,6 +10,11 @@ def minimize(session):
return session.transport.send("POST", "session/%s/window/minimize" % session.session_id)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the Fullscreen API specification.
# Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
# 10.7.4 Minimize Window
@ -135,11 +140,11 @@ def test_fully_exit_fullscreen(session):
"""
session.window.fullscreen()
assert session.execute_script("return window.fullScreen") is True
assert is_fullscreen(session) is True
response = minimize(session)
assert_success(response)
assert session.execute_script("return window.fullScreen") is False
assert is_fullscreen(session) is False
assert session.execute_script("return document.hidden") is True

View file

@ -13,6 +13,11 @@ alert_doc = inline("<script>window.alert()</script>")
def set_window_rect(session, rect):
return session.transport.send("POST", "session/%s/window/rect" % session.session_id, rect)
def is_fullscreen(session):
# At the time of writing, WebKit does not conform to the Fullscreen API specification.
# Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
# 10.7.2 Set Window Rect
@ -293,14 +298,14 @@ def test_fully_exit_fullscreen(session):
3. Exit fullscreen document.
"""
session.window.fullscreen()
assert session.execute_script("return window.fullScreen") is True
assert is_fullscreen(session) is True
response = set_window_rect(session, {"width": 400, "height": 400})
value = assert_success(response)
assert value["width"] == 400
assert value["height"] == 400
assert session.execute_script("return window.fullScreen") is False
assert is_fullscreen(session) is False
def test_restore_from_minimized(session):