Bug 1521928 - Enable Eslint for widget (manual changes). r=Standard8,jmathies
authorchampionshuttler <shivams2799@gmail.com>
Thu, 14 Feb 2019 20:20:18 +0000
changeset 459393 0176f4dc4345f1e7620f3984a7be294757616b2b
parent 459392 0e0638c8ef27dea641754aae390213e829eb71f3
child 459394 bf504227f36241116e5d277e11f6bc2c3db1d53c
push id35561
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:37:54 +0000
treeherdermozilla-central@0e2ab35d382d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, jmathies
bugs1521928
milestone67.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 1521928 - Enable Eslint for widget (manual changes). r=Standard8,jmathies Differential Revision: https://phabricator.services.mozilla.com/D18580
widget/headless/tests/test_headless_clipboard.js
widget/tests/test_bug565392.html
widget/tests/test_imestate.html
widget/tests/test_native_key_bindings_mac.html
widget/tests/test_picker_no_crash.html
widget/tests/test_secure_input.html
widget/tests/unit/test_taskbar_jumplistitems.js
widget/tests/window_imestate_iframes.html
widget/tests/window_mouse_scroll_win.html
--- a/widget/headless/tests/test_headless_clipboard.js
+++ b/widget/headless/tests/test_headless_clipboard.js
@@ -1,11 +1,12 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function getString(clipboard) {
   var str = "";
 
   // Create transferable that will transfer the text.
   var trans = Cc["@mozilla.org/widget/transferable;1"]
                         .createInstance(Ci.nsITransferable);
   trans.init(null);
@@ -24,18 +25,17 @@ function getString(clipboard) {
   } catch (ex) {
     // If the clipboard is empty getTransferData will throw.
   }
 
   return str;
 }
 
 add_task(async function test_clipboard() {
-  let clipboard = Cc["@mozilla.org/widget/clipboard;1"]
-                  .getService(Ci.nsIClipboard);
+  let clipboard = Services.clipboard;
 
   // Test copy.
   const data = "random number: " + Math.random();
   let helper = Cc["@mozilla.org/widget/clipboardhelper;1"]
                .getService(Ci.nsIClipboardHelper);
   helper.copyString(data);
   equal(getString(clipboard), data, "Data was successfully copied.");
 
--- a/widget/tests/test_bug565392.html
+++ b/widget/tests/test_bug565392.html
@@ -12,23 +12,22 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug 565392</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 /** Test for Bug 565392 **/
 
-  var ds = Cc["@mozilla.org/file/directory_service;1"]
-             .getService(Ci.nsIProperties);
-  var dir1 = ds.get("ProfD", Ci.nsIFile);
-  var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
-                    .getService(Ci.nsIClipboard);
+var dir1 = Services.dirsvc.get("ProfD", Ci.nsIFile);
+var clipboard = Services.clipboard;
 
   function getLoadContext() {
     return window.docShell.QueryInterface(Ci.nsILoadContext);
   }
 
   function getTransferableFile(file) {
     var transferable = Cc["@mozilla.org/widget/transferable;1"]
                          .createInstance(Ci.nsITransferable);
--- a/widget/tests/test_imestate.html
+++ b/widget/tests/test_imestate.html
@@ -111,29 +111,30 @@ setTestPluginEnabledState(SpecialPowers.
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 SimpleTest.waitForExplicitFinish();
 
 function hitEventLoop(aFunc, aTimes) {
   if (--aTimes) {
     setTimeout(hitEventLoop, 0, aFunc, aTimes);
   } else {
     setTimeout(aFunc, 20);
   }
 }
 
 var gUtils = window.windowUtils;
-var gFM = Cc["@mozilla.org/focus-manager;1"].
-      getService(Ci.nsIFocusManager);
+var gFM = Services.focus;
 const kIMEEnabledSupported = navigator.platform.indexOf("Mac") == 0 ||
                              navigator.platform.indexOf("Win") == 0 ||
                              navigator.platform.indexOf("Linux") == 0;
 
 // We support to control IME open state on Windows and Mac actually.  However,
 // we cannot test it on Mac if the current keyboard layout is not CJK. And also
 // we cannot test it on Win32 if the system didn't be installed IME. So,
 // currently we should not run the open state testing.
@@ -162,35 +163,33 @@ function runBasicTest(aIsEditable, aInDe
   var TIP = Cc["@mozilla.org/text-input-processor;1"]
               .createInstance(Ci.nsITextInputProcessor);
   if (!TIP.beginInputTransactionForTests(window, TIPCallback)) {
     ok(false, "runBasicTest(): failed to begin input transaction");
     return;
   }
 
   function test(aTest) {
-    function moveFocus(aTest, aFocusEventHandler) {
+    function moveFocus(aTestInner, aFocusEventHandler) {
       if (aInDesignMode) {
         if (document.activeElement) {
           document.activeElement.blur();
         }
       } else if (aIsEditable) {
         document.getElementById("display").focus();
       } else if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED) {
         document.getElementById("password").focus();
       } else {
         document.getElementById("text").focus();
       }
       var previousFocusedElement = gFM.focusedElement;
       var element = document.getElementById(aTest.id);
       var focusEventTarget = element;
-      var subDocument = null;
       if (element.contentDocument) {
         focusEventTarget = element.contentDocument;
-        subDocument = element.contentDocument;
         element = element.contentDocument.documentElement;
       }
 
       focusEventTarget.addEventListener("focus", aFocusEventHandler, true);
       onIMEFocusBlurHandler = aFocusEventHandler;
 
       element.focus();
 
@@ -209,17 +208,17 @@ function runBasicTest(aIsEditable, aInDe
            aDescription + ": " + aTest.description + ", focus didn't move");
         return (element == focusedElement);
       }
       is(focusedElement, previousFocusedElement,
          aDescription + ": " + aTest.description + ", focus moved as unexpected");
       return (previousFocusedElement == focusedElement);
     }
 
-    function testOpened(aTest, aOpened) {
+    function testOpened(aTestInner, aOpened) {
       document.getElementById("text").focus();
       gUtils.IMEIsOpen = aOpened;
       if (!moveFocus(aTest)) {
         return;
       }
       var message = aDescription + ": " + aTest.description +
                                             ", wrong opened state";
       is(gUtils.IMEIsOpen,
@@ -312,17 +311,17 @@ function runBasicTest(aIsEditable, aInDe
            aDescription + ": " + aTest.description +
              ", IME shouldn't receive a focus notification at testing non-focusable element");
         is(IMEReceivesBlur, 0,
            aDescription + ": " + aTest.description +
              ", IME shouldn't receive a blur notification at testing non-focusable element");
       }
 
       enabled = gUtils.IMEStatus;
-      inputtype = gUtils.focusedInputType;
+      var inputtype = gUtils.focusedInputType;
       is(enabled, aTest.expectedEnabled,
          aDescription + ": " + aTest.description + ", wrong enabled state");
       if (aTest.expectedType && !aInDesignMode) {
         is(inputtype, aTest.expectedType,
            aDescription + ": " + aTest.description + ", wrong input type");
       } else if (aInDesignMode) {
         is(inputtype, "",
            aDescription + ": " + aTest.description + ", wrong input type");
@@ -1064,17 +1063,16 @@ function runComplexContenteditableTests(
   container.removeAttribute("contenteditable");
   is(gFM.focusedElement, button,
      description + "The button loses focus, the container has been no editable");
   todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
           description + "IME is still enabled on the button, the container has been no editable");
 
   description = "testOnIndependentEditor: ";
   function testOnIndependentEditor(aEditor, aEditorDescription) {
-    var isReadonly = aEditor.readOnly;
     var expectedState =
       aEditor.readOnly ? gUtils.IME_STATUS_DISABLED : gUtils.IME_STATUS_ENABLED;
     var unexpectedStateDescription =
       expectedState != gUtils.IME_STATUS_ENABLED ? "enabled" : "disabled";
     aEditor.focus();
     is(gFM.focusedElement, aEditor,
        description + "The " + aEditorDescription + " doesn't get focus");
     is(gUtils.IMEStatus, expectedState,
@@ -1269,44 +1267,38 @@ function runTestPasswordFieldOnDialog() 
 
   if (document.activeElement) {
     document.activeElement.blur();
   }
 
   var dialog;
 
   function WindowObserver() {
-    Cc["@mozilla.org/observer-service;1"].
-       getService(Ci.nsIObserverService).
-       addObserver(this, "domwindowopened");
+    Services.obs.addObserver(this, "domwindowopened");
   }
 
   WindowObserver.prototype = {
     QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
 
     observe(subject, topic, data) {
       if (topic === "domwindowopened") {
         ok(true, "dialog window is created");
         dialog = subject.QueryInterface(Ci.nsIDOMWindow);
         dialog.addEventListener("load", onPasswordDialogLoad);
       }
     },
   };
 
   var observer = new WindowObserver();
-  var arg1 = new Object(), arg2 = new Object();
-  Cc["@mozilla.org/embedcomp/prompt-service;1"].
-     getService(Ci.nsIPromptService).
-     promptPassword(window, "title", "text", arg1, "msg", arg2);
+  var arg1 = {}, arg2 = {};
+  Services.prompt.promptPassword(window, "title", "text", arg1, "msg", arg2);
 
   ok(true, "password dialog was closed");
 
-  Cc["@mozilla.org/observer-service;1"].
-     getService(Ci.nsIObserverService).
-     removeObserver(observer, "domwindowopened");
+  Services.obs.addObserver(observer, "domwindowopened");
 
   var passwordField;
 
   function onPasswordDialogLoad() {
     ok(true, "onPasswordDialogLoad is called");
     dialog.removeEventListener("load", onPasswordDialogLoad);
     passwordField = dialog.document.getElementById("password1Textbox");
     passwordField.addEventListener("focus", onPasswordFieldFocus);
--- a/widget/tests/test_native_key_bindings_mac.html
+++ b/widget/tests/test_native_key_bindings_mac.html
@@ -299,17 +299,17 @@
         if (document.activeElement) {
           document.activeElement.blur();
         }
 
         aElement.focus();
 
         for (let i = 0; i < synthesizedKeys.length; i++) {
           synthesizedKeys[i].push(function() {
-            aSelectionCheck.call(null, aElement, expectations[i]);
+            aSelectionCheck(aElement, expectations[i]);
             continueTest();
           });
           var synthOk = synthesizeNativeKey.apply(null, synthesizedKeys[i]);
           synthesizedKeys[i].pop();
           yield synthOk;
         }
       }
 
--- a/widget/tests/test_picker_no_crash.html
+++ b/widget/tests/test_picker_no_crash.html
@@ -17,17 +17,17 @@ function testStepOne() {
   childWindow = window.open("window_picker_no_crash_child.html", "childWindow", "width=300,height=150");
   SimpleTest.waitForFocus(testStepTwo, childWindow);
 }
 
 function testStepTwo() {
   childWindow.document.form1.uploadbox.click();
   // This should not crash the browser
   childWindow.close();
-  setTimeout("testStepThree();", 5000);
+  setTimeout(testStepThree, 5000);
 }
 
 function testStepThree() {
   ok(true, "browser didn't crash");
   SimpleTest.finish();
 }
 
 SimpleTest.waitForFocus(testStepOne);
--- a/widget/tests/test_secure_input.html
+++ b/widget/tests/test_secure_input.html
@@ -72,17 +72,17 @@
     $("input_change").focus();
     $("input_change").type = "password";
     sendAKeyEvent();
     ok(true, "Not crashed: input on <input type=\"password\"> changed from type=\"text\"");
     $("input_change").type = "text";
     sendAKeyEvent();
     ok(true, "Not crashed: input on <input type=\"text\"> changed from type=\"password\"");
 
-    otherWindow =
+    var otherWindow =
       window.open("file_secure_input.html",
                   "_blank", "chrome,width=100,height=100");
     ok(otherWindow, "failed to open other window");
     if (!otherWindow) {
       SimpleTest.finish();
       return;
     }
 
--- a/widget/tests/unit/test_taskbar_jumplistitems.js
+++ b/widget/tests/unit/test_taskbar_jumplistitems.js
@@ -1,14 +1,15 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This tests taskbar jump list functionality available on win7 and up.
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function test_basics() {
   var item = Cc["@mozilla.org/windows-jumplistitem;1"].
   createInstance(Ci.nsIJumpListItem);
 
   var sep = Cc["@mozilla.org/windows-jumplistseparator;1"].
   createInstance(Ci.nsIJumpListSeparator);
 
@@ -151,20 +152,17 @@ function test_shortcuts() {
 
   var faviconPageUri = Cc["@mozilla.org/network/simple-uri-mutator;1"]
                          .createInstance(Ci.nsIURIMutator)
                          .setSpec("http://www.123.com/")
                          .finalize();
   sc.faviconPageUri = faviconPageUri;
   Assert.equal(sc.faviconPageUri, faviconPageUri);
 
-  var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
-                  getService(Ci.nsIProperties).
-                  QueryInterface(Ci.nsIDirectoryService);
-  var notepad = dirSvc.get("WinD", Ci.nsIFile);
+  var notepad = Services.dirsvc.get("WinD", Ci.nsIFile);
   notepad.append("notepad.exe");
   if (notepad.exists()) {
     handlerApp.executable = notepad;
     sc.app = handlerApp;
     Assert.equal(sc.app.detailedDescription, "TestApp detailed description.");
     Assert.equal(sc.app.name, "TestApp");
     Assert.ok(sc.app.parameterExists("-test"));
     Assert.ok(!sc.app.parameterExists("-notset"));
@@ -210,20 +208,17 @@ async function test_jumplist() {
            .createInstance(Ci.nsIJumpListShortcut);
 
   var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"]
                    .createInstance(Ci.nsILocalHandlerApp);
 
   handlerApp.name = "Notepad";
   handlerApp.detailedDescription = "Testing detailed description.";
 
-  var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
-                  getService(Ci.nsIProperties).
-                  QueryInterface(Ci.nsIDirectoryService);
-  var notepad = dirSvc.get("WinD", Ci.nsIFile);
+  var notepad = Services.dirsvc.get("WinD", Ci.nsIFile);
   notepad.append("notepad.exe");
   if (notepad.exists()) {
     // To ensure "profile-before-change" will fire before
     // "xpcom-shutdown-threads"
     do_get_profile();
 
     handlerApp.executable = notepad;
     sc.app = handlerApp;
--- a/widget/tests/window_imestate_iframes.html
+++ b/widget/tests/window_imestate_iframes.html
@@ -29,16 +29,18 @@
           src="data:text/html,&lt;body id='editor' contenteditable='true'&gt;&lt;a href='about:blank'&gt;about:blank;&lt;/a&gt;&lt;/body&gt;"></iframe><br>
   <iframe id="iframe_p"
           src="data:text/html,&lt;body&gt;&lt;p id='editor' contenteditable='true'&gt;&lt;a href='about:blank'&gt;about:blank;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;"></iframe><br>
 
   <input id="next" readonly><br>
 </p>
 <script class="testbody" type="application/javascript">
 
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 function ok(aCondition, aMessage) {
   window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage) {
   window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
@@ -96,21 +98,19 @@ function observeFocusBlur(aNextFocusedNo
     gBlurObservingElement = aNextBlurredNode;
     gBlurObservingElement.willBlur = aWillFireBlurEvent;
     gBlurObservingElement.addEventListener("blur", onBlur, true);
   }
 }
 
 function runTests() {
   var utils = window.windowUtils;
-  var fm =
-    Cc["@mozilla.org/focus-manager;1"]
-      .getService(Ci.nsIFocusManager);
+  var fm = Services.focus;
 
-  var iframe, editor, root, input;
+  var iframe, editor, root;
   var prev = document.getElementById("prev");
   var next = document.getElementById("next");
   var html = document.documentElement;
 
   function resetFocusToInput(aDescription) {
     observeFocusBlur(null, false, null, false);
     prev.focus();
     is(fm.focusedElement, prev,
--- a/widget/tests/window_mouse_scroll_win.html
+++ b/widget/tests/window_mouse_scroll_win.html
@@ -15,16 +15,18 @@
 <p id="p2" style="font-size: 32px; width: 100px; height: 100px;">2nd &lt;p&gt;.</p>
 </div>
 <script class="testbody" type="application/javascript">
 
 window.opener.wrappedJSObject.SimpleTest.waitForFocus(prepareTests, window);
 
 const nsIDOMWindowUtils = Ci.nsIDOMWindowUtils;
 
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 const WHEEL_PAGESCROLL = 4294967295;
 
 const WM_VSCROLL     = 0x0115;
 const WM_HSCROLL     = 0x0114;
 const WM_MOUSEWHEEL  = 0x020A;
 const WM_MOUSEHWHEEL = 0x020E;
 
 const SB_LINEUP    = 0;
@@ -1098,18 +1100,17 @@ var gDeactiveWindowTests = [
     expected: {
       axis: kVAxis, lines: 3, pixels() { return gLineHeight * 3; },
     },
     init() {
       SpecialPowers.setIntPref(kVAmountPref, 3);
       SpecialPowers.setIntPref(kHAmountPref, 3);
     },
     onLineScrollEvent(aEvent) {
-      var fm = Cc["@mozilla.org/focus-manager;1"].
-            getService(Ci.nsIFocusManager);
+      var fm = Services.focus;
       is(fm.activeWindow, gOtherWindow, "The other window isn't activated");
     },
   },
 
   { description: "WM_MOUSEWHEEL, 120, -3 lines, window is deactive",
     message: WM_MOUSEWHEEL, delta: 120,
     target: gP1, x: 10, y: 10, window,
     modifiers: 0,