Bug 1231509 - Using more than just an expression in XBL fields confuses the eslint xbl preprocessor. r=mossop
authorPhilipp Kewisch <mozilla@kewis.ch>
Mon, 19 Sep 2016 11:31:38 +0200
changeset 344095 9fb7792946fbf759e20de38bda7e14213559850d
parent 344069 45052ddb03a448606ca6ce33f4893a559edebf72
child 344096 ee2f29d9d25d5796a80327a844909facecf0d120
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1231509
milestone52.0a1
Bug 1231509 - Using more than just an expression in XBL fields confuses the eslint xbl preprocessor. r=mossop MozReview-Commit-ID: 4lMiSP0ery4
browser/base/content/urlbarBindings.xml
toolkit/content/widgets/autocomplete.xml
toolkit/content/widgets/preferences.xml
toolkit/content/widgets/tabbox.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1853,23 +1853,29 @@ file, You can obtain one at http://mozil
       ]]></destructor>
 
       <field name="progressmeter" readonly="true">
         document.getElementById("addon-progress-notification-progressmeter");
       </field>
       <field name="progresstext" readonly="true">
         document.getElementById("addon-progress-notification-progresstext");
       </field>
-      <field name="DownloadUtils" readonly="true">
-        {
-          let utils = {};
-          Components.utils.import("resource://gre/modules/DownloadUtils.jsm", utils);
-          utils.DownloadUtils;
-        }
-      </field>
+      <property name="DownloadUtils" readonly="true">
+        <getter><![CDATA[
+          let module = {};
+          Components.utils.import("resource://gre/modules/DownloadUtils.jsm", module);
+          Object.defineProperty(this, "DownloadUtils", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: module.DownloadUtils
+          });
+          return module.DownloadUtils;
+        ]]></getter>
+      </property>
 
       <method name="destroy">
         <body><![CDATA[
           if (!this.notification)
             return;
 
           this.notification.options.installs.forEach(function(aInstall) {
             aInstall.removeListener(this);
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -64,36 +64,43 @@
       ]]></constructor>
 
       <destructor><![CDATA[
         this.inputField.controllers.removeController(this._pasteController);
       ]]></destructor>
 
       <!-- =================== nsIAutoCompleteInput =================== -->
 
-      <field name="popup"><![CDATA[
-        // Wrap in a block so that the let statements don't
-        // create properties on 'this' (bug 635252).
-        {
+      <property name="popup" readonly="true">
+        <getter><![CDATA[
           let popup = null;
           let popupId = this.getAttribute("autocompletepopup");
-          if (popupId)
+          if (popupId) {
             popup = document.getElementById(popupId);
+          }
           if (!popup) {
             popup = document.createElement("panel");
             popup.setAttribute("type", "autocomplete");
             popup.setAttribute("noautofocus", "true");
 
             let popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
             popupset.appendChild(popup);
           }
           popup.mInput = this;
-          popup;
-        }
-      ]]></field>
+
+          // Avoid having to recalculate the popup property each time
+          Object.defineProperty(this, "popup", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: popup
+          });
+          return popup;
+        ]]></getter>
+      </property>
 
       <property name="controller" onget="return this.mController;" readonly="true"/>
 
       <property name="popupOpen"
                 onget="return this.popup.popupOpen;"
                 onset="if (val) this.openPopup(); else this.closePopup();"/>
 
       <property name="disableAutoComplete"
@@ -144,23 +151,29 @@
 
       <property name="searchCount" readonly="true"
                 onget="this.initSearchNames(); return this.mSearchNames.length;"/>
 
       <field name="shrinkDelay" readonly="true">
         parseInt(this.getAttribute("shrinkdelay")) || 0
       </field>
 
-      <field name="PrivateBrowsingUtils" readonly="true">
-        {
-          let utils = {};
-          Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm", utils);
-          utils.PrivateBrowsingUtils
-        }
-      </field>
+      <property name="PrivateBrowsingUtils" readonly="true">
+        <getter><![CDATA[
+          let module = {};
+          Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm", module);
+          Object.defineProperty(this, "PrivateBrowsingUtils", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: module.PrivateBrowsingUtils
+          });
+          return module.PrivateBrowsingUtils;
+        ]]></getter>
+      </property>
 
       <property name="inPrivateContext" readonly="true"
                 onget="return this.PrivateBrowsingUtils.isWindowPrivate(window);"/>
 
       <property name="noRollupOnCaretMove" readonly="true"
                 onget="return this.popup.getAttribute('norolluponanchor') == 'true'"/>
 
       <!-- This is the maximum number of drop-down rows we get when we
