зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730642 - [wdspec] Added web-platform tests for browsingContext.navigate command r=webdriver-reviewers,whimboo
Depends on D141584 Differential Revision: https://phabricator.services.mozilla.com/D141585
This commit is contained in:
Родитель
5d0a935c26
Коммит
3264767190
|
@ -0,0 +1,3 @@
|
|||
[invalid.py]
|
||||
disabled:
|
||||
if release_or_beta: https://bugzilla.mozilla.org/show_bug.cgi?id=1712902
|
|
@ -0,0 +1,3 @@
|
|||
[navigate.py]
|
||||
disabled:
|
||||
if release_or_beta: https://bugzilla.mozilla.org/show_bug.cgi?id=1712902
|
|
@ -0,0 +1,3 @@
|
|||
[wait.py]
|
||||
disabled:
|
||||
if release_or_beta: https://bugzilla.mozilla.org/show_bug.cgi?id=1712902
|
|
@ -11,7 +11,7 @@ def assert_browsing_context(
|
|||
assert isinstance(info["children"], list)
|
||||
assert len(info["children"]) == children
|
||||
else:
|
||||
assert info["children"] == None
|
||||
assert info["children"] is None
|
||||
|
||||
assert "context" in info
|
||||
assert isinstance(info["context"], str)
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
import pytest
|
||||
import webdriver.bidi.error as error
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_context_invalid_type(bidi_session, inline, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=value, url=inline("<p>foo")
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "somestring"])
|
||||
async def test_params_context_invalid_value(bidi_session, inline, value):
|
||||
with pytest.raises(error.NoSuchFrameException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=value, url=inline("<p>foo")
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_url_invalid_type(bidi_session, top_context, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=value
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["http://:invalid", "http://#invalid"])
|
||||
async def test_params_url_invalid_value(bidi_session, top_context, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=value
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, 42, {}, []])
|
||||
async def test_params_wait_invalid_type(bidi_session, inline, top_context, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=inline("<p>bar"), wait=value
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "somestring"])
|
||||
async def test_params_wait_invalid_value(bidi_session, inline, top_context, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=inline("<p>bar"), wait=value
|
||||
)
|
|
@ -0,0 +1,103 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
async def test_payload(bidi_session, inline, top_context):
|
||||
url = inline("<div>foo</div>")
|
||||
result = await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url
|
||||
)
|
||||
|
||||
assert "navigation" in result
|
||||
assert result["url"] == url
|
||||
|
||||
|
||||
async def test_interactive_simultaneous_navigation(bidi_session, inline, top_context):
|
||||
frame1_start_url = inline("frame1")
|
||||
frame2_start_url = inline("frame2")
|
||||
|
||||
url = inline(
|
||||
f"<iframe src='{frame1_start_url}'></iframe><iframe src='{frame2_start_url}'></iframe>"
|
||||
)
|
||||
|
||||
result = await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url, wait="complete"
|
||||
)
|
||||
assert result["url"] == url
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"]
|
||||
)
|
||||
assert len(contexts) == 1
|
||||
assert contexts[0]["url"] == url
|
||||
assert len(contexts[0]["children"]) == 2
|
||||
|
||||
frame1_context_id = contexts[0]["children"][0]["context"]
|
||||
frame2_context_id = contexts[0]["children"][1]["context"]
|
||||
|
||||
# The goal here is to navigate both iframes in parallel, and to use the
|
||||
# interactive wait condition for both.
|
||||
# Make sure that monitoring the DOMContentLoaded event for one frame does
|
||||
# prevent monitoring it for the other frame.
|
||||
img_url = "/webdriver/tests/bidi/browsing_context/navigate/support/empty.svg"
|
||||
script_url = "/webdriver/tests/bidi/browsing_context/navigate/support/empty.js"
|
||||
# frame1 also has a slow loading image so that it won't reach a complete
|
||||
# navigation, and we can make sure we resolved with the interactive state.
|
||||
frame1_url = inline(
|
||||
f"""frame1_new<script src='{script_url}?pipe=trickle(d2)'></script>
|
||||
<img src='{img_url}?pipe=trickle(d100)'>
|
||||
"""
|
||||
)
|
||||
frame2_url = inline(
|
||||
f"frame2_new<script src='{script_url}?pipe=trickle(d0.5)'></script>"
|
||||
)
|
||||
|
||||
frame1_task = asyncio.ensure_future(
|
||||
bidi_session.browsing_context.navigate(
|
||||
context=frame1_context_id, url=frame1_url, wait="interactive"
|
||||
)
|
||||
)
|
||||
|
||||
frame2_result = await bidi_session.browsing_context.navigate(
|
||||
context=frame2_context_id, url=frame2_url, wait="interactive"
|
||||
)
|
||||
assert frame2_result["url"] == frame2_url
|
||||
|
||||
# The "interactive" navigation should resolve before the 5 seconds timeout.
|
||||
await asyncio.wait_for(frame1_task, timeout=5)
|
||||
|
||||
frame1_result = frame1_task.result()
|
||||
assert frame1_result["url"] == frame1_url
|
||||
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"]
|
||||
)
|
||||
assert contexts[0]["children"][0]["url"] == frame1_url
|
||||
assert contexts[0]["children"][1]["url"] == frame2_url
|
||||
|
||||
|
||||
async def test_relative_url(bidi_session, url, top_context):
|
||||
url_before = url(
|
||||
"/webdriver/tests/bidi/browsing_context/navigate/support/empty.html"
|
||||
)
|
||||
|
||||
# Navigate to page1 with wait=interactive to make sure the document's base URI
|
||||
# was updated.
|
||||
result = await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url_before, wait="interactive"
|
||||
)
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"], max_depth=0
|
||||
)
|
||||
assert contexts[0]["url"] == url_before
|
||||
|
||||
url_after = url_before.replace("empty.html", "other.html")
|
||||
result = await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url="other.html", wait="interactive"
|
||||
)
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"], max_depth=0
|
||||
)
|
||||
assert contexts[0]["url"] == url_after
|
||||
assert result["url"] == url_after
|
|
@ -0,0 +1 @@
|
|||
"use strict";
|
|
@ -0,0 +1,2 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
</svg>
|
После Ширина: | Высота: | Размер: 48 B |
|
@ -0,0 +1,114 @@
|
|||
import pytest
|
||||
import asyncio
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["none", "interactive", "complete"])
|
||||
async def test_expected_url(bidi_session, inline, top_context, value):
|
||||
url = inline("<div>foo</div>")
|
||||
result = await bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url, wait=value
|
||||
)
|
||||
assert result["url"] == url
|
||||
if value != "none":
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"], max_depth=0
|
||||
)
|
||||
assert contexts[0]["url"] == url
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"wait, expect_timeout",
|
||||
[
|
||||
("none", False),
|
||||
("interactive", False),
|
||||
("complete", True),
|
||||
],
|
||||
)
|
||||
async def test_slow_image(bidi_session, inline, top_context, wait, expect_timeout):
|
||||
script_url = "/webdriver/tests/bidi/browsing_context/navigate/support/empty.svg"
|
||||
url = inline(f"<img src='{script_url}?pipe=trickle(d10)'>")
|
||||
|
||||
# Ultimately, "interactive" and "complete" should support a timeout argument.
|
||||
# See https://github.com/w3c/webdriver-bidi/issues/188.
|
||||
wait_for_navigation = asyncio.wait_for(
|
||||
bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url, wait=wait
|
||||
),
|
||||
timeout=1,
|
||||
)
|
||||
|
||||
if expect_timeout:
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
await wait_for_navigation
|
||||
else:
|
||||
await wait_for_navigation
|
||||
|
||||
if wait != "none":
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"], max_depth=0
|
||||
)
|
||||
assert contexts[0]["url"] == url
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"wait, expect_timeout",
|
||||
[
|
||||
("none", False),
|
||||
("interactive", True),
|
||||
("complete", True),
|
||||
],
|
||||
)
|
||||
async def test_slow_page(bidi_session, url, top_context, wait, expect_timeout):
|
||||
page_url = url(
|
||||
"/webdriver/tests/bidi/browsing_context/navigate/support/empty.html?pipe=trickle(d10)"
|
||||
)
|
||||
|
||||
wait_for_navigation = asyncio.wait_for(
|
||||
bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=page_url, wait=wait
|
||||
),
|
||||
timeout=1,
|
||||
)
|
||||
|
||||
if expect_timeout:
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
await wait_for_navigation
|
||||
else:
|
||||
await wait_for_navigation
|
||||
|
||||
# Note that we cannot assert the top context url here, because the navigation
|
||||
# is blocked on the initial url for this test case.
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"wait, expect_timeout",
|
||||
[
|
||||
("none", False),
|
||||
("interactive", True),
|
||||
("complete", True),
|
||||
],
|
||||
)
|
||||
async def test_slow_script(bidi_session, inline, top_context, wait, expect_timeout):
|
||||
script_url = "/webdriver/tests/bidi/browsing_context/navigate/support/empty.js"
|
||||
url = inline(f"<script src='{script_url}?pipe=trickle(d10)'></script>")
|
||||
|
||||
wait_for_navigation = asyncio.wait_for(
|
||||
bidi_session.browsing_context.navigate(
|
||||
context=top_context["context"], url=url, wait=wait
|
||||
),
|
||||
timeout=1,
|
||||
)
|
||||
|
||||
if expect_timeout:
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
await wait_for_navigation
|
||||
else:
|
||||
await wait_for_navigation
|
||||
|
||||
if wait != "none":
|
||||
contexts = await bidi_session.browsing_context.get_tree(
|
||||
parent=top_context["context"], max_depth=0
|
||||
)
|
||||
assert contexts[0]["url"] == url
|
|
@ -34,3 +34,9 @@ def test_page_cross_origin_frame(inline, test_page_cross_origin):
|
|||
@pytest.fixture
|
||||
def test_page_same_origin_frame(inline, test_page):
|
||||
return inline(f"<iframe src='{test_page}'></iframe>")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def top_context(bidi_session):
|
||||
contexts = await bidi_session.browsing_context.get_tree()
|
||||
return contexts[0]
|
||||
|
|
Загрузка…
Ссылка в новой задаче