Skip to content

Commit

Permalink
[wdspec] Add "Get Element Text" tests for ShadowRoot with slot.
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D193651

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1824664
gecko-commit: 8c758adbe3cbecd8c1ea1990921a78072254e6f3
gecko-reviewers: webdriver-reviewers, jgraham
  • Loading branch information
whimboo authored and moz-wptsync-bot committed Nov 21, 2023
1 parent e3d24c1 commit 1a0633b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions webdriver/tests/classic/get_element_text/get.py
Expand Up @@ -102,6 +102,42 @@ def test_read_element_text(session, inline):
assert_success(result, "oo")


@pytest.mark.parametrize("text, inner_html, expected", [
("cheese", "<slot><span>foo</span>bar</slot>", "cheese"),
("cheese", "<slot><span>foo</span></slot>bar", "cheesebar"),
("cheese", "<slot><span style=\"display: none\">foo</span>bar</slot>", "cheese"),
("", "<slot><span>foo</span>bar</slot>", "foobar"),
("", "<slot><span>foo</span></slot>bar", "foobar"),
("", "<slot><span style=\"display: none\">foo</span>bar</slot>", "bar"),
], ids=[
"custom visible",
"custom outside",
"custom hidden",
"default visible",
"default outside",
"default hidden",
])
def test_shadow_root_slot(session, inline, text, inner_html, expected):
session.url = inline(f"""
<test-container>{text}</test-container>
<script>
class TestContainer extends HTMLElement {{
connectedCallback() {{
const shadow = this.attachShadow({{ mode: "open" }});
shadow.innerHTML = "{inner_html}";
}}
}}
customElements.define("test-container", TestContainer);
</script>
""")

element = session.find.css("test-container", all=False)

result = get_element_text(session, element.id)
assert_success(result, expected)


def test_pretty_print_xml(session, inline):
session.url = inline("<xml><foo>che<bar>ese</bar></foo></xml>", doctype="xml")

Expand Down

0 comments on commit 1a0633b

Please sign in to comment.