anchor-without-link.html (1383B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>summary element: clicking on anchor without link</title> 4 <link rel="author" title="Di Zhang" href="mailto:dizhangg@chromium.org"> 5 <link rel="help" href="https://html.spec.whatwg.org/C/#the-summary-element"> 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 10 <details id="details"> 11 <summary><a id="no_inline">Details</a></summary> 12 <p>Text</p> 13 </details> 14 15 <details id="details_inline"> 16 <summary><a><i id="has_inline">Details</i></a></summary> 17 <p>Text</p> 18 </details> 19 20 21 <script> 22 23 async function testClickingOnAnchorWithoutLink (detailsId, targetId) { 24 const details = document.getElementById(detailsId); 25 const target = document.getElementById(targetId); 26 const initialLoc = location.hash; 27 28 assert_false(details.open); 29 target.click(); 30 assert_true(details.open); 31 assert_equals(location.hash, initialLoc); 32 } 33 34 promise_test(() => testClickingOnAnchorWithoutLink('details', 'no_inline'), 35 "clicking on anchor without link should open details and not navigate."); 36 37 promise_test(() => testClickingOnAnchorWithoutLink('details_inline', 'has_inline'), 38 "clicking on anchor without link, with embedded inline element should open details and not navigate."); 39 40 </script>