diff --git a/.eslintrc.js b/.eslintrc.js index de87304061990..583b71b3ffac5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -564,32 +564,6 @@ module.exports = { }, { files: [ - "toolkit/content/tests/chrome/frame_popup_anchor.xhtml", - "toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml", - "toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml", - "toolkit/content/tests/chrome/test_arrowpanel.xhtml", - "toolkit/content/tests/chrome/test_autocomplete2.xhtml", - "toolkit/content/tests/chrome/test_autocomplete3.xhtml", - "toolkit/content/tests/chrome/test_autocomplete4.xhtml", - "toolkit/content/tests/chrome/test_autocomplete5.xhtml", - "toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml", - "toolkit/content/tests/chrome/test_autocomplete_mac_caret.xhtml", - "toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml", - "toolkit/content/tests/chrome/test_browser_drop.xhtml", - "toolkit/content/tests/chrome/test_bug1048178.xhtml", - "toolkit/content/tests/chrome/test_bug382990.xhtml", - "toolkit/content/tests/chrome/test_bug437844.xhtml", - "toolkit/content/tests/chrome/test_bug624329.xhtml", - "toolkit/content/tests/chrome/test_bug792324.xhtml", - "toolkit/content/tests/chrome/test_contextmenu_list.xhtml", - "toolkit/content/tests/chrome/test_cursorsnap.xhtml", - "toolkit/content/tests/chrome/test_dialogfocus.xhtml", - "toolkit/content/tests/chrome/test_hiddenitems.xhtml", - "toolkit/content/tests/chrome/test_hiddenpaging.xhtml", - "toolkit/content/tests/chrome/test_maximized_persist.xhtml", - "toolkit/content/tests/chrome/test_menu.xhtml", - "toolkit/content/tests/chrome/test_menuitem_blink.xhtml", - "toolkit/content/tests/chrome/test_menulist.xhtml", "toolkit/content/tests/chrome/test_menulist_keynav.xhtml", "toolkit/content/tests/chrome/test_mousescroll.xhtml", "toolkit/content/tests/chrome/test_mozinputbox_dictionary.xhtml", diff --git a/toolkit/content/tests/chrome/frame_popup_anchor.xhtml b/toolkit/content/tests/chrome/frame_popup_anchor.xhtml index df52936c06c02..142bc7b0af746 100644 --- a/toolkit/content/tests/chrome/frame_popup_anchor.xhtml +++ b/toolkit/content/tests/chrome/frame_popup_anchor.xhtml @@ -35,13 +35,13 @@ function popupShown() var left, top; var popuprect = document.getElementById("popup").getBoundingClientRect(); if (isSecondTest) { - var buttonrect = document.getElementById("button").getBoundingClientRect(); + let buttonrect = document.getElementById("button").getBoundingClientRect(); left = buttonrect.left + 6; top = buttonrect.top + 6; } else { - var iframerect = parent.document.getElementById("frame").getBoundingClientRect(); - var buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect(); + let iframerect = parent.document.getElementById("frame").getBoundingClientRect(); + let buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect(); // The popup should appear anchored on the bottom left edge of the button, however // the client rectangle is relative to the iframe's document. Thus the coordinates diff --git a/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml b/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml index 4b57303e75178..f68a06d85d516 100644 --- a/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml +++ b/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml @@ -27,7 +27,6 @@ function runTests() function mouseMove(e) { e.stopPropagation(); - var element = e.target; var el = document.getElementById("cap1"); el.label = "client: (" + e.clientX + "," + e.clientY + ")"; parent.arguments[0].SimpleTest.is(e.clientX, 3, "mouse event clientX on sub frame 1"); @@ -36,7 +35,7 @@ function mouseMove(e) { frames[0].runTests(); } -window.addEventListener("mousemove", mouseMove, false); +window.addEventListener("mousemove", mouseMove); diff --git a/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml b/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml index 9ea0f9ebfe65e..338877ff965a9 100644 --- a/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml +++ b/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml @@ -23,7 +23,6 @@ function runTests() function mouseMove(e) { e.stopPropagation(); - var element = e.target; var el = document.getElementById("cap2"); el.label = "client: (" + e.clientX + "," + e.clientY + ")"; parent.parent.arguments[0].SimpleTest.is(e.clientX, 6, "mouse event clientX on sub frame 2"); @@ -32,7 +31,7 @@ function mouseMove(e) { parent.parent.close(); } -window.addEventListener("mousemove",mouseMove, false); +window.addEventListener("mousemove", mouseMove); diff --git a/toolkit/content/tests/chrome/test_arrowpanel.xhtml b/toolkit/content/tests/chrome/test_arrowpanel.xhtml index 5e6ccd000eb2d..6da6648a73503 100644 --- a/toolkit/content/tests/chrome/test_arrowpanel.xhtml +++ b/toolkit/content/tests/chrome/test_arrowpanel.xhtml @@ -201,7 +201,7 @@ function* nextTest() } // Check that the transition occurs for an arrow panel with animate="true" - $("animatepanel").addEventListener("transitionend", transitionEnded, false); + $("animatepanel").addEventListener("transitionend", transitionEnded); $("animatepanel").openPopup($("topleft"), "after_start", 0, 0, false, false, null, "start"); is($("animatepanel").state, "showing", "state is showing"); yield; diff --git a/toolkit/content/tests/chrome/test_autocomplete2.xhtml b/toolkit/content/tests/chrome/test_autocomplete2.xhtml index e9a58c143b164..4a051357eb070 100644 --- a/toolkit/content/tests/chrome/test_autocomplete2.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete2.xhtml @@ -41,38 +41,31 @@ nsAutoCompleteSimpleResult.prototype = { defaultIndex: -1, errorDescription: null, matchCount: 0, - getValueAt: function() { return this._param; }, - getCommentAt: function() { return null; }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getFinalCompleteValueAt: function() { return this.getValueAt(); }, - getLabelAt: function() { return null; }, - removeValueAt: function() {} + getValueAt() { return this._param; }, + getCommentAt() { return null; }, + getStyleAt() { return null; }, + getImageAtn() { return null; }, + getFinalCompleteValueAt() { return this.getValueAt(); }, + getLabelAt() { return null; }, + removeValueAt() {} }; // A basic autocomplete implementation that either returns one result or none var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple" var autoCompleteSimple = { - QueryInterface: function(iid) { - if (iid.equals(Ci.nsISupports) || - iid.equals(Ci.nsIFactory) || - iid.equals(Ci.nsIAutoCompleteSearch)) - return this; + QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]), - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, - - createInstance: function(outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - startSearch: function(aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { var result = new nsAutoCompleteSimpleResult(aString); aListener.onSearchResult(this, result); }, - stopSearch: function() {} + stopSearch() {} }; var componentManager = Components.manager diff --git a/toolkit/content/tests/chrome/test_autocomplete3.xhtml b/toolkit/content/tests/chrome/test_autocomplete3.xhtml index c2d9566563576..04a5117b6adb8 100644 --- a/toolkit/content/tests/chrome/test_autocomplete3.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete3.xhtml @@ -41,38 +41,31 @@ nsAutoCompleteSimpleResult.prototype = { defaultIndex: 0, errorDescription: null, matchCount: 0, - getValueAt: function() { return this._param; }, - getCommentAt: function() { return null; }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getFinalCompleteValueAt: function() { return this.getValueAt(); }, - getLabelAt: function() { return null; }, - removeValueAt: function() {} + getValueAt() { return this._param; }, + getCommentAt() { return null; }, + getStyleAt() { return null; }, + getImageAt() { return null; }, + getFinalCompleteValueAt() { return this.getValueAt(); }, + getLabelAt() { return null; }, + removeValueAt() {} }; // A basic autocomplete implementation that either returns one result or none var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple" var autoCompleteSimple = { - QueryInterface: function(iid) { - if (iid.equals(Ci.nsISupports) || - iid.equals(Ci.nsIFactory) || - iid.equals(Ci.nsIAutoCompleteSearch)) - return this; + QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]), - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, - - createInstance: function(outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - startSearch: function(aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { var result = new nsAutoCompleteSimpleResult(aString); aListener.onSearchResult(this, result); }, - stopSearch: function() {} + stopSearch() {} }; var componentManager = Components.manager @@ -142,7 +135,6 @@ function checkNext() { function checkResult() { var autocomplete = $("autocomplete"); - var style = window.getComputedStyle(autocomplete); is(autocomplete.value, tests[currentTest].result, "Test " + currentTest + ": autocomplete.value should equal '" + @@ -158,26 +150,38 @@ function checkResult() { ++currentTest; - if (currentTest < tests.length) + if (currentTest < tests.length) { setTimeout(checkNext, 0); - else { + } else { // TODO (bug 494809): Autocomplete-in-the-middle should take in count RTL // and complete on KEY_ArrowRight or KEY_ArrowLeft based on that. It should also revert // what user has typed to far if he moves in the opposite direction. if (!autocomplete.value.includes(">>")) { // Test result if user accepts autocomplete suggestion. synthesizeKey("KEY_ArrowRight"); - is(autocomplete.value, "Result", - "Test complete: autocomplete.value should equal 'Result'"); - is(autocomplete.selectionStart, 6, - "Test complete: autocomplete selection should start at 6"); - is(autocomplete.selectionEnd, 6, - "Test complete: autocomplete selection should end at 6"); + is( + autocomplete.value, + "Result", + "Test complete: autocomplete.value should equal 'Result'" + ); + is( + autocomplete.selectionStart, + 6, + "Test complete: autocomplete selection should start at 6" + ); + is( + autocomplete.selectionEnd, + 6, + "Test complete: autocomplete selection should end at 6" + ); } - setTimeout(function() { + setTimeout(function () { // Unregister the factory so that we don't get in the way of other tests - componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple); + componentManager.unregisterFactory( + autoCompleteSimpleID, + autoCompleteSimple + ); SimpleTest.finish(); }, 0); } diff --git a/toolkit/content/tests/chrome/test_autocomplete4.xhtml b/toolkit/content/tests/chrome/test_autocomplete4.xhtml index 08c66ea03cb7d..9abf66ba19494 100644 --- a/toolkit/content/tests/chrome/test_autocomplete4.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete4.xhtml @@ -44,38 +44,31 @@ nsAutoCompleteSimpleResult.prototype = { defaultIndex: 0, errorDescription: null, matchCount: 0, - getValueAt: function() { return this._param; }, - getCommentAt: function() { return null; }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getFinalCompleteValueAt: function() { return this.getValueAt(); }, - getLabelAt: function() { return null; }, - removeValueAt: function() {} + getValueAt() { return this._param; }, + getCommentAt() { return null; }, + getStyleAt() { return null; }, + getImageAt() { return null; }, + getFinalCompleteValueAt() { return this.getValueAt(); }, + getLabelAt() { return null; }, + removeValueAt() {} }; // A basic autocomplete implementation that either returns one result or none var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple" var autoCompleteSimple = { - QueryInterface: function(iid) { - if (iid.equals(Ci.nsISupports) || - iid.equals(Ci.nsIFactory) || - iid.equals(Ci.nsIAutoCompleteSearch)) - return this; + QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]), - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, - - createInstance: function(outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - startSearch: function(aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { var result = new nsAutoCompleteSimpleResult(aString); aListener.onSearchResult(this, result); }, - stopSearch: function() {} + stopSearch() {} }; var componentManager = Components.manager @@ -221,7 +214,7 @@ function runCurrentTest() { function searchComplete() { var autocomplete = $("autocomplete"); - autocomplete.setAttribute("forcecomplete", currentTest.forceComplete ? true : false); + autocomplete.setAttribute("forcecomplete", currentTest.forceComplete); if (currentTest.completeFromMiddle) { if (!currentTest.forceComplete) { diff --git a/toolkit/content/tests/chrome/test_autocomplete5.xhtml b/toolkit/content/tests/chrome/test_autocomplete5.xhtml index 94ece8d45d704..72cb081f6664a 100644 --- a/toolkit/content/tests/chrome/test_autocomplete5.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete5.xhtml @@ -37,38 +37,31 @@ nsAutoCompleteSimpleResult.prototype = { defaultIndex: -1, errorDescription: null, matchCount: 0, - getValueAt: function() { return this._param; }, - getCommentAt: function() { return null; }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getFinalCompleteValueAt: function() { return this.getValueAt(); }, - getLabelAt: function() { return null; }, - removeValueAt: function() {} + getValueAt() { return this._param; }, + getCommentAt() { return null; }, + getStyleAt() { return null; }, + getImageAt() { return null; }, + getFinalCompleteValueAt() { return this.getValueAt(); }, + getLabelAt() { return null; }, + removeValueAt() {} }; // A basic autocomplete implementation that either returns one result or none var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple" var autoCompleteSimple = { - QueryInterface: function(iid) { - if (iid.equals(Ci.nsISupports) || - iid.equals(Ci.nsIFactory) || - iid.equals(Ci.nsIAutoCompleteSearch)) - return this; + QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]), - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, - - createInstance: function(outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - startSearch: function(aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { var result = new nsAutoCompleteSimpleResult(aString); aListener.onSearchResult(this, result); }, - stopSearch: function() {} + stopSearch() {} }; @@ -129,7 +122,7 @@ function checkSearchCompleted() { hasSearchBegun = false; synthesizeKey("KEY_Escape"); } else { - throw "checkSearchCompleted should only be called twice."; + throw new Error("checkSearchCompleted should only be called twice."); } } diff --git a/toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml b/toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml index f8c73b663753d..5155dee6874f7 100644 --- a/toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml @@ -42,38 +42,31 @@ nsAutoCompleteSimpleResult.prototype = { defaultIndex: -1, errorDescription: null, matchCount: 0, - getValueAt: function() { return resultText; }, - getCommentAt: function() { return this.getValueAt(); }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getFinalCompleteValueAt: function() { return this.getValueAt(); }, - getLabelAt: function() { return this.getValueAt(); }, - removeValueAt: function() {} + getValueAt() { return resultText; }, + getCommentAt() { return this.getValueAt(); }, + getStyleAt() { return null; }, + getImageAt() { return null; }, + getFinalCompleteValueAt() { return this.getValueAt(); }, + getLabelAt() { return this.getValueAt(); }, + removeValueAt() {} }; // A basic autocomplete implementation that returns the string contained in 'resultText'. var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple" var autoCompleteSimple = { - QueryInterface: function(iid) { - if (iid.equals(Ci.nsISupports) || - iid.equals(Ci.nsIFactory) || - iid.equals(Ci.nsIAutoCompleteSearch)) - return this; + QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]), - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, - - createInstance: function(outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - startSearch: function(aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { var result = new nsAutoCompleteSimpleResult(aString); aListener.onSearchResult(this, result); }, - stopSearch: function() {} + stopSearch() {} }; var componentManager = Components.manager diff --git a/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml b/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml index f2e8fed03d310..15ed2dfda9053 100644 --- a/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml +++ b/toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml @@ -43,12 +43,12 @@ autoCompleteSimpleResult.prototype = { defaultIndex: 0, errorDescription: null, matchCount: 0, - getValueAt: function() { return this._param; }, - getCommentAt: function() { return null; }, - getStyleAt: function() { return null; }, - getImageAt: function() { return null; }, - getLabelAt: function() { return null; }, - removeValueAt: function() {} + getValueAt() { return this._param; }, + getCommentAt() { return null; }, + getStyleAt() { return null; }, + getImageAt() { return null; }, + getLabelAt() { return null; }, + removeValueAt() {} }; var searchCounter = 0; @@ -64,23 +64,23 @@ let autoCompleteSimple = { "nsIFactory", "nsIAutoCompleteSearch" ]), - createInstance: function (outer, iid) { + createInstance(outer, iid) { return this.QueryInterface(iid); }, - registerFactory: function () { + registerFactory() { let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); registrar.registerFactory(this.classID, "Test Simple Autocomplete", this.contractID, this); }, - unregisterFactory: function () { + unregisterFactory() { let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); registrar.unregisterFactory(this.classID, this); }, - startSearch: function (aString, aParam, aResult, aListener) { + startSearch(aString, aParam, aResult, aListener) { let result = new autoCompleteSimpleResult(aString); if (this.searchAsync) { @@ -99,7 +99,7 @@ let autoCompleteSimple = { aListener.onSearchResult(this, result); } }, - stopSearch: function () { + stopSearch() { clearTimeout(this.pendingSearch); } }; diff --git a/toolkit/content/tests/chrome/test_bug1048178.xhtml b/toolkit/content/tests/chrome/test_bug1048178.xhtml index 6199bd27a67f4..302835e3b9f16 100644 --- a/toolkit/content/tests/chrome/test_bug1048178.xhtml +++ b/toolkit/content/tests/chrome/test_bug1048178.xhtml @@ -30,13 +30,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1048178 /** Test for Bug 1048178 **/ var scrollbarTester = { scrollbar: null, - startTest: function() { + startTest() { this.scrollbar = $("scroller"); this.setScrollToClick(false); this.testThumbDragging(); SimpleTest.finish(); }, - testThumbDragging: function() { + testThumbDragging() { var x = 400; // on the right half of the scroolbar var y = 5; @@ -55,22 +55,21 @@ var scrollbarTester = { ok(newPos2 < newPos, "Scrollbar thumb should follow the mouse when dragged."); }, - setScrollToClick: function(value) { - var prefService = Cc["@mozilla.org/preferences-service;1"] - .getService(Ci.nsIPrefService); + setScrollToClick(value) { + var prefService = SpecialPowers.Services.prefs.nsIPrefService; var uiBranch = prefService.getBranch("ui."); uiBranch.setIntPref("scrollToClick", value ? 1 : 0); }, - getPos: function() { + getPos() { return this.scrollbar.getAttribute("curpos"); }, - mousedown: function(x, y, button) { + mousedown(x, y, button) { synthesizeMouse(this.scrollbar, x, y, { type: "mousedown", 'button': button }); }, - mousemove: function(x, y, button) { + mousemove(x, y, button) { synthesizeMouse(this.scrollbar, x, y, { type: "mousemove", 'button': button }); }, - mouseup: function(x, y, button) { + mouseup(x, y, button) { synthesizeMouse(this.scrollbar, x, y, { type: "mouseup", 'button': button }); } } diff --git a/toolkit/content/tests/chrome/test_bug437844.xhtml b/toolkit/content/tests/chrome/test_bug437844.xhtml index 5d59757b63e9d..5bc06e098774b 100644 --- a/toolkit/content/tests/chrome/test_bug437844.xhtml +++ b/toolkit/content/tests/chrome/test_bug437844.xhtml @@ -42,8 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=348233 /** Test for Bug 437844 and Bug 348233 **/ SimpleTest.waitForExplicitFinish(); - let prefs = Cc["@mozilla.org/preferences-service;1"] - .getService(Ci.nsIPrefBranch); + let prefs = SpecialPowers.Services.prefs.nsIPrefBranch; prefs.setIntPref("intl.uidirection", 1); let rootDir = getRootDirectory(window.location.href); @@ -66,27 +65,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=348233 let frame = document.createXULElement("iframe"); frame.setAttribute("src", "about:plugins"); frame.addEventListener("load", function () { - frame.removeEventListener("load", arguments.callee, false); is(frame.contentDocument.dir, "rtl", "about:plugins should be RTL in RTL locales"); - let gDirSvc = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIDirectoryService). - QueryInterface(Ci.nsIProperties); - let tmpd = gDirSvc.get("ProfD", Ci.nsIFile); + // eslint-disable-next-line no-unused-vars + let tmpd = SpecialPowers.Services.dirsvc.get("ProfD", Ci.nsIFile); frame = document.createXULElement("iframe"); frame.setAttribute("src", "file://" + tmpd.path); // a file:// URI, bug 348233 frame.addEventListener("load", function () { - frame.removeEventListener("load", arguments.callee, false); - is(frame.contentDocument.body.dir, "rtl", "file:// listings should be RTL in RTL locales"); cleanupFunc(); prefs.clearUserPref("intl.uidirection"); SimpleTest.finish(); - }, false); + }); document.documentElement.appendChild(frame); - }, false); + }, { once: true }); document.documentElement.appendChild(frame); ]]> diff --git a/toolkit/content/tests/chrome/test_bug624329.xhtml b/toolkit/content/tests/chrome/test_bug624329.xhtml index 59b57a1607f1d..7000cbc66a56f 100644 --- a/toolkit/content/tests/chrome/test_bug624329.xhtml +++ b/toolkit/content/tests/chrome/test_bug624329.xhtml @@ -40,9 +40,8 @@ function openTestWindow() { function listenOnce(event, callback) { win.addEventListener(event, function listener() { - win.removeEventListener(event, listener, false); callback(); - }, false); + }, { once: true}); } function childFocused() { diff --git a/toolkit/content/tests/chrome/test_bug792324.xhtml b/toolkit/content/tests/chrome/test_bug792324.xhtml index febc93288e58c..ddedf5907b406 100644 --- a/toolkit/content/tests/chrome/test_bug792324.xhtml +++ b/toolkit/content/tests/chrome/test_bug792324.xhtml @@ -47,7 +47,6 @@ function clicked(event) { function checkAccessKeyOnPanel(panelid, buttonid, cb) { let panel = document.getElementById(panelid); panel.addEventListener("popupshown", function onpopupshown() { - panel.removeEventListener("popupshown", onpopupshown); panel.firstChild.focus(); after_click = function(event) { is(event.target.id, buttonid, "Accesskey was directed to the button '" + buttonid + "'"); diff --git a/toolkit/content/tests/chrome/test_contextmenu_list.xhtml b/toolkit/content/tests/chrome/test_contextmenu_list.xhtml index 798c94e343861..8fb5f112d0444 100644 --- a/toolkit/content/tests/chrome/test_contextmenu_list.xhtml +++ b/toolkit/content/tests/chrome/test_contextmenu_list.xhtml @@ -163,12 +163,12 @@ function nextTest() function isRoundedX(a, b, msg) { - is(Math.round(a + mozInnerScreenX), Math.round(b + mozInnerScreenX), msg); + is(Math.round(a + window.mozInnerScreenX), Math.round(b + window.mozInnerScreenX), msg); } function isRoundedY(a, b, msg) { - is(Math.round(a + mozInnerScreenY), Math.round(b + mozInnerScreenY), msg); + is(Math.round(a + window.mozInnerScreenY), Math.round(b + window.mozInnerScreenY), msg); } function checkContextMenu(event) @@ -189,6 +189,7 @@ function checkContextMenu(event) // context menu from mouse click switch (gTestId) { case -1: + // eslint-disable-next-line no-nested-ternary var expected = gSelectionStep == 2 ? 1 : (platformIsMac() ? 3 : 0); is($(gTestElement).selectedIndex, expected, "index after click " + gSelectionStep); break; @@ -251,14 +252,14 @@ function checkPopup() } else if (gTestId == 1) { // activating a context menu with the mouse from position (7, 4). - var elementrect = $(gTestElement).getBoundingClientRect(); + let elementrect = $(gTestElement).getBoundingClientRect(); isRoundedX(menurect.left, elementrect.left + 7 + contextMenuOffsetX, gTestElement + " mouse left"); isRoundedY(menurect.top, elementrect.top + 4 + contextMenuOffsetY, gTestElement + " mouse top"); } else { - var elementrect = $(gTestElement).getBoundingClientRect(); + let elementrect = $(gTestElement).getBoundingClientRect(); isRoundedX(menurect.left, elementrect.left + contextMenuOffsetX, gTestElement + " no selection keyboard left"); isRoundedY(menurect.top, elementrect.bottom + contextMenuOffsetY, diff --git a/toolkit/content/tests/chrome/test_cursorsnap.xhtml b/toolkit/content/tests/chrome/test_cursorsnap.xhtml index 0e9e3758a6121..f83938fbb7114 100644 --- a/toolkit/content/tests/chrome/test_cursorsnap.xhtml +++ b/toolkit/content/tests/chrome/test_cursorsnap.xhtml @@ -101,14 +101,12 @@ function runCurrentTest() default: SetPrefs(false); SimpleTest.finish(); - return; } } function SetPrefs(aSet) { - var prefSvc = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); + var prefSvc = SpecialPowers.Services.prefs.nsIPrefBranch; const kPrefName = "ui.cursor_snapping.always_enabled"; if (aSet) { prefSvc.setBoolPref(kPrefName, true); diff --git a/toolkit/content/tests/chrome/test_menu.xhtml b/toolkit/content/tests/chrome/test_menu.xhtml index 6ec9501a074f8..8ef5c4ca15abd 100644 --- a/toolkit/content/tests/chrome/test_menu.xhtml +++ b/toolkit/content/tests/chrome/test_menu.xhtml @@ -52,7 +52,7 @@ "nsIDOMXULContainerElement::parentContainer failed."); // nsIDOMXULContainerElement::appendItem(); - var item = menu.appendItem("item3"); + item = menu.appendItem("item3"); is(menu.getIndexOfItem(item), 2, "nsIDOMXULContainerElement::appendItem() failed."); diff --git a/toolkit/content/tests/chrome/test_menuitem_blink.xhtml b/toolkit/content/tests/chrome/test_menuitem_blink.xhtml index ccb8f8204c649..3340f0b7b604f 100644 --- a/toolkit/content/tests/chrome/test_menuitem_blink.xhtml +++ b/toolkit/content/tests/chrome/test_menuitem_blink.xhtml @@ -45,10 +45,8 @@ function test_crash(when, andThen) { var attrChanges = { "REMOVAL": 0, "ADDITION": 0 }; var storedEvent = null; menupopup.addEventListener("popupshown", function () { - menupopup.removeEventListener("popupshown", arguments.callee, false); menuitem.addEventListener("mouseup", function (e) { - menuitem.removeEventListener("mouseup", arguments.callee, true); - menuitem.addEventListener("DOMAttrModified", function (e) { + menuitem.addEventListener("DOMAttrModified", function onDOMAttrModified(e) { if (e.target != e.currentTarget) { return; } @@ -63,16 +61,15 @@ function test_crash(when, andThen) { menuitem.getBoundingClientRect(); ok(true, "Didn't crash on _moz-menuactive " + when.toLowerCase() + " during blinking") menuitem.hidden = false; - menuitem.removeEventListener("DOMAttrModified", arguments.callee, false); + menuitem.removeEventListener("DOMAttrModified", onDOMAttrModified); SimpleTest.executeSoon(function () { menupopup.hidePopup(); }); } } - }, false); - }, true); + }); + }, {once: true}); menupopup.addEventListener("popuphidden", function() { - menupopup.removeEventListener("popuphidden", arguments.callee, false); if (!when) { // Test whether we've blinked at all. var shouldBlink = navigator.platform.match(/Mac/); @@ -83,14 +80,14 @@ function test_crash(when, andThen) { is(attrChanges[storedEvent.ADDITION], expectedNumAddition, "blinking set attributes correctly"); } SimpleTest.executeSoon(andThen); - }, false); + }, {once: true}); synthesizeMouse(menuitem, 10, 5, { type : "mousemove" }); synthesizeMouse(menuitem, 10, 5, { type : "mousemove" }); synthesizeMouse(menuitem, 10, 5, { type : "mousedown" }); SimpleTest.executeSoon(function () { synthesizeMouse(menuitem, 10, 5, { type : "mouseup" }); }); - }, false); + }, {once: true}); document.getElementById("menulist").open = true; } diff --git a/toolkit/content/tests/chrome/test_menulist.xhtml b/toolkit/content/tests/chrome/test_menulist.xhtml index df9e8253065f8..4181d7f44f12e 100644 --- a/toolkit/content/tests/chrome/test_menulist.xhtml +++ b/toolkit/content/tests/chrome/test_menulist.xhtml @@ -153,7 +153,7 @@ function test_nsIDOMXULMenuListElement(element) function test_nsIDOMXULMenuListElement_properties(element, thirditem, properties) { let {attr, value} = properties.shift(); - let last = (properties.length == 0); + let last = !properties.length; let mutObserver = new MutationObserver(() => { is(element.getAttribute(attr), value, `${attr} modified`);