Bug 1420744 - Extensions downloads.download api with saveAs flag, skips file picker in android r=aswan

Differential Revision: https://phabricator.services.mozilla.com/D7118

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Arshad Kazmi 2018-10-01 16:59:10 +00:00
parent 0ffb516d02
commit bea20ae425
3 changed files with 47 additions and 1 deletions

View File

@ -14,6 +14,7 @@ support-files =
tags = webextensions
[test_ext_all_apis.html]
[test_ext_downloads_saveAs.html]
[test_ext_tab_runtimeConnect.html]
[test_ext_tabs_captureVisibleTab.html]
[test_ext_tabs_create.html]

View File

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Downloads Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.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() {
let 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>

View File

@ -511,7 +511,7 @@ this.downloads = class extends ExtensionAPI {
}
}
if (!saveAs) {
if (!saveAs || AppConstants.platform === "android") {
return target;
}