Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>beforematch fired on ScrollToTextFragment</title>
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/utils.js"></script>
<script src="/scroll-to-text-fragment/stash.js"></script>
<script>
promise_test(t => new Promise((resolve, reject) => {
const key = token();
test_driver.bless('Open a scroll to text fragment URL', () => {
window.open(
`resources/hidden-until-found-text-fragment.html?key=${key}#:~:text=foo`,
'_blank',
'noopener');
});
fetchResults(key, resolve, reject);
}).then(results => {
assert_false(results.targetHasHiddenAttribute,
'The matching hidden=until-found element should have its hidden attribute removed so it can be scrolled to.');
assert_true(results.pageYOffsetAfterRaf > 0,
'The page should be scrolled down to foo.');
}), 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
</script>