Skip to content

Commit

Permalink
Text Fragments: Add tests for search-invisible content inside a text …
Browse files Browse the repository at this point in the history
…directive parameter.

Existing tests only cover search-invisible content in between text directive tokens (eg. between `prefix-` and `start`),
but not inside of a text directive parameter.
Since this is a use case that happens rather frequently (e.g. an image inside a text node), there should be tests for this.

Differential Revision: https://phabricator.services.mozilla.com/D216688

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1908118
gecko-commit: 56d722e540c78c0703711c3d67708bdac63ded9e
gecko-reviewers: peterv, dom-core
  • Loading branch information
jnjaeschke authored and moz-wptsync-bot committed Jul 23, 2024
1 parent e86ad36 commit 94558e7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,26 @@

Dipsum


<div>Text
<div style="display: none">This isn't rendered</div>
with display: none
</div>
<div>Text
<div style="visibility: hidden">This also isn't visible</div>
with visibility: hidden as block boundary
</div>
<div>Text
<span style="visibility: hidden">This also isn't visible</span>
with visibility: hidden as inline
</div>
<div>Text
<iframe srcdoc="Inner Iframe"></iframe>
with Iframe
</div>
<div>Text
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mNk+M+AARiHsiAAcCIKAYwFoQ8AAAAASUVORK5CYII=">
with image
</div>

</p>
<p>
Expand Down
25 changes: 25 additions & 0 deletions scroll-to-text-fragment/find-range-from-text-directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,31 @@
fragment: '#:~:text=prefix-,match,matchEnd,-suffix5',
expect_to_scroll: true,
description: 'Range end matches correct suffix'
},
{
fragment: '#:~:text=Text%20with%20display:%20none',
expect_to_scroll: true,
description: '`start` element contains search-invisible text (display: none)'
},
{
fragment: '#:~:text=Text%20with%20visibility:%20hidden%20as%20block%20boundary',
expect_to_scroll: false,
description: '`start` element contains hidden text, which is a block boundary'
},
{
fragment: '#:~:text=Text%20with%20visibility:%20hidden%20as%20inline',
expect_to_scroll: true,
description: '`start` element contains hidden text which is not a block boundary'
},
{
fragment: '#:~:text=Text%20with%20Iframe',
expect_to_scroll: true,
description: '`start` element contains search-invisible text (iframe)'
},
{
fragment: '#:~:text=Text%20with%20image',
expect_to_scroll: true,
description: '`start` element contains search-invisible text (image)'
}
];

Expand Down

0 comments on commit 94558e7

Please sign in to comment.