mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
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:
parent
0ffb516d02
commit
bea20ae425
@ -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]
|
||||
|
@ -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>
|
@ -511,7 +511,7 @@ this.downloads = class extends ExtensionAPI {
|
||||
}
|
||||
}
|
||||
|
||||
if (!saveAs) {
|
||||
if (!saveAs || AppConstants.platform === "android") {
|
||||
return target;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user