зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1392274 - [wdspec] Add tests for Back navigation command. r=ato
MozReview-Commit-ID: 7ByYkBbqCDo --HG-- extra : rebase_source : 9ca5cf81caddfbbaa8b9ed8d84f3a86f8cd2fbe8
This commit is contained in:
Родитель
63e39943c0
Коммит
ee92424cf5
|
@ -298090,6 +298090,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/back/conftest.py": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/close_window/__init__.py": [
|
||||
[
|
||||
{}
|
||||
|
@ -408620,6 +408625,14 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/back/user_prompts.py": [
|
||||
[
|
||||
"/webdriver/tests/back/user_prompts.py",
|
||||
{
|
||||
"timeout": "long"
|
||||
}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/close_window/close.py": [
|
||||
[
|
||||
"/webdriver/tests/close_window/close.py",
|
||||
|
@ -624138,7 +624151,15 @@
|
|||
"support"
|
||||
],
|
||||
"webdriver/tests/back/back.py": [
|
||||
"0df671f059b0b9064a6a8608163b46042524f7e7",
|
||||
"ae4209c3f47af5e13c0851f73ad3d1f788b7ed56",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/back/conftest.py": [
|
||||
"a15c7372ba9d459ddcc4b5cf4030eb32406b60cf",
|
||||
"support"
|
||||
],
|
||||
"webdriver/tests/back/user_prompts.py": [
|
||||
"53944b4a302d2e1c5cde4e48ff451452d699f7f6",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/close_window/__init__.py": [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from tests.support.inline import inline
|
||||
from tests.support.asserts import assert_success
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
|
||||
|
||||
def back(session):
|
||||
|
@ -14,3 +14,99 @@ def test_null_response_value(session):
|
|||
response = back(session)
|
||||
value = assert_success(response)
|
||||
assert value is None
|
||||
|
||||
|
||||
def test_no_browsing_context(session, create_window):
|
||||
new_handle = create_window()
|
||||
|
||||
session.window_handle = new_handle
|
||||
session.close()
|
||||
assert new_handle not in session.handles
|
||||
|
||||
response = back(session)
|
||||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_no_browsing_history(session):
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
|
||||
|
||||
def test_data_urls(session):
|
||||
test_pages = [
|
||||
inline("<p id=1>"),
|
||||
inline("<p id=2>"),
|
||||
]
|
||||
|
||||
for page in test_pages:
|
||||
session.url = page
|
||||
assert session.url == test_pages[1]
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
assert session.url == test_pages[0]
|
||||
|
||||
|
||||
def test_dismissed_beforeunload(session):
|
||||
url_beforeunload = inline("""
|
||||
<input type="text">
|
||||
<script>
|
||||
window.addEventListener("beforeunload", function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
</script>
|
||||
""")
|
||||
|
||||
session.url = inline("<div id=foo>")
|
||||
session.url = url_beforeunload
|
||||
|
||||
element = session.find.css("input", all=False)
|
||||
element.send_keys("bar")
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
|
||||
assert session.url != url_beforeunload
|
||||
|
||||
|
||||
def test_fragments(session, url):
|
||||
test_pages = [
|
||||
url("/common/blank.html"),
|
||||
url("/common/blank.html#1234"),
|
||||
url("/common/blank.html#5678"),
|
||||
]
|
||||
|
||||
for page in test_pages:
|
||||
session.url = page
|
||||
assert session.url == test_pages[2]
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
assert session.url == test_pages[1]
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
assert session.url == test_pages[0]
|
||||
|
||||
|
||||
def test_history_pushstate(session, url):
|
||||
pushstate_page = inline("""
|
||||
<script>
|
||||
function pushState() {
|
||||
history.pushState({foo: "bar"}, "", "#pushstate");
|
||||
}
|
||||
</script>
|
||||
<a onclick="javascript:pushState();">click</a>
|
||||
""")
|
||||
|
||||
session.url = pushstate_page
|
||||
session.find.css("a", all=False).click()
|
||||
|
||||
assert session.url == "{}#pushstate".format(pushstate_page)
|
||||
assert session.execute_script("return history.state;") == {"foo": "bar"}
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
|
||||
assert session.url == pushstate_page
|
||||
assert session.execute_script("return history.state;") is None
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import pytest
|
||||
|
||||
from webdriver.error import NoSuchWindowException
|
||||
|
||||
|
||||
@pytest.fixture(name="session")
|
||||
def fixture_session(capabilities, session, create_window):
|
||||
"""Prevent re-using existent history by running the test in a new window."""
|
||||
original_handle = session.window_handle
|
||||
session.window_handle = create_window()
|
||||
|
||||
yield session
|
||||
|
||||
try:
|
||||
session.close()
|
||||
except NoSuchWindowException:
|
||||
pass
|
||||
|
||||
session.window_handle = original_handle
|
|
@ -0,0 +1,68 @@
|
|||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
|
||||
|
||||
|
||||
def back(session):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/back".format(**vars(session)))
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_handle_prompt_accept(session, create_dialog, dialog_type):
|
||||
create_dialog(dialog_type, text="dialog")
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
|
||||
assert_dialog_handled(session, expected_text="dialog")
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_handle_prompt_accept_and_notify(session, create_dialog, dialog_type):
|
||||
create_dialog(dialog_type, text="dialog")
|
||||
|
||||
response = back(session)
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text="dialog")
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_handle_prompt_dismiss(session, create_dialog, dialog_type):
|
||||
create_dialog(dialog_type, text="dialog")
|
||||
|
||||
response = back(session)
|
||||
assert_success(response)
|
||||
|
||||
assert_dialog_handled(session, expected_text="dialog")
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_handle_prompt_dissmiss_and_notify(session, create_dialog, dialog_type):
|
||||
create_dialog(dialog_type, text="dialog")
|
||||
|
||||
response = back(session)
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text="dialog")
|
||||
|
||||
|
||||
def test_handle_prompt_ignore():
|
||||
"""TODO"""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_handle_prompt_default(session, create_dialog, dialog_type):
|
||||
create_dialog(dialog_type, text="dialog")
|
||||
|
||||
response = back(session)
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text="dialog")
|
Загрузка…
Ссылка в новой задаче