Bug 1688904 - Prevent add-ons still using the legacy API from installing. r=mkmelin
authorJohn Bieling <john@thunderbird.net>
Wed, 27 Jan 2021 10:51:48 +0200
changeset 31526 0fb3daf57a2db360a5a586c4f4dbeb181185c4d2
parent 31525 129709c908c465699e73f9bd305132fec2458a8d
child 31527 93948d7bde072df3974a6f119ef63c4572f75d66
push id18396
push usermkmelin@iki.fi
push dateWed, 27 Jan 2021 08:56:42 +0000
treeherdercomm-central@25e615d8cc33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1688904
Bug 1688904 - Prevent add-ons still using the legacy API from installing. r=mkmelin
mail/base/modules/ExtensionsUI.jsm
--- a/mail/base/modules/ExtensionsUI.jsm
+++ b/mail/base/modules/ExtensionsUI.jsm
@@ -881,16 +881,40 @@ var ExtensionsUI = {
         });
       } else {
         AMTelemetry.recordInstallEvent(info.install, {
           step: "permissions_prompt",
           num_strings: strings.msgs.length,
         });
       }
 
+      // Reject add-ons using the legacy API. We cannot use the general "ignore
+      // unknown APIs" policy, as add-ons using the Legacy API from TB68 will
+      // not do anything, confusing the user.
+      if (data.manifest.legacy) {
+        let subject = {
+          wrappedJSObject: {
+            browser,
+            originatingURI: null,
+            installs: [
+              {
+                addon: info.addon,
+                name: info.addon.name,
+                error: 0,
+              },
+            ],
+            install: null,
+            cancel: null,
+          },
+        };
+        Services.obs.notifyObservers(subject, "addon-install-failed");
+        info.reject();
+        return;
+      }
+
       this.showPermissionsPrompt(browser, strings, info.icon, histkey).then(
         answer => {
           if (answer) {
             info.resolve();
           } else {
             info.reject();
           }
         }