mirror of
https://github.com/servo/servo.git
synced 2025-08-27 16:18:21 +01:00
Update web-platform-tests to revision 38bd28fe2368c650cf6e57be205cf3118dbd4997
This commit is contained in:
parent
a28e15e4ea
commit
85fe63f512
165 changed files with 2144 additions and 2644 deletions
|
@ -1,7 +1,4 @@
|
|||
import json
|
||||
import pytest
|
||||
import types
|
||||
|
||||
from tests.support import platform_name
|
||||
from tests.support.inline import inline
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.sync import Poll
|
||||
|
@ -25,33 +22,36 @@ def test_no_browsing_context(session, closed_window):
|
|||
def test_get_current_url_matches_location(session):
|
||||
url = session.execute_script("return window.location.href")
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, url)
|
||||
response = get_current_url(session)
|
||||
assert_success(response, url)
|
||||
|
||||
|
||||
def test_get_current_url_payload(session):
|
||||
session.start()
|
||||
|
||||
result = get_current_url(session)
|
||||
assert result.status == 200
|
||||
assert isinstance(result.body["value"], basestring)
|
||||
response = get_current_url(session)
|
||||
assert response.status == 200
|
||||
assert isinstance(response.body["value"], basestring)
|
||||
|
||||
|
||||
def test_get_current_url_special_pages(session):
|
||||
session.url = "about:blank"
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, "about:blank")
|
||||
response = get_current_url(session)
|
||||
assert_success(response, "about:blank")
|
||||
|
||||
|
||||
# TODO(ato): This test requires modification to pass on Windows
|
||||
def test_get_current_url_file_protocol(session):
|
||||
def test_get_current_url_file_protocol(session, server_config):
|
||||
# tests that the browsing context remains the same
|
||||
# when navigated privileged documents
|
||||
session.url = "file:///"
|
||||
path = server_config["doc_root"]
|
||||
if platform_name == "windows":
|
||||
path = path.replace("\\", "/")
|
||||
url = u"file:///{}".format(path)
|
||||
session.url = url
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, "file:///")
|
||||
response = get_current_url(session)
|
||||
assert_success(response, url)
|
||||
|
||||
|
||||
# TODO(ato): Test for http:// and https:// protocols.
|
||||
|
@ -60,27 +60,30 @@ def test_get_current_url_file_protocol(session):
|
|||
|
||||
|
||||
def test_set_malformed_url(session):
|
||||
result = session.transport.send("POST",
|
||||
"session/%s/url" % session.session_id,
|
||||
{"url": "foo"})
|
||||
response = session.transport.send(
|
||||
"POST",
|
||||
"session/%s/url" % session.session_id, {"url": "foo"})
|
||||
|
||||
assert_error(response, "invalid argument")
|
||||
|
||||
assert_error(result, "invalid argument")
|
||||
|
||||
def test_get_current_url_after_modified_location(session):
|
||||
start = get_current_url(session)
|
||||
session.execute_script("window.location.href = 'about:blank#wd_test_modification'")
|
||||
Poll(session, message="URL did not change").until(
|
||||
lambda s: get_current_url(s).body["value"] != start.body["value"])
|
||||
lambda s: get_current_url(s).body["value"] != start.body["value"])
|
||||
|
||||
response = get_current_url(session)
|
||||
assert_success(response, "about:blank#wd_test_modification")
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, "about:blank#wd_test_modification")
|
||||
|
||||
def test_get_current_url_nested_browsing_context(session, create_frame):
|
||||
session.url = "about:blank#wd_from_within_frame"
|
||||
session.switch_frame(create_frame())
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, "about:blank#wd_from_within_frame")
|
||||
response = get_current_url(session)
|
||||
assert_success(response, "about:blank#wd_from_within_frame")
|
||||
|
||||
|
||||
def test_get_current_url_nested_browsing_contexts(session):
|
||||
session.url = two_frames_doc
|
||||
|
@ -92,5 +95,5 @@ def test_get_current_url_nested_browsing_contexts(session):
|
|||
inner_frame = session.find.css("iframe", all=False)
|
||||
session.switch_frame(inner_frame)
|
||||
|
||||
result = get_current_url(session)
|
||||
assert_success(result, top_level_url)
|
||||
response = get_current_url(session)
|
||||
assert_success(response, top_level_url)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from tests.support import platform_name
|
||||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
@ -25,3 +26,17 @@ def test_null_response_value(session):
|
|||
def test_no_browsing_context(session, closed_window):
|
||||
response = navigate_to(session, "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_file_protocol(session, server_config):
|
||||
# tests that the browsing context remains the same
|
||||
# when navigated privileged documents
|
||||
path = server_config["doc_root"]
|
||||
if platform_name == "windows":
|
||||
path = path.replace("\\", "/")
|
||||
url = u"file:///{}".format(path)
|
||||
|
||||
response = navigate_to(session, url)
|
||||
assert_success(response)
|
||||
|
||||
assert session.url == url
|
||||
|
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
from webdriver.transport import Response
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.authentication import basic_authentication
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
|
@ -55,7 +56,14 @@ def test_alert_element_not_interactable(session, dialog_type):
|
|||
assert_error(response, "element not interactable")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text", ["", "Federer", " Fed erer "])
|
||||
def test_alert_unsupported_operation(session):
|
||||
session.url = basic_authentication()
|
||||
|
||||
response = send_alert_text(session, "Federer")
|
||||
assert_error(response, "unsupported operation")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text", ["", "Federer", " Fed erer ", "Fed\terer"])
|
||||
def test_send_alert_text(session, page, text):
|
||||
send_response = send_alert_text(session, text)
|
||||
assert_success(send_response)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import urllib
|
||||
|
||||
|
||||
def basic_authentication(username=None, password=None, protocol="http"):
|
||||
from .fixtures import server_config, url
|
||||
build_url = url(server_config())
|
||||
|
||||
query = {}
|
||||
|
||||
return build_url("/webdriver/tests/support/authentication.py",
|
||||
query=urllib.urlencode(query),
|
||||
protocol=protocol)
|
||||
|
||||
|
||||
def main(request, response):
|
||||
user = request.auth.username
|
||||
password = request.auth.password
|
||||
|
||||
if user == "user" and password == "password":
|
||||
return "Authentication done"
|
||||
|
||||
realm = "test"
|
||||
if "realm" in request.GET:
|
||||
realm = request.GET.first("realm")
|
||||
|
||||
return ((401, "Unauthorized"),
|
||||
[("WWW-Authenticate", 'Basic realm="' + realm + '"')],
|
||||
"Please login with credentials 'user' and 'password'")
|
Loading…
Add table
Add a link
Reference in a new issue