diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/url/tests/browser_download_after_revoke.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/url/tests/browser_download_after_revoke.js')
-rw-r--r-- | dom/url/tests/browser_download_after_revoke.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/url/tests/browser_download_after_revoke.js b/dom/url/tests/browser_download_after_revoke.js new file mode 100644 index 0000000000..8894e092e6 --- /dev/null +++ b/dom/url/tests/browser_download_after_revoke.js @@ -0,0 +1,57 @@ +function test() { + waitForExplicitFinish(); + gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); + + function onLoad() { + info("Page loaded."); + + var listener = { + onOpenWindow(aXULWindow) { + info("Download window shown..."); + Services.wm.removeListener(listener); + + function downloadOnLoad() { + domwindow.removeEventListener("load", downloadOnLoad, true); + + is( + domwindow.document.location.href, + "chrome://mozapps/content/downloads/unknownContentType.xhtml", + "Download page appeared" + ); + + domwindow.close(); + gBrowser.removeTab(gBrowser.selectedTab); + finish(); + } + + var domwindow = aXULWindow.docShell.domWindow; + domwindow.addEventListener("load", downloadOnLoad, true); + }, + onCloseWindow(aXULWindow) {}, + }; + + Services.wm.addListener(listener); + + info("Creating BlobURL and clicking on a HTMLAnchorElement..."); + SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() { + let blob = new content.Blob(["test"], { type: "text/plain" }); + let url = content.URL.createObjectURL(blob); + + let link = content.document.createElement("a"); + link.href = url; + link.download = "example.txt"; + content.document.body.appendChild(link); + link.click(); + + content.URL.revokeObjectURL(url); + }); + } + + const target = "http://example.com/browser/dom/url/tests/empty.html"; + BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, target).then( + onLoad + ); + + info("Loading download page..."); + BrowserTestUtils.loadURI(gBrowser, target); +} |