Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'win' && socketprocess_networking && fission OR os == 'mac' && socketprocess_networking && fission OR os == 'mac' && debug OR os == 'linux' && socketprocess_networking OR os == 'android'
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-remote.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
"use strict";
// downloads.download API can be observed by extensions.
// The DNR version is in test_ext_dnr_download.js.
add_task(async function testDownload() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: [
"webRequest",
"webRequestBlocking",
"downloads",
],
},
background: async function () {
browser.webRequest.onBeforeRequest.addListener(
() => {
browser.test.sendMessage("request_intercepted");
return { cancel: true };
},
{
},
["blocking"]
);
browser.downloads.onChanged.addListener(delta => {
browser.test.assertEq(delta.state.current, "interrupted");
browser.test.sendMessage("done");
});
await browser.downloads.download({
filename: "example.txt",
});
},
});
await extension.startup();
await extension.awaitMessage("request_intercepted");
await extension.awaitMessage("done");
await extension.unload();
});