Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<title>Navigating to a text fragment directive in a new tab</title>
<meta charset=utf-8>
<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="/scroll-to-text-fragment/stash.js"></script>
<body></body>
<script>
const isMacOS = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
promise_test(async t => new Promise((resolve, reject) =>{
let key = token();
document.body.innerHTML = `<a href="/scroll-to-text-fragment/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
// Use CMD+Enter on macOS, CTRL+Enter otherwise
const accelEnter = isMacOS ? '\uE03D\uE007': '\uE009\uE007';
test_driver.send_keys(link, accelEnter);
});
fetchResults(key, resolve, reject);
}).then(data => {
assert_true(data.scrollPosition != 'top', '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>