Bug 1591501 - Click category to go back to list in about:addons r=rpl
☠☠ backed out by f7c199feb6c6 ☠ ☠
authorMark Striemer <mstriemer@mozilla.com>
Wed, 13 Nov 2019 15:54:28 +0000
changeset 501764 97a383ec65b7791c289a1ae523cd7181d3ec6093
parent 501763 bb6776d41b9eae7155e49f0674c00c99ee8dbebf
child 501765 909f5eb0cc4807fb607a7ec225d3d1389c3bcf49
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1591501
milestone72.0a1
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
Bug 1591501 - Click category to go back to list in about:addons r=rpl Differential Revision: https://phabricator.services.mozilla.com/D51317
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser.ini
toolkit/mozapps/extensions/test/browser/browser_sidebar_categories.js
toolkit/mozapps/extensions/test/browser/head.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -827,23 +827,18 @@ var gCategories = {
       this.node.value = gViewDefault;
     }
 
     this.node.addEventListener("select", () => {
       gViewController.loadView(this.node.selectedItem.value);
     });
 
     this.node.addEventListener("click", aEvent => {
-      var selectedItem = this.node.selectedItem;
-      if (
-        aEvent.target.localName == "richlistitem" &&
-        aEvent.target == selectedItem
-      ) {
-        var viewId = selectedItem.value;
-
+      let viewId = this.node.selectedItem.value;
+      if (gViewController.currentViewId !== viewId) {
         gViewController.loadView(viewId);
       }
     });
   },
 
   shutdown() {
     AddonManager.removeTypeListener(this);
   },
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -94,16 +94,17 @@ skip-if = verify
 [browser_manage_shortcuts_hidden.js]
 [browser_page_options_install_addon.js]
 [browser_page_options_updates.js]
 [browser_panel_item_accesskey.js]
 [browser_pluginprefs.js]
 [browser_reinstall.js]
 [browser_search_bar_focus.js]
 [browser_shortcuts_duplicate_check.js]
+[browser_sidebar_categories.js]
 [browser_task_next_test.js]
 [browser_updateid.js]
 [browser_updatessl.js]
 [browser_webapi.js]
 [browser_webapi_abuse_report.js]
 support-files =
   head_abuse_report.js
 [browser_webapi_access.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_sidebar_categories.js
@@ -0,0 +1,43 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const THEME_ID = "default-theme@mozilla.org";
+
+add_task(async function testClickingSidebarEntriesChangesView() {
+  let win = await loadInitialView("extension");
+  let doc = win.document;
+  let { managerWindow } = win;
+  let themeCategory = managerWindow.document.getElementById("category-theme");
+
+  let assertViewHas = (selector, msg) => ok(doc.querySelector(selector), msg);
+  let assertListView = type =>
+    assertViewHas(`addon-list[type="${type}"]`, `On ${type} list`);
+
+  assertListView("extension");
+
+  let loaded = waitForViewLoad(win);
+  themeCategory.click();
+  await loaded;
+
+  assertListView("theme");
+
+  loaded = waitForViewLoad(win);
+  getAddonCard(win, THEME_ID).click();
+  await loaded;
+
+  ok(!doc.querySelector("addon-list"), "No more addon-list");
+  assertViewHas(
+    `addon-card[addon-id="${THEME_ID}"][expanded]`,
+    "Detail view now"
+  );
+
+  loaded = waitForViewLoad(win);
+  themeCategory.firstElementChild.click();
+  await loaded;
+
+  assertListView("theme");
+
+  await closeView(win);
+});
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -325,18 +325,22 @@ function check_all_in_list(aManager, aId
   for (let inlistItem of inlist) {
     if (!aIds.includes(inlistItem)) {
       ok(false, "Shouldn't have seen " + inlistItem + " in the list");
     }
   }
 }
 
 function get_addon_element(aManager, aId) {
-  const doc = aManager.getHtmlBrowser().contentDocument;
-  return doc.querySelector(`addon-card[addon-id="${aId}"]`);
+  const win = aManager.getHtmlBrowser().contentWindow;
+  return getAddonCard(win, aId);
+}
+
+function getAddonCard(win, id) {
+  return win.document.querySelector(`addon-card[addon-id="${id}"]`);
 }
 
 function wait_for_view_load(
   aManagerWindow,
   aCallback,
   aForceWait,
   aLongerTimeout
 ) {