--- a/toolkit/content/widgets/preferences.xml
+++ b/toolkit/content/widgets/preferences.xml
@@ -1258,21 +1258,29 @@
           while (temp && temp.nodeType == Node.ELEMENT_NODE &&
                  !temp.hasAttribute("preference"))
             temp = temp.parentNode;
           return temp.nodeType == Node.ELEMENT_NODE ? temp : aStartElement;
         ]]>
         </body>
       </method>
 
-      <field name="DeferredTask" readonly="true">
-        let targetObj = {};
-        Components.utils.import("resource://gre/modules/DeferredTask.jsm", targetObj);
-        targetObj.DeferredTask;
-      </field>
+      <property name="DeferredTask" readonly="true">
+        <getter><![CDATA[
+          let module = {};
+          Components.utils.import("resource://gre/modules/DeferredTask.jsm", module);
+          Object.defineProperty(this, "DeferredTask", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: module.DeferredTask
+          });
+          return module.DeferredTask;
+        ]]></getter>
+      </property>
       <method name="_deferredValueUpdate">
         <parameter name="aElement"/>
         <body>
         <![CDATA[
           delete aElement._deferredValueUpdateTask;
           let preference = document.getElementById(aElement.getAttribute("preference"));
           let prefVal = preference.getElementValue(aElement);
           preference.value = prefVal;
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -344,25 +344,36 @@
                 break;
               }
             }
             return val;
           ]]>
         </setter>
       </property>
 
-      <field name="tabbox" readonly="true"><![CDATA[
-        var parent = this.parentNode;
-        while (parent) {
-          if (parent.localName == "tabbox")
-            break;
-          parent = parent.parentNode;
-        }
-        parent;
-      ]]></field>
+      <property name="tabbox" readonly="true">
+        <getter><![CDATA[
+          let parent = this.parentNode;
+          while (parent) {
+            if (parent.localName == "tabbox") {
+              break;
+            }
+            parent = parent.parentNode;
+          }
+
+          // Avoid having to recalculate the tabbox property each time
+          Object.defineProperty(this, "tabbox", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: parent
+          });
+          return parent;
+        ]]></getter>
+      </property>
 
       <!-- _tabbox is deprecated, it exists only for backwards compatibility. -->
       <field name="_tabbox" readonly="true"><![CDATA[
         this.tabbox;
       ]]></field>
 
       <property name="selectedIndex">
         <getter>
@@ -628,25 +639,36 @@
           }
 
           return tabElmFromIndex;
         ]]>
         </body>
       </method>
 
       <!-- public -->
-      <field name="tabbox" readonly="true"><![CDATA[
-        var parent = this.parentNode;
-        while (parent) {
-          if (parent.localName == "tabbox")
-            break;
-          parent = parent.parentNode;
-        }
-        parent;
-      ]]></field>
+      <property name="tabbox" readonly="true">
+        <getter><![CDATA[
+          let parent = this.parentNode;
+          while (parent) {
+            if (parent.localName == "tabbox") {
+              break;
+            }
+            parent = parent.parentNode;
+          }
+
+          // Avoid having to recalculate the tabbox property each time
+          Object.defineProperty(this, "tabbox", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: parent
+          });
+          return parent;
+        ]]></getter>
+      </property>
 
       <field name="_selectedPanel">this.childNodes.item(this.selectedIndex)</field>
 
       <property name="selectedIndex">
         <getter>
         <![CDATA[
           var indexStr = this.getAttribute("selectedIndex");
           return indexStr ? parseInt(indexStr) : -1;
@@ -765,23 +787,29 @@
       </method>
 
       <property name="linkedPanel" onget="return this.getAttribute('linkedpanel')"
                                    onset="this.setAttribute('linkedpanel', val); return val;"/>
 
       <field name="arrowKeysShouldWrap" readonly="true">
         /Mac/.test(navigator.platform)
       </field>
-      <field name="TelemetryStopwatch" readonly="true">
-        {
-          let tmp = {};
-          Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", tmp);
-          tmp.TelemetryStopwatch;
-        }
-      </field>
+      <property name="TelemetryStopwatch" readonly="true">
+        <getter><![CDATA[
+          let module = {};
+          Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", module);
+          Object.defineProperty(this, "TelemetryStopwatch", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: module.TelemetryStopwatch
+          });
+          return module.TelemetryStopwatch;
+        ]]></getter>
+      </property>
     </implementation>
 
     <handlers>
       <handler event="mousedown" button="0">
       <![CDATA[
         if (this.disabled)
           return;