Bug 815120 - xpinstall.enabled=false still allows to install xpi via. addon search. r=Unfocused
☠☠ backed out by ab1d6d80090e ☠ ☠
authorMartin Stransky <stransky@redhat.com>
Mon, 19 Aug 2013 08:49:42 -0400
changeset 143063 ebd79cd25bf55b9c715c26be9e13a24a681d89e2
parent 143062 d413dcf6b5a08a2d6e46c82b1b73b70b29d5134e
child 143064 ab1d6d80090eba98f105cc95b8c22df97a1d1846
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersUnfocused
bugs815120
milestone26.0a1
Bug 815120 - xpinstall.enabled=false still allows to install xpi via. addon search. r=Unfocused
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser_searching.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2080,16 +2080,19 @@ var gSearchView = {
     this._filter = document.getElementById("search-filter-radiogroup");
     this._sorters = document.getElementById("search-sorters");
     this._sorters.handler = this;
     this._loading = document.getElementById("search-loading");
     this._listBox = document.getElementById("search-list");
     this._emptyNotice = document.getElementById("search-list-empty");
     this._allResultsLink = document.getElementById("search-allresults-link");
 
+    if (!AddonManager.isInstallEnabled("application/x-xpinstall"))
+      this._filter.hidden = true;
+
     var self = this;
     this._listBox.addEventListener("keydown", function listbox_onKeydown(aEvent) {
       if (aEvent.keyCode == aEvent.DOM_VK_ENTER ||
           aEvent.keyCode == aEvent.DOM_VK_RETURN) {
         var item = self._listBox.selectedItem;
         if (item)
           item.showInDetailView();
       }
@@ -2221,16 +2224,20 @@ var gSearchView = {
   
   showLoading: function gSearchView_showLoading(aLoading) {
     this._loading.hidden = !aLoading;
     this._listBox.hidden = aLoading;
   },
 
   updateView: function gSearchView_updateView() {
     var showLocal = this._filter.value == "local";
+
+    if (!showLocal && !AddonManager.isInstallEnabled("application/x-xpinstall"))
+      showLocal = true;
+
     this._listBox.setAttribute("local", showLocal);
     this._listBox.setAttribute("remote", !showLocal);
 
     this.showLoading(this.isSearching && !showLocal);
     if (!this.isSearching) {
       var isEmpty = true;
       var results = this._listBox.getElementsByTagName("richlistitem");
       for (let result of results) {
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_searching.js
@@ -330,31 +330,34 @@ function check_results(aQuery, aSortBy, 
  * Check results of a search with different filterings
  *
  * @param  aQuery
  *         The search query used
  * @param  aSortBy
  *         How the results are sorted (e.g. "name")
  * @param  aReverseOrder
  *         Boolean representing if the results are in reverse default order
+ * @param  aLocalOnly
+ *         Boolean representing if the results are local only, can be undefined
  */
-function check_filtered_results(aQuery, aSortBy, aReverseOrder) {
+function check_filtered_results(aQuery, aSortBy, aReverseOrder, aLocalOnly) {
   var localFilter = gManagerWindow.document.getElementById("search-filter-local");
   var remoteFilter = gManagerWindow.document.getElementById("search-filter-remote");
 
   var list = gManagerWindow.document.getElementById("search-list");
   list.ensureElementIsVisible(localFilter);
 
   // Check with showing local add-ons
   EventUtils.synthesizeMouseAtCenter(localFilter, { }, gManagerWindow);
   check_results(aQuery, aSortBy, aReverseOrder, true);
 
   // Check with showing remote add-ons
+  aLocalOnly = aLocalOnly || false;
   EventUtils.synthesizeMouseAtCenter(remoteFilter, { }, gManagerWindow);
-  check_results(aQuery, aSortBy, aReverseOrder, false);
+  check_results(aQuery, aSortBy, aReverseOrder, aLocalOnly);
 }
 
 /*
  * Get item for a specific add-on by name
  *
  * @param  aName
  *         The name of the add-on to search for
  * @return Row of add-on if found, null otherwise
@@ -642,8 +645,40 @@ add_test(function() {
       var installBtn = get_install_button(get_addon_item(REMOTE_TO_INSTALL));
       is(installBtn.hidden, true, "Install button should be hidden for installed item");
 
       run_next_test();
     });
   });
 });
 
+function bug_815120_test_search(aLocalOnly) {
+  restart_manager(gManagerWindow, "addons://list/extension", function(aWindow) {
+    gManagerWindow = aWindow;
+    gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+
+    // Installed add-on is considered local on new search
+    gAddonInstalled = true;
+
+    // Check the search setup
+    if (aLocalOnly) {
+      var localFilterSelected = aWindow.document.getElementById("search-filter-local").selected;
+      ok(localFilterSelected, "Local filter should be selected if remote plugin installation is disabled");      
+    }    
+    var remoteFilterButton = aWindow.document.getElementById("search-filter-remote");
+    is(aLocalOnly, is_hidden(remoteFilterButton), "Remote filter button visibility does not match, aLocalOnly = " + aLocalOnly);
+
+    search(QUERY, false, function() {
+      check_filtered_results(QUERY, "relevancescore", false, aLocalOnly);
+      run_next_test();
+    });
+  });
+}
+
+// Tests for Bug 815120
+add_test(function() {
+  Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
+  bug_815120_test_search(true);
+});
+add_test(function() {
+  Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
+  bug_815120_test_search(false);
+});