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