browser_partial.js (1705B)
1 async function test() { 2 waitForExplicitFinish(); 3 const target = 4 "https://example.com/browser/dom/media/test/browser/file_empty_page.html"; 5 6 info("Loading download page..."); 7 8 let tab = BrowserTestUtils.addTab(gBrowser, target); 9 10 registerCleanupFunction(function () { 11 gBrowser.removeTab(tab); 12 window.restore(); 13 }); 14 15 gBrowser.selectedTab = tab; 16 BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, target).then( 17 async () => { 18 info("Page loaded."); 19 let allDownloads = await Downloads.getList(Downloads.ALL); 20 let started = new Promise(resolve => { 21 // With no download modal, the download will begin on its own, so we need 22 // to wait to be notified by the downloads list when that happens. 23 let downloadView = { 24 onDownloadAdded(download) { 25 ok(true, "Download was started."); 26 download.cancel(); 27 allDownloads.removeView(this); 28 allDownloads.removeFinished(); 29 resolve(); 30 }, 31 }; 32 allDownloads.addView(downloadView); 33 }); 34 35 let revoked = SpecialPowers.spawn( 36 tab.linkedBrowser, 37 [], 38 () => 39 new Promise(resolve => { 40 let link = content.document.createElement("a"); 41 link.href = "force_octet_stream.mp4"; 42 content.document.body.appendChild(link); 43 info("Clicking HTMLAnchorElement..."); 44 link.click(); 45 info("Clicked HTMLAnchorElement."); 46 resolve(); 47 }) 48 ); 49 50 info("Waiting for async activities..."); 51 await Promise.all([revoked, started]); 52 ok(true, "Exiting test."); 53 finish(); 54 } 55 ); 56 }