mirror of
https://github.com/servo/servo.git
synced 2025-08-24 14:48:21 +01:00
Update web-platform-tests to revision 6c2d23b1b5e4dc00c944eedd16a11850e74a2d11
This commit is contained in:
parent
ad83faa745
commit
0114122fe0
140 changed files with 4328 additions and 1419 deletions
|
@ -1,5 +1,7 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.fixtures import clear_all_cookies
|
||||
|
||||
|
@ -10,6 +12,12 @@ def add_cookie(session, cookie):
|
|||
{"cookie": cookie})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/cookie".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session, url):
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver import Element
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
@ -14,6 +15,16 @@ def element_send_keys(session, element, text):
|
|||
{"text": text})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
|
||||
path = "/session/{session_id}/element/{element_id}/value".format(
|
||||
session_id=session.session_id, element_id=element.id)
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
|
@ -13,6 +15,12 @@ def execute_async_script(session, script, args=None):
|
|||
body)
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/execute/async".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = execute_async_script(session, "argument[0](1);")
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
|
@ -14,6 +16,12 @@ def execute_script(session, script, args=None):
|
|||
body)
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/execute/sync".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = execute_script(session, "return 1;")
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_same_element, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -10,6 +12,12 @@ def find_element(session, using, value):
|
|||
{"using": using, "value": value})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/element".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = find_element(session, "css selector", "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_same_element, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -12,6 +14,16 @@ def find_element(session, element_id, using, value):
|
|||
{"using": using, "value": value})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
session.url = inline("<div><a href=# id=linkText>full link text</a></div>")
|
||||
element = session.find.css("div", all=False)
|
||||
|
||||
path = "/session/{session_id}/element/{element_id}/element".format(
|
||||
session_id=session.session_id, element_id=element.id)
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = find_element(session, "notReal", "css selector", "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
@ -80,7 +92,7 @@ def test_find_element_partial_link_text(session, document, value):
|
|||
assert_success(response)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("using,value",[("css selector", "#wontExist")])
|
||||
@pytest.mark.parametrize("using,value", [("css selector", "#wontExist")])
|
||||
def test_no_element(session, using, value):
|
||||
# Step 8 - 9
|
||||
session.url = inline("<div></div>")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_same_element, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -10,6 +12,12 @@ def find_elements(session, using, value):
|
|||
{"using": using, "value": value})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/elements".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = find_elements(session, "css selector", "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_same_element, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -12,6 +14,16 @@ def find_elements(session, element_id, using, value):
|
|||
{"using": using, "value": value})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
session.url = inline("<div><a href=# id=linkText>full link text</a></div>")
|
||||
element = session.find.css("div", all=False)
|
||||
|
||||
path = "/session/{session_id}/element/{element_id}/elements".format(
|
||||
session_id=session.session_id, element_id=element.id)
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = find_elements(session, "notReal", "css selector", "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
def get_window_handle(session):
|
||||
return session.transport.send(
|
||||
"GET", "session/{session_id}/window".format(**vars(session)))
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = get_window_handle(session)
|
||||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_basic(session):
|
||||
response = get_window_handle(session)
|
||||
assert_success(response, session.window_handle)
|
|
@ -0,0 +1,61 @@
|
|||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_success
|
||||
|
||||
|
||||
def get_window_handle(session):
|
||||
return session.transport.send(
|
||||
"GET", "session/{session_id}/window".format(**vars(session)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
window_handle = session.window_handle
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = get_window_handle(session)
|
||||
assert_success(response, window_handle)
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept_and_notify(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss_and_notify(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_default(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
|
@ -0,0 +1,38 @@
|
|||
from tests.support.asserts import assert_success
|
||||
|
||||
|
||||
def get_window_handles(session):
|
||||
return session.transport.send(
|
||||
"GET", "session/{session_id}/window/handles".format(**vars(session)))
|
||||
|
||||
|
||||
def test_no_browsing_context(session, create_window):
|
||||
window_handles = session.handles
|
||||
|
||||
new_handle = create_window()
|
||||
session.window_handle = new_handle
|
||||
session.close()
|
||||
|
||||
response = get_window_handles(session)
|
||||
assert_success(response, window_handles)
|
||||
|
||||
|
||||
def test_single_window(session):
|
||||
response = get_window_handles(session)
|
||||
value = assert_success(response)
|
||||
|
||||
assert len(value) == 1
|
||||
assert value == session.handles
|
||||
assert value[0] == session.window_handle
|
||||
|
||||
|
||||
def test_multiple_windows(session, create_window):
|
||||
original_handle = session.window_handle
|
||||
new_handle = create_window()
|
||||
|
||||
response = get_window_handles(session)
|
||||
value = assert_success(response)
|
||||
|
||||
assert len(value) == 2
|
||||
assert original_handle in value
|
||||
assert new_handle in value
|
|
@ -0,0 +1,61 @@
|
|||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_success
|
||||
|
||||
|
||||
def get_window_handles(session):
|
||||
return session.transport.send(
|
||||
"GET", "session/{session_id}/window/handles".format(**vars(session)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
window_handles = session.handles
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = get_window_handles(session)
|
||||
assert_success(response, window_handles)
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept_and_notify(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss_and_notify(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_default(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
|
@ -1,3 +1,5 @@
|
|||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -8,6 +10,12 @@ def navigate_to(session, url):
|
|||
{"url": url})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/url".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session):
|
||||
response = navigate_to(session, inline("<div/>"))
|
||||
value = assert_success(response)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
@ -10,6 +12,12 @@ def send_alert_text(session, text=None):
|
|||
{"text": text})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/alert/text".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session, url):
|
||||
session.url = inline("<script>window.result = window.prompt('Enter Your Name: ', 'Name');</script>")
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from tests.support.asserts import assert_success
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
def set_timeouts(session, timeouts):
|
||||
|
@ -7,6 +9,12 @@ def set_timeouts(session, timeouts):
|
|||
timeouts)
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/timeouts".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session):
|
||||
response = set_timeouts(session, {"implicit": 1000})
|
||||
value = assert_success(response)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import pytest
|
||||
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
|
@ -22,6 +24,12 @@ def is_fullscreen(session):
|
|||
""")
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/window/rect".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = set_window_rect(session, {})
|
||||
assert_error(response, "no such window")
|
||||
|
|
|
@ -294,10 +294,11 @@ def clear_all_cookies(session):
|
|||
|
||||
|
||||
def closed_window(session, create_window):
|
||||
new_handle = create_window()
|
||||
original_handle = session.window_handle
|
||||
|
||||
new_handle = create_window()
|
||||
session.window_handle = new_handle
|
||||
|
||||
session.close()
|
||||
assert new_handle not in session.handles, "Unable to close window {}".format(new_handle)
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import contextlib
|
||||
import httplib
|
||||
import json
|
||||
|
||||
from six import text_type
|
||||
|
||||
|
||||
class HTTPRequest(object):
|
||||
|
@ -13,11 +16,26 @@ class HTTPRequest(object):
|
|||
def get(self, path):
|
||||
return self._request("GET", path)
|
||||
|
||||
def post(self, path, body):
|
||||
return self._request("POST", path, body)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _request(self, method, path):
|
||||
def _request(self, method, path, body=None):
|
||||
payload = None
|
||||
|
||||
if body is not None:
|
||||
try:
|
||||
payload = json.dumps(body)
|
||||
except ValueError:
|
||||
raise ValueError("Failed to encode request body as JSON: {}".format(
|
||||
json.dumps(body, indent=2)))
|
||||
|
||||
if isinstance(payload, text_type):
|
||||
payload = body.encode("utf-8")
|
||||
|
||||
conn = httplib.HTTPConnection(self.host, self.port)
|
||||
try:
|
||||
conn.request(method, path)
|
||||
conn.request(method, path, payload)
|
||||
yield conn.getresponse()
|
||||
finally:
|
||||
conn.close()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import webdriver.protocol as protocol
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.inline import inline, iframe
|
||||
|
@ -12,6 +13,12 @@ def switch_to_frame(session, frame):
|
|||
session=session)
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/frame".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session):
|
||||
session.url = inline(iframe("<p>foo"))
|
||||
frame_element = session.find.css("iframe", all=False)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from tests.support.asserts import assert_success
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
def switch_to_window(session, handle):
|
||||
|
@ -7,6 +9,12 @@ def switch_to_window(session, handle):
|
|||
{"handle": handle})
|
||||
|
||||
|
||||
def test_null_parameter_value(session, http):
|
||||
path = "/session/{session_id}/window".format(**vars(session))
|
||||
with http.post(path, None) as response:
|
||||
assert_error(Response.from_http(response), "invalid argument")
|
||||
|
||||
|
||||
def test_null_response_value(session, create_window):
|
||||
new_handle = create_window()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue