Debian Codegraph @

testing/web-platform/mozilla/tests/scroll-to-text-fragment/scroll-to-text-fragment-open-link-in-new-tab-desktop.html

raw
1 <!doctype html>
2 <title>Navigating to a text fragment directive in a new tab</title>
3 <meta charset=utf-8>
4 <link rel="help" href="https://wicg.github.io/ScrollToTextFragment/">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="/resources/testdriver.js"></script>
8 <script src="/resources/testdriver-actions.js"></script>
9 <script src="/resources/testdriver-vendor.js"></script>
10 <script src="/common/utils.js"></script>
11 <script src="/scroll-to-text-fragment/stash.js"></script>
12 <body></body>
13 <script>
14 const isMacOS = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
15 promise_test(async t => new Promise((resolve, reject) =>{
16 let key = token();
17 document.body.innerHTML = `<a href="/scroll-to-text-fragment/scroll-to-text-fragment-target.html?key=${key}#:~:text=test">Click me</a>`;
18 const link = document.querySelector("a");
19 test_driver.bless('Open a URL with a text directive in a new tab', () => {
20 test_driver.send_keys(document.body, '\uE004'); // TAB to focus the link
21 // Use CMD+Enter on macOS, CTRL+Enter otherwise
22 const accelEnter = isMacOS ? '\uE03D\uE007': '\uE009\uE007';
23 test_driver.send_keys(link, accelEnter);
24 });
25 fetchResults(key, resolve, reject);
26 }).then(data => {
27 assert_true(data.scrollPosition != 'top', 'Expected ctrl+click on a link to be user activated.');
28 }), `Test that the text fragment directive requires a user activation when invoked by clicking a link in the same or a new tab`);
29
30
31 </script>