From 100f42a912271d1b110611ddcaa5faa114379455 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Wed, 20 Mar 2013 15:30:24 -0400 Subject: [PATCH] Bug 852962 - Bad optionsURL will show 'options' header but no options r=margaret --- mobile/android/chrome/content/aboutAddons.js | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/mobile/android/chrome/content/aboutAddons.js b/mobile/android/chrome/content/aboutAddons.js index e023b5e2166f..93ccbb4e9da1 100644 --- a/mobile/android/chrome/content/aboutAddons.js +++ b/mobile/android/chrome/content/aboutAddons.js @@ -328,22 +328,28 @@ var Addons = { if (xhr.responseXML) { // Only allow for now let settings = xhr.responseXML.querySelectorAll(":root > setting"); - for (let i = 0; i < settings.length; i++) { - var setting = settings[i]; - var desc = stripTextNodes(setting).trim(); - if (!setting.hasAttribute("desc")) - setting.setAttribute("desc", desc); - box.appendChild(setting); + if (settings.length > 0) { + for (let i = 0; i < settings.length; i++) { + var setting = settings[i]; + var desc = stripTextNodes(setting).trim(); + if (!setting.hasAttribute("desc")) + setting.setAttribute("desc", desc); + box.appendChild(setting); + } + // Send an event so add-ons can prepopulate any non-preference based + // settings + let event = document.createEvent("Events"); + event.initEvent("AddonOptionsLoad", true, false); + window.dispatchEvent(event); + + // Also send a notification to match the behavior of desktop Firefox + let id = aListItem.getAttribute("addonID"); + Services.obs.notifyObservers(document, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, id); + } else { + // No options, so hide the header and reset the list item + detailItem.setAttribute("optionsURL", ""); + aListItem.setAttribute("optionsURL", ""); } - // Send an event so add-ons can prepopulate any non-preference based - // settings - let event = document.createEvent("Events"); - event.initEvent("AddonOptionsLoad", true, false); - window.dispatchEvent(event); - - // Also send a notification to match the behavior of desktop Firefox - let id = aListItem.getAttribute("addonID"); - Services.obs.notifyObservers(document, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, id); } } catch (e) { }