summaryrefslogtreecommitdiffstats
path: root/toolkit/components/addoncompat/tests/browser/browser_addonShims.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/addoncompat/tests/browser/browser_addonShims.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/addoncompat/tests/browser/browser_addonShims.js')
-rw-r--r--toolkit/components/addoncompat/tests/browser/browser_addonShims.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/toolkit/components/addoncompat/tests/browser/browser_addonShims.js b/toolkit/components/addoncompat/tests/browser/browser_addonShims.js
new file mode 100644
index 000000000..b642eb3cb
--- /dev/null
+++ b/toolkit/components/addoncompat/tests/browser/browser_addonShims.js
@@ -0,0 +1,67 @@
+var {AddonManager} = Cu.import("resource://gre/modules/AddonManager.jsm", {});
+var {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+
+const ADDON_URL = "http://example.com/browser/toolkit/components/addoncompat/tests/browser/addon.xpi";
+const COMPAT_ADDON_URL = "http://example.com/browser/toolkit/components/addoncompat/tests/browser/compat-addon.xpi";
+
+// Install a test add-on that will exercise e10s shims.
+// url: Location of the add-on.
+function addAddon(url)
+{
+ info("Installing add-on: " + url);
+
+ return new Promise(function(resolve, reject) {
+ AddonManager.getInstallForURL(url, installer => {
+ installer.install();
+ let listener = {
+ onInstallEnded: function(addon, addonInstall) {
+ installer.removeListener(listener);
+
+ // Wait for add-on's startup scripts to execute. See bug 997408
+ executeSoon(function() {
+ resolve(addonInstall);
+ });
+ }
+ };
+ installer.addListener(listener);
+ }, "application/x-xpinstall");
+ });
+}
+
+// Uninstall a test add-on.
+// addon: The addon reference returned from addAddon.
+function removeAddon(addon)
+{
+ info("Removing addon.");
+
+ return new Promise(function(resolve, reject) {
+ let listener = {
+ onUninstalled: function(uninstalledAddon) {
+ if (uninstalledAddon != addon) {
+ return;
+ }
+ AddonManager.removeAddonListener(listener);
+ resolve();
+ }
+ };
+ AddonManager.addAddonListener(listener);
+ addon.uninstall();
+ });
+}
+
+add_task(function* test_addon_shims() {
+ yield new Promise(resolve => {
+ SpecialPowers.pushPrefEnv({set: [["dom.ipc.shims.enabledWarnings", true]]},
+ resolve);
+ });
+
+ let addon = yield addAddon(ADDON_URL);
+ yield window.runAddonShimTests({ok: ok, is: is, info: info});
+ yield removeAddon(addon);
+
+ if (Services.appinfo.browserTabsRemoteAutostart) {
+ addon = yield addAddon(COMPAT_ADDON_URL);
+ yield window.runAddonTests({ok: ok, is: is, info: info});
+ yield removeAddon(addon);
+ }
+});