a-download-click-404.html (1066B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Clicking on an <a> element with a download attribute and href that leads to 404 should not navigate</title> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-download"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <body> 9 <script> 10 "use strict"; 11 async_test(t => { 12 const errorFrame = document.createElement("iframe"); 13 14 errorFrame.addEventListener("load", t.step_func(function () { 15 errorFrame.contentWindow.addEventListener( 16 "beforeunload", t.unreached_func("Navigated instead of downloading")); 17 18 errorFrame.contentDocument.querySelector("#error-url").click(); 19 t.step_timeout(() => t.done(), 1000); 20 })); 21 errorFrame.src = "resources/a-download-404.html"; 22 document.body.appendChild(errorFrame); 23 }, "Do not navigate to 404 for anchor with download"); 24 </script> 25 </body>