summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-09 11:10:00 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-09 11:10:00 -0500
commitf164d9124708b50789dbb6959e1de96cc5697c48 (patch)
tree6dffd12e08c5383130df0252fb69cd6d6330794f /toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
parent30de4018913f0cdaea19d1dd12ecd8209e2ed08e (diff)
downloadUXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar
UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.gz
UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.lz
UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.xz
UXP-f164d9124708b50789dbb6959e1de96cc5697c48.zip
Rename Toolkit's webextensions component directory to better reflect what it is.
Diffstat (limited to 'toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js')
-rw-r--r--toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
new file mode 100644
index 000000000..058b9b18c
--- /dev/null
+++ b/toolkit/components/webextensions/test/xpcshell/test_ext_downloads.js
@@ -0,0 +1,76 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(function* test_downloads_api_namespace_and_permissions() {
+ function backgroundScript() {
+ browser.test.assertTrue(!!browser.downloads, "`downloads` API is present.");
+ browser.test.assertTrue(!!browser.downloads.FilenameConflictAction,
+ "`downloads.FilenameConflictAction` enum is present.");
+ browser.test.assertTrue(!!browser.downloads.InterruptReason,
+ "`downloads.InterruptReason` enum is present.");
+ browser.test.assertTrue(!!browser.downloads.DangerType,
+ "`downloads.DangerType` enum is present.");
+ browser.test.assertTrue(!!browser.downloads.State,
+ "`downloads.State` enum is present.");
+ browser.test.notifyPass("downloads tests");
+ }
+
+ let extensionData = {
+ background: backgroundScript,
+ manifest: {
+ permissions: ["downloads", "downloads.open", "downloads.shelf"],
+ },
+ };
+
+ let extension = ExtensionTestUtils.loadExtension(extensionData);
+ yield extension.startup();
+ yield extension.awaitFinish("downloads tests");
+ yield extension.unload();
+});
+
+add_task(function* test_downloads_open_permission() {
+ function backgroundScript() {
+ browser.test.assertFalse("open" in browser.downloads,
+ "`downloads.open` permission is required.");
+ browser.test.notifyPass("downloads tests");
+ }
+
+ let extensionData = {
+ background: backgroundScript,
+ manifest: {
+ permissions: ["downloads"],
+ },
+ };
+
+ let extension = ExtensionTestUtils.loadExtension(extensionData);
+ yield extension.startup();
+ yield extension.awaitFinish("downloads tests");
+ yield extension.unload();
+});
+
+add_task(function* test_downloads_open() {
+ async function backgroundScript() {
+ await browser.test.assertRejects(
+ browser.downloads.open(10),
+ "Invalid download id 10",
+ "The error is informative.");
+
+ browser.test.notifyPass("downloads tests");
+
+ // TODO: Once downloads.{pause,cancel,resume} lands (bug 1245602) test that this gives a good
+ // error when called with an incompleted download.
+ }
+
+ let extensionData = {
+ background: backgroundScript,
+ manifest: {
+ permissions: ["downloads", "downloads.open"],
+ },
+ };
+
+ let extension = ExtensionTestUtils.loadExtension(extensionData);
+ yield extension.startup();
+ yield extension.awaitFinish("downloads tests");
+ yield extension.unload();
+});