summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
commit37d5300335d81cecbecc99812747a657588c63eb (patch)
tree765efa3b6a56bb715d9813a8697473e120436278 /toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
parentb2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff)
parent4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff)
downloadUXP-37d5300335d81cecbecc99812747a657588c63eb.tar
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz
UXP-37d5300335d81cecbecc99812747a657588c63eb.zip
Merge branch 'ext-work'
Diffstat (limited to 'toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js')
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js106
1 files changed, 106 insertions, 0 deletions
diff --git a/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js b/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
new file mode 100644
index 000000000..c35870c9b
--- /dev/null
+++ b/toolkit/mozapps/webextensions/test/xpcshell/test_proxy.js
@@ -0,0 +1,106 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const ID = "proxy1@tests.mozilla.org";
+
+createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
+startupManager();
+
+BootstrapMonitor.init();
+
+// Ensure that a proxy file to an add-on with a valid manifest works.
+add_task(function*() {
+ let tempdir = gTmpD.clone();
+ writeInstallRDFToDir({
+ id: ID,
+ version: "1.0",
+ bootstrap: true,
+ unpack: true,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Bootstrap 1 (proxy)",
+ }, tempdir, ID, "bootstrap.js");
+
+ let unpackedAddon = tempdir.clone();
+ unpackedAddon.append(ID);
+ do_get_file("data/test_proxy/bootstrap.js")
+ .copyTo(unpackedAddon, "bootstrap.js");
+
+ // create proxy file in profile/extensions dir
+ let extensionsDir = gProfD.clone();
+ extensionsDir.append("extensions");
+ let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
+
+ yield promiseRestartManager();
+
+ BootstrapMonitor.checkAddonInstalled(ID, "1.0");
+ BootstrapMonitor.checkAddonStarted(ID, "1.0");
+
+ let addon = yield promiseAddonByID(ID);
+
+ do_check_neq(addon, null);
+ do_check_eq(addon.version, "1.0");
+ do_check_eq(addon.name, "Test Bootstrap 1 (proxy)");
+ do_check_true(addon.isCompatible);
+ do_check_false(addon.appDisabled);
+ do_check_true(addon.isActive);
+ do_check_eq(addon.type, "extension");
+ do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
+
+ do_check_true(proxyFile.exists());
+
+ addon.uninstall();
+ unpackedAddon.remove(true);
+
+ yield promiseRestartManager();
+});
+
+
+// Ensure that a proxy file to an add-on is not removed even
+// if the manifest file is invalid. See bug 1195353.
+add_task(function*() {
+ let tempdir = gTmpD.clone();
+
+ // use a mismatched ID to make this install.rdf invalid
+ writeInstallRDFToDir({
+ id: "bad-proxy1@tests.mozilla.org",
+ version: "1.0",
+ bootstrap: true,
+ unpack: true,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Bootstrap 1 (proxy)",
+ }, tempdir, ID, "bootstrap.js");
+
+ let unpackedAddon = tempdir.clone();
+ unpackedAddon.append(ID);
+ do_get_file("data/test_proxy/bootstrap.js")
+ .copyTo(unpackedAddon, "bootstrap.js");
+
+ // create proxy file in profile/extensions dir
+ let extensionsDir = gProfD.clone();
+ extensionsDir.append("extensions");
+ let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
+
+ yield promiseRestartManager();
+
+ BootstrapMonitor.checkAddonNotInstalled(ID, "1.0");
+ BootstrapMonitor.checkAddonNotStarted(ID, "1.0");
+
+ let addon = yield promiseAddonByID(ID);
+ do_check_eq(addon, null);
+
+ do_check_true(proxyFile.exists());
+
+ unpackedAddon.remove(true);
+ proxyFile.remove(true);
+
+ yield promiseRestartManager();
+});