Bug 1471811 - "ReferenceError: Services is not defined" in autocomplete.xml. r=Gijs,jorgk
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 26 Nov 2018 12:14:14 +0000
changeset 504404 326ed3b7c89498850b2830fbaa18b850841ecaec
parent 504403 6040483f1f0aa53d3049ce30209328eb0e2c27f2
child 504405 693821f7cf935d9ad882af4b12f699562a6e7ea7
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, jorgk
bugs1471811
milestone65.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 1471811 - "ReferenceError: Services is not defined" in autocomplete.xml. r=Gijs,jorgk Differential Revision: https://phabricator.services.mozilla.com/D12889
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1221,17 +1221,17 @@
                            class="ac-action-text"
                            xbl:inherits="selected"/>
         </xul:description>
       </xul:hbox>
     </content>
 
     <handlers>
       <handler event="click" button="0"><![CDATA[
-        let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
+        let baseURL = this.Services.urlFormatter.formatURLPref("app.support.baseURL");
         window.openTrustedLinkIn(baseURL + "insecure-password", "tab", {
           relatedToCurrent: true,
         });
       ]]></handler>
     </handlers>
 
     <implementation>
       <constructor><![CDATA[
@@ -1240,17 +1240,17 @@
         // recalculate an item's height and width.
         this.classList.add("forceHandleUnderflow");
       ]]></constructor>
 
       <property name="_learnMoreString">
         <getter><![CDATA[
           if (!this.__learnMoreString) {
             this.__learnMoreString =
-              Services.strings.createBundle("chrome://passwordmgr/locale/passwordmgr.properties").
+              this.Services.strings.createBundle("chrome://passwordmgr/locale/passwordmgr.properties").
               GetStringFromName("insecureFieldWarningLearnMore");
           }
           return this.__learnMoreString;
         ]]></getter>
       </property>
 
       <!-- Override _getSearchTokens to have the Learn More text emphasized -->
       <method name="_getSearchTokens">
@@ -1347,16 +1347,34 @@
           );
           this._actionText = document.getAnonymousElementByAttribute(
             this, "anonid", "action-text"
           );
           this._adjustAcItem();
         ]]>
       </constructor>
 
+      <property name="Services" readonly="true">
+        <getter><![CDATA[
+          let module = {};
+          if (window.Services) {
+            module.Services = window.Services;
+          } else {
+            ChromeUtils.import("resource://gre/modules/Services.jsm", module);
+          }
+          Object.defineProperty(this, "Services", {
+            configurable: true,
+            enumerable: true,
+            writable: true,
+            value: module.Services,
+          });
+          return module.Services;
+        ]]></getter>
+      </property>
+
       <method name="_cleanup">
         <body>
         <![CDATA[
           this.removeAttribute("url");
           this.removeAttribute("image");
           this.removeAttribute("title");
           this.removeAttribute("text");
           this.removeAttribute("displayurl");
@@ -1386,17 +1404,17 @@
             return label;
           ]]>
         </getter>
       </property>
 
       <property name="_stringBundle">
         <getter><![CDATA[
           if (!this.__stringBundle) {
-            this.__stringBundle = Services.strings.createBundle("chrome://global/locale/autocomplete.properties");
+            this.__stringBundle = this.Services.strings.createBundle("chrome://global/locale/autocomplete.properties");
           }
           return this.__stringBundle;
         ]]></getter>
       </property>
 
       <field name="_boundaryCutoff">null</field>
 
       <property name="boundaryCutoff" readonly="true">
@@ -1734,17 +1752,17 @@
           ]]>
         </body>
       </method>
 
       <method name="_unescapeUrl">
         <parameter name="url"/>
         <body>
           <![CDATA[
-          return Services.textToSubURI.unEscapeURIForUI("UTF-8", url);
+          return this.Services.textToSubURI.unEscapeURIForUI("UTF-8", url);
           ]]>
         </body>
       </method>
 
       <method name="_reuseAcItem">
         <body>
           <![CDATA[
             let action = this._parseActionUrl(this.getAttribute("url"));
@@ -1956,17 +1974,17 @@
             displayUrl = displayUrl.substr(0, popup.textRunsMaxLen);
           }
           this.setAttribute("displayurl", displayUrl);
 
           // Show the domain as the title if we don't have a title.
           if (!title) {
             titleLooksLikeUrl = true;
             try {
-              let uri = Services.io.newURI(originalUrl);
+              let uri = this.Services.io.newURI(originalUrl);
               // Not all valid URLs have a domain.
               if (uri.host)
                 title = uri.host;
             } catch (e) {}
             if (!title)
               title = displayUrl;
           }