Skip to content

Commit

Permalink
Text Fragments: Preserve user activation when opening a link in a new…
Browse files Browse the repository at this point in the history
… tab or window.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1911339
gecko-commit: e51c1a59a5ea4c68128307b147f92c5c7bca0bfa
gecko-reviewers: dom-core, tabbrowser-reviewers, dao, farre
  • Loading branch information
jnjaeschke authored and moz-wptsync-bot committed Aug 21, 2024
1 parent 006422e commit c0ba65c
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<title>Navigating to a text fragment directive in a new tab</title>
<meta charset=utf-8>
<link rel="help" href="https://wicg.github.io/ScrollToTextFragment/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/utils.js"></script>
<script src="stash.js"></script>
<body></body>
<script>
promise_test(async t => new Promise((resolve, reject) =>{
let key = token();
document.body.innerHTML = `<a href="scroll-to-text-fragment-target.html?key=${key}#:~:text=test">Click me</a>`;
const link = document.querySelector("a");
test_driver.bless('Open a URL with a text directive in a new tab', () => {
test_driver.send_keys(document.body, '\uE004'); // TAB to focus the link
test_driver.send_keys(link, '\uE009\uE007'); // CTRL + ENTER
});
fetchResults(key, resolve, reject);
}).then(data => {
assert_equals(data.scrollPosition, 'text', 'Expected ctrl+click on a link to be user activated.');
}), `Test that the text fragment directive requires a user activation when invoked by clicking a link in the same or a new tab`);


</script>

0 comments on commit c0ba65c

Please sign in to comment.