Backed out changeset 680dd7916a23 (bug 1197420)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 25 Mar 2017 17:39:43 +0100
changeset 397740 a1667683da70198a991920d8580e2e3536b68cf3
parent 397739 0b0d2e8ada83c58ab59fa6ae388a02abd428dd3a
child 397741 66fe37afe8f1234b72b6e04066b09c251080bdab
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1197420
milestone55.0a1
backs out680dd7916a238a0da1ac687bffea4b76f76278b8
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 680dd7916a23 (bug 1197420)
browser/base/content/test/webextensions/browser_extension_sideloading.js
browser/modules/ExtensionsUI.jsm
toolkit/components/extensions/Extension.jsm
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
--- a/browser/base/content/test/webextensions/browser_extension_sideloading.js
+++ b/browser/base/content/test/webextensions/browser_extension_sideloading.js
@@ -90,56 +90,56 @@ add_task(function* () {
   const ID1 = "addon1@tests.mozilla.org";
   let mock1 = new MockAddon({
     id: ID1,
     name: "Test 1",
     userDisabled: true,
     seen: false,
     userPermissions: {
       permissions: ["history"],
-      origins: ["https://*/*"],
+      hosts: ["https://*/*"],
     },
     iconURL: ICON_URL,
   });
 
   const ID2 = "addon2@tests.mozilla.org";
   let mock2 = new MockAddon({
     id: ID2,
     name: "Test 2",
     userDisabled: true,
     seen: false,
     userPermissions: {
       permissions: [],
-      origins: [],
+      hosts: [],
     },
   });
 
   const ID3 = "addon3@tests.mozilla.org";
   let mock3 = new MockAddon({
     id: ID3,
     name: "Test 3",
     isWebExtension: true,
     userDisabled: true,
     seen: false,
     userPermissions: {
       permissions: [],
-      origins: ["<all_urls>"],
+      hosts: ["<all_urls>"],
     }
   });
 
   const ID4 = "addon4@tests.mozilla.org";
   let mock4 = new MockAddon({
     id: ID4,
     name: "Test 4",
     isWebExtension: true,
     userDisabled: true,
     seen: false,
     userPermissions: {
       permissions: [],
-      origins: ["<all_urls>"],
+      hosts: ["<all_urls>"],
     }
   });
 
   let provider = new MockProvider(mock1, mock2, mock3, mock4);
   AddonManagerPrivate.registerProvider(provider, [{
     id: "extension",
     name: "Extensions",
     uiPriority: 4000,
--- a/browser/modules/ExtensionsUI.jsm
+++ b/browser/modules/ExtensionsUI.jsm
@@ -215,21 +215,21 @@ this.ExtensionsUI = {
   },
 
   // Create a set of formatted strings for a permission prompt
   _buildStrings(info) {
     let result = {};
 
     let bundle = Services.strings.createBundle(BROWSER_PROPERTIES);
 
-    let perms = info.permissions || {origins: [], permissions: []};
+    let perms = info.permissions || {hosts: [], permissions: []};
 
     // First classify our host permissions
     let allUrls = false, wildcards = [], sites = [];
-    for (let permission of perms.origins) {
+    for (let permission of perms.hosts) {
       if (permission == "<all_urls>") {
         allUrls = true;
         break;
       }
       let match = /^[htps*]+:\/\/([^/]+)\//.exec(permission);
       if (!match) {
         throw new Error("Unparseable host permission");
       }
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -370,43 +370,43 @@ this.ExtensionData = class {
     });
   }
 
   // This method should return a structured representation of any
   // capabilities this extension has access to, as derived from the
   // manifest.  The current implementation just returns the contents
   // of the permissions attribute, if we add things like url_overrides,
   // they should also be added here.
-  get userPermissions() {
+  userPermissions() {
     let result = {
-      origins: this.whiteListedHosts.pat,
+      hosts: this.whiteListedHosts.pat,
       apis: [...this.apiNames],
     };
 
     if (Array.isArray(this.manifest.content_scripts)) {
       for (let entry of this.manifest.content_scripts) {
-        result.origins.push(...entry.matches);
+        result.hosts.push(...entry.matches);
       }
     }
     const EXP_PATTERN = /^experiments\.\w+/;
     result.permissions = [...this.permissions]
-      .filter(p => !result.origins.includes(p) && !EXP_PATTERN.test(p));
+      .filter(p => !result.hosts.includes(p) && !EXP_PATTERN.test(p));
     return result;
   }
 
   // Compute the difference between two sets of permissions, suitable
   // for presenting to the user.
   static comparePermissions(oldPermissions, newPermissions) {
     // See bug 1331769: should we do something more complicated to
     // compare host permissions?
     // e.g., if we go from <all_urls> to a specific host or from
     // a *.domain.com to specific-host.domain.com that's actually a
     // drop in permissions but the simple test below will cause a prompt.
     return {
-      origins: newPermissions.origins.filter(perm => !oldPermissions.origins.includes(perm)),
+      hosts: newPermissions.hosts.filter(perm => !oldPermissions.hosts.includes(perm)),
       permissions: newPermissions.permissions.filter(perm => !oldPermissions.permissions.includes(perm)),
     };
   }
 
   parseManifest() {
     return Promise.all([
       this.readJSON("manifest.json"),
       Management.lazyInit(),
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -1343,17 +1343,17 @@ var AddonManagerInternal = {
       return Promise.resolve();
     }
 
     let newPerms = info.addon.userPermissions;
 
     let difference = Extension.comparePermissions(oldPerms, newPerms);
 
     // If there are no new permissions, just go ahead with the update
-    if (difference.origins.length == 0 && difference.permissions.length == 0) {
+    if (difference.hosts.length == 0 && difference.permissions.length == 0) {
       return Promise.resolve();
     }
 
     return new Promise((resolve, reject) => {
       let subject = {wrappedJSObject: {
         addon: info.addon,
         permissions: difference,
         resolve, reject
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -720,17 +720,17 @@ function attachUpdateHandler(install) {
       return Promise.resolve();
     }
 
     let newPerms = info.addon.userPermissions;
 
     let difference = Extension.comparePermissions(oldPerms, newPerms);
 
     // If there are no new permissions, just proceed
-    if (difference.origins.length == 0 && difference.permissions.length == 0) {
+    if (difference.hosts.length == 0 && difference.permissions.length == 0) {
       return Promise.resolve();
     }
 
     return new Promise((resolve, reject) => {
       let subject = {
         wrappedJSObject: {
           target: getBrowserElement(),
           info: {
@@ -1286,17 +1286,17 @@ var gViewController = {
           return false;
         let addonType = AddonManager.addonTypes[aAddon.type];
         return (!(addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) &&
                 hasPermission(aAddon, "enable"));
       },
       doCommand(aAddon) {
         if (aAddon.isWebExtension && !aAddon.seen && WEBEXT_PERMISSION_PROMPTS) {
           let perms = aAddon.userPermissions;
-          if (perms.origins.length > 0 || perms.permissions.length > 0) {
+          if (perms.hosts.length > 0 || perms.permissions.length > 0) {
             let subject = {
               wrappedJSObject: {
                 target: getBrowserElement(),
                 info: {
                   type: "sideload",
                   addon: aAddon,
                   icon: aAddon.iconURL,
                   permissions: perms,
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -1017,17 +1017,17 @@ var loadManifestFromWebManifest = Task.a
     else
       addon.optionsBrowserStyle = manifest.options_ui.browser_style;
   }
 
   // WebExtensions don't use iconURLs
   addon.iconURL = null;
   addon.icon64URL = null;
   addon.icons = manifest.icons || {};
-  addon.userPermissions = extension.userPermissions;
+  addon.userPermissions = extension.userPermissions();
 
   addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
 
   function getLocale(aLocale) {
     // Use the raw manifest, here, since we need values with their
     // localization placeholders still in place.
     let rawManifest = extension.rawManifest;
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -515,17 +515,17 @@ add_task(function* test_permissions_prom
 
   yield promiseCompleteInstall(install);
 
   notEqual(perminfo, undefined, "Permission handler was invoked");
   equal(perminfo.existingAddon, null, "Permission info does not include an existing addon");
   notEqual(perminfo.addon, null, "Permission info includes the new addon");
   let perms = perminfo.addon.userPermissions;
   deepEqual(perms.permissions, ["tabs", "storage"], "API permissions are correct");
-  deepEqual(perms.origins, ["https://*.example.com/*", "<all_urls>"], "Host permissions are correct");
+  deepEqual(perms.hosts, ["https://*.example.com/*", "<all_urls>"], "Host permissions are correct");
   deepEqual(perms.apis, ["test"], "Experiments permissions are correct");
 
   let addon = yield promiseAddonByID(perminfo.addon.id);
   notEqual(addon, null, "Extension was installed");
 
   addon.uninstall();
   yield OS.File.remove(xpi.path);
 });