Bug 1427754 - Enable ESLint rule mozilla/use-services for accessible/ r=surkov
authorMark Banner <standard8@mozilla.com>
Wed, 03 Jan 2018 15:26:19 +0000
changeset 449579 e31bd656aded8dae312e891ce9422bff575c76dc
parent 449578 cdc7b763df3b1db35197597a991ee0248cff9c85
child 449580 7000040f2b07f846c5f8c08eb61ec366e0f38742
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1427754
milestone59.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 1427754 - Enable ESLint rule mozilla/use-services for accessible/ r=surkov MozReview-Commit-ID: EJoFyhMfQzv
.eslintrc.js
accessible/tests/mochitest/common.js
accessible/tests/mochitest/elm/test_nsApplicationAcc.html
accessible/tests/mochitest/textcaret/test_general.html
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -23,17 +23,16 @@ module.exports = {
     "files": "**/*.*html",
     "rules": {
       "eol-last": "off",
     }
   }, {
     // XXX Bug 1421969. These files/directories are still being fixed,
     // so turn off mozilla/use-services for them for now.
     "files": [
-      "accessible/**",
       // Browser: Bug 1421379
       "browser/extensions/shield-recipe-client/test/browser/head.js",
       "browser/modules/offlineAppCache.jsm",
       "devtools/**",
       "dom/indexedDB/**",
       "dom/media/**",
       "extensions/pref/**",
       "mobile/android/**",
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -705,29 +705,24 @@ function getLoadContext() {
                .getInterface(Ci.nsIWebNavigation)
                .QueryInterface(Ci.nsILoadContext);
 }
 
 /**
  * Return text from clipboard.
  */
 function getTextFromClipboard() {
-  var clip = Components.classes["@mozilla.org/widget/clipboard;1"].
-    getService(Components.interfaces.nsIClipboard);
-  if (!clip)
-    return "";
-
   var trans = Components.classes["@mozilla.org/widget/transferable;1"].
     createInstance(Components.interfaces.nsITransferable);
   trans.init(getLoadContext());
   if (!trans)
     return "";
 
   trans.addDataFlavor("text/unicode");
-  clip.getData(trans, clip.kGlobalClipboard);
+  Services.clipboard.getData(trans, Services.clipboard.kGlobalClipboard);
 
   var str = {};
   var strLength = {};
   trans.getTransferData("text/unicode", str, strLength);
 
   if (str)
     str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
   if (str)
--- a/accessible/tests/mochitest/elm/test_nsApplicationAcc.html
+++ b/accessible/tests/mochitest/elm/test_nsApplicationAcc.html
@@ -1,59 +1,54 @@
 <html>
 
 <head>
   <title>application accessible name</title>
-  <link rel="stylesheet" type="text/css" 
+  <link rel="stylesheet" type="text/css"
          href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-  <script type="application/javascript" 
+  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
-  <script type="application/javascript" 
+  <script type="application/javascript"
           src="../common.js"></script>
-  <script type="application/javascript" 
+  <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
+    /* import-globals-from ../common.js */
     function doTest() {
       var accessible = getApplicationAccessible();
       if (!accessible) {
         SimpleTest.finish();
         return;
       }
 
-      var bundleServ =
-        Components.classes["@mozilla.org/intl/stringbundle;1"].
-        getService(Components.interfaces.nsIStringBundleService);
       var brandBundle =
-        bundleServ.createBundle("chrome://branding/locale/brand.properties");
-
-      var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
-        getService(Components.interfaces.nsIXULAppInfo);
+        Services.strings.createBundle("chrome://branding/locale/brand.properties");
 
       // nsIAccessible::name
       var applicationName = "";
       if (LINUX || SOLARIS) {
-        applicationName = appInfo.name;
+        applicationName = Services.appinfo.name;
       } else {
         try {
           applicationName = brandBundle.GetStringFromName("brandShortName");
         } catch (e) {
         }
 
         if (applicationName == "")
           applicationName = "Gecko based application";
       }
       is(accessible.name, applicationName, "wrong application accessible name");
 
       // nsIAccessibleApplication
-      is(accessible.appName, appInfo.name, "Wrong application name");
-      is(accessible.appVersion, appInfo.version, "Wrong application version");
+      is(accessible.appName, Services.appinfo.name, "Wrong application name");
+      is(accessible.appVersion, Services.appinfo.version, "Wrong application version");
       is(accessible.platformName, "Gecko", "Wrong platform name");
-      is(accessible.platformVersion, appInfo.platformVersion,
+      is(accessible.platformVersion, Services.appinfo.platformVersion,
          "Wrong platform version");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
--- a/accessible/tests/mochitest/textcaret/test_general.html
+++ b/accessible/tests/mochitest/textcaret/test_general.html
@@ -10,23 +10,22 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
+    /* import-globals-from ../common.js */
     /**
      * Turn on/off the caret browsing mode.
      */
     function turnCaretBrowsing(aIsOn) {
-      var prefs = Components.classes["@mozilla.org/preferences-service;1"].
-        getService(Components.interfaces.nsIPrefBranch);
-      prefs.setBoolPref("accessibility.browsewithcaret", aIsOn);
+      Services.prefs.setBoolPref("accessibility.browsewithcaret", aIsOn);
     }
 
     /**
      * Test caret offset for the given accessible.
      */
     function testCaretOffset(aID, aCaretOffset) {
       var acc = getAccessible(aID, [nsIAccessibleText]);
       is(acc.caretOffset, aCaretOffset,