mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -1,14 +1,9 @@
|
|||
import json
|
||||
import pytest
|
||||
import types
|
||||
import urllib
|
||||
|
||||
import webdriver
|
||||
|
||||
|
||||
def inline(doc):
|
||||
return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
|
||||
|
||||
from support.inline import inline
|
||||
from support.asserts import assert_error, assert_success
|
||||
|
||||
alert_doc = inline("<script>window.alert()</script>")
|
||||
frame_doc = inline("<p>frame")
|
||||
|
@ -16,89 +11,83 @@ one_frame_doc = inline("<iframe src='%s'></iframe>" % frame_doc)
|
|||
two_frames_doc = inline("<iframe src='%s'></iframe>" % one_frame_doc)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def new_window(session):
|
||||
"""Open new window and return the window handle."""
|
||||
windows_before = session.window_handles
|
||||
name = session.execute_script("window.open()")
|
||||
assert len(session.window_handles) == len(windows_before) + 1
|
||||
new_windows = session.window_handles - windows_before
|
||||
return new_windows.pop()
|
||||
|
||||
|
||||
# TODO(ato): 7.1 Get
|
||||
|
||||
|
||||
def test_get_current_url_no_browsing_context(session, new_window):
|
||||
def test_get_current_url_no_browsing_context(session, create_window):
|
||||
# 7.2 step 1
|
||||
session.window_handle = new_window
|
||||
session.window_handle = create_window()
|
||||
session.close()
|
||||
with pytest.raises(webdriver.NoSuchWindowException):
|
||||
session.url = "about:blank"
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
assert_error(result, "no such window")
|
||||
|
||||
|
||||
def test_get_current_url_alert_prompt(session):
|
||||
# 7.2 step 2
|
||||
session.url = alert_doc
|
||||
with pytest.raises(webdriver.UnexpectedAlertOpenException):
|
||||
session.url = "about:blank"
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
assert_error(result, "unexpected alert open")
|
||||
|
||||
def test_get_current_url_matches_location(session):
|
||||
# 7.2 step 3
|
||||
url = session.execute_script("return window.location.href")
|
||||
assert session.url == url
|
||||
|
||||
|
||||
def test_get_current_url_payload(http, session):
|
||||
def test_get_current_url_payload(session):
|
||||
# 7.2 step 4-5
|
||||
session.start()
|
||||
with http.get("/session/%s/url" % session.session_id) as resp:
|
||||
assert resp.status == 200
|
||||
body = json.load(resp)
|
||||
assert "value" in body
|
||||
assert isinstance(body["value"], types.StringTypes)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
assert result.status == 200
|
||||
assert isinstance(result.body["value"], basestring)
|
||||
|
||||
def test_get_current_url_special_pages(session):
|
||||
session.url = "about:blank"
|
||||
assert session.url == "about:blank"
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
"""
|
||||
Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=1332122
|
||||
assert_success(result, "about:blank")
|
||||
|
||||
# TODO(ato): This test requires modification to pass on Windows
|
||||
def test_get_current_url_file_protocol(session):
|
||||
# tests that the browsing context remains the same
|
||||
# when navigated privileged documents
|
||||
session.url = "file:///"
|
||||
assert session.url == "file:///"
|
||||
"""
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
assert_success(result, "file:///")
|
||||
|
||||
# TODO(ato): Test for http:// and https:// protocols.
|
||||
# We need to expose a fixture for accessing
|
||||
# documents served by wptserve in order to test this.
|
||||
|
||||
def test_set_malformed_url(session):
|
||||
result = session.transport.send("POST",
|
||||
"session/%s/url" % session.session_id,
|
||||
{"url": "foo"})
|
||||
|
||||
def test_get_current_url_malformed_url(session):
|
||||
session.url = "foo"
|
||||
assert session.url
|
||||
|
||||
assert_error(result, "invalid argument")
|
||||
|
||||
def test_get_current_url_after_modified_location(session):
|
||||
session.execute_script("window.location.href = 'about:blank'")
|
||||
assert session.url == "about:blank"
|
||||
session.execute_script("window.location.href = 'about:blank#wd_test_modification'")
|
||||
|
||||
result = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
def test_get_current_url_nested_browsing_context(session):
|
||||
session.url = one_frame_doc
|
||||
top_level_url = session.url
|
||||
frame = session.find.css("iframe", all=False)
|
||||
session.switch_frame(frame)
|
||||
assert session.url == top_level_url
|
||||
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 = session.transport.send("GET", "session/%s/url" % session.session_id)
|
||||
|
||||
assert_success(result, "about:blank#wd_from_within_frame")
|
||||
|
||||
def test_get_current_url_nested_browsing_contexts(session):
|
||||
session.url = two_frames_doc
|
||||
|
@ -108,6 +97,6 @@ def test_get_current_url_nested_browsing_contexts(session):
|
|||
session.switch_frame(outer_frame)
|
||||
|
||||
inner_frame = session.find.css("iframe", all=False)
|
||||
session.switch_frame(frame)
|
||||
session.switch_frame(inner_frame)
|
||||
|
||||
assert session.url == top_level_url
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue