Bug 671555 - Set the correct extensions.checkCompatibility pref in mobile tester tools [r=mfinkle, a=johnath]
authorMatt Brubeck <mbrubeck@mozilla.com>
Tue, 09 Aug 2011 13:03:27 -0700
changeset 72767 7894b27a5a9ada2904ae06e9cd60ac12363ebc13
parent 72766 ddc2fd44b7fa91c692d308b7de817ac79092448e
child 72769 04411da717901c27f45ce295628ee4efb07fb742
push id300
push usermbrubeck@mozilla.com
push dateWed, 10 Aug 2011 03:39:03 +0000
treeherdermozilla-aurora@7894b27a5a9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, johnath
bugs671555
milestone7.0a2
Bug 671555 - Set the correct extensions.checkCompatibility pref in mobile tester tools [r=mfinkle, a=johnath]
mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
--- a/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
+++ b/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
@@ -37,24 +37,30 @@
 
 var Feedback = {
   _prefs: [],
   _device: "",
   _manufacturer: "",
 
   init: function(aEvent) {
     // Delay the widget initialization during startup.
-    window.addEventListener("UIReadyDelayed", function(aEvent) {
+    let panel = document.getElementById("feedback-container");
+    panel.addEventListener("ToolPanelShown", function delayedInit(aEvent) {
+      panel.removeEventListener("ToolPanelShown", delayedInit, false);
+
       let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
       document.getElementById("feedback-about").setAttribute("desc", appInfo.version);
 
       // A simple frame script to fill in the referrer page and device info
       messageManager.loadFrameScript("chrome://feedback/content/content.js", true);
 
-      window.removeEventListener(aEvent.type, arguments.callee, false);
+      let setting = document.getElementById("feedback-checkCompatibility");
+      setting.setAttribute("pref", Feedback.compatibilityPref);
+      setting.preferenceChanged();
+
       document.getElementById("feedback-container").hidden = false;
 
       let feedbackPrefs = document.getElementById("feedback-tools").childNodes;
       for (let i = 0; i < feedbackPrefs.length; i++) {
         let pref = feedbackPrefs[i].getAttribute("pref");
         if (!pref)
           continue;
   
@@ -63,16 +69,30 @@ var Feedback = {
       }
 
       let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
       Feedback._device = sysInfo.get("device");
       Feedback._manufacturer = sysInfo.get("manufacturer");
     }, false);
   },
 
+  get compatibilityPref() {
+    let result = "extensions.checkCompatibility.";
+    let channel = Services.prefs.getCharPref("app.update.channel");
+    if (channel == "nightly") {
+      result += "nightly";
+    } else {
+      // Copied from toolkit/mozapps/extensions/XPIProvider.jsm
+      const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi;
+      result += Services.appinfo.version.replace(BRANCH_REGEXP, "$1");
+    }
+    delete this.compatibilityPref;
+    return this.compatibilityPref = result;
+  },
+
   openFeedback: function(aName) {
     let pref = "extensions.feedback.url." + aName;
     let url = Services.prefs.getPrefType(pref) == Ci.nsIPrefBranch.PREF_INVALID ? "" : Services.prefs.getCharPref(pref);
     if (!url)
       return;
 
     let currentURL = Browser.selectedBrowser.currentURI.spec;
     let newTab = BrowserUI.newTab(url, Browser.selectedTab);
--- a/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
+++ b/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
@@ -63,16 +63,16 @@
             </setting>
           </settings>
           <settings id="feedback-information" label="&feedback.information.title;">
             <setting id="feedback-about" title="&feedback.about.title;" type="control">
               <button id="feedback-about-button" label="&feedback.about.button;" oncommand="Feedback.openReadme();"/>
             </setting>
           </settings>
           <settings id="feedback-tools" label="&feedback.tools.title;">
-            <setting pref="extensions.checkCompatibility.4.0b" title="&feedback.forceCompat.title;" type="bool" inverted="true" oninputchanged="Feedback.updateRestart();"/>
+            <setting id="feedback-checkCompatibility" title="&feedback.forceCompat.title;" type="bool" inverted="true" oninputchanged="Feedback.updateRestart();"/>
             <setting pref="devtools.errorconsole.enabled" title="&feedback.errorConsole.title;" type="bool"/>
           </settings>
         </richlistbox>
       </notificationbox>
     </vbox>
   </deck>
 </overlay>