a-download-click.html (1264B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Clicking on an <a> element with a download attribute must not throw an exception</title> 4 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour"> 6 <link rel="help" href="https://github.com/whatwg/html/issues/2116"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 10 <body> 11 <script> 12 "use strict"; 13 async_test(t => { 14 const frame = document.createElement("iframe"); 15 16 frame.addEventListener("load", t.step_func(function () { 17 frame.contentWindow.addEventListener( 18 "beforeunload", t.unreached_func("Navigated instead of downloading")); 19 const string = "test"; 20 const blob = new Blob([string], { type: "text/html" }); 21 22 const link = frame.contentDocument.querySelector("#blob-url"); 23 link.href = URL.createObjectURL(blob); 24 25 link.click(); 26 27 t.step_timeout(() => t.done(), 1000); 28 })); 29 frame.src = "resources/a-download-click.html"; 30 document.body.appendChild(frame); 31 }, "Clicking on an <a> element with a download attribute must not throw an exception"); 32 </script> 33 </body>