navigate-anchor-download.html (1248B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <body> 5 <script> 6 const tests = [["a", ""], ["a", "filename"], ["area", ""], ["area", "filename"]]; 7 8 for (const [tag, download_attr] of tests) { 9 async_test(t => { 10 let a = document.createElement(tag); 11 a.href = "foo.html"; 12 a.download = download_attr; 13 document.body.appendChild(a); 14 navigation.onnavigate = t.step_func_done(e => { 15 assert_equals(e.navigationType, "push"); 16 assert_true(e.cancelable); 17 assert_true(e.canIntercept); 18 assert_false(e.userInitiated); 19 assert_false(e.hashChange); 20 assert_equals(e.downloadRequest, download_attr); 21 assert_equals(e.formData, null); 22 assert_equals(new URL(e.destination.url).pathname, 23 "/navigation-api/navigate-event/foo.html"); 24 assert_false(e.destination.sameDocument); 25 assert_equals(e.destination.key, ""); 26 assert_equals(e.destination.id, ""); 27 assert_equals(e.destination.index, -1); 28 assert_equals(e.sourceElement, a); 29 e.preventDefault(); 30 }); 31 a.click(); 32 }, `<${tag}> fires navigate and populates downloadRequest with '${download_attr}'`); 33 } 34 </script> 35 </body>