Source code

Revision control

Other Tools

Test Info: Warnings

  • This test gets skipped with pattern: !is_fennec
  • This test was skipped 314 times in the preceding 7 days.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Downloads Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
// saveAs is not implemented on Fennec but this tests that a call to download() that supplies that option passes anyway.
add_task(async function testDownload() {
const extension = ExtensionTestUtils.loadExtension({
manifest: {permissions: ["downloads"]},
background: async function() {
const url = URL.createObjectURL(new Blob(["file content"]));
const id = await browser.downloads.download({
url,
saveAs: true,
});
browser.downloads.onChanged.addListener(delta => {
if (delta.id == id && delta.state.current === "complete") {
browser.test.notifyPass("downloadPass");
}
});
},
});
await extension.startup();
await extension.awaitFinish("downloadPass");
await extension.unload();
});
</script>
</body>
</html>