Bug 1207494 - Part 12: Remove use of expression closure from dom/tests/. r=jst
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Sep 2015 18:39:15 +0900
changeset 265753 7067747636ceb1fa293687ad9f80db3cd290d14c
parent 265752 9da37def06fd378393b8a7b7d4c8c60b6917a768
child 265754 2dbb20dbd99e2c35b8534172d80e57ebb5cd3735
push id66014
push userarai_a@mac.com
push dateFri, 02 Oct 2015 15:40:10 +0000
treeherdermozilla-inbound@7347b9d55c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs1207494
milestone44.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 1207494 - Part 12: Remove use of expression closure from dom/tests/. r=jst
dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
dom/tests/browser/browser_localStorage_privatestorageevent.js
dom/tests/mochitest/bugs/test_bug642026.html
dom/tests/mochitest/chrome/focus_frameset.html
dom/tests/mochitest/chrome/focus_window2.xul
dom/tests/mochitest/chrome/sizemode_attribute.xul
dom/tests/mochitest/chrome/window_focus.xul
dom/tests/mochitest/general/test_497898.html
dom/tests/mochitest/general/test_domWindowUtils_scrollbarSize.html
dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing_perwindowpb.html
dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
--- a/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
+++ b/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
@@ -61,17 +61,17 @@ function test() {
   }
 
   function testOnWindow(aOptions, aCallback) {
     whenNewWindowLoaded(aOptions, function(aWin) {
       windowsToClose.push(aWin);
       // execute should only be called when need, like when you are opening
       // web pages on the test. If calling executeSoon() is not necesary, then
       // call whenNewWindowLoaded() instead of testOnWindow() on your test.
-      executeSoon(function() aCallback(aWin));
+      executeSoon(() => aCallback(aWin));
     });
   };
 
    // this function is called after calling finish() on the test.
   registerCleanupFunction(function() {
     windowsToClose.forEach(function(aWin) {
       aWin.close();
     });
--- a/dom/tests/browser/browser_localStorage_privatestorageevent.js
+++ b/dom/tests/browser/browser_localStorage_privatestorageevent.js
@@ -8,17 +8,17 @@ function test() {
     win.addEventListener("load", function onLoad() {
       win.removeEventListener("load", onLoad, false);
       win.addEventListener("DOMContentLoaded", function onInnerLoad() {
         if (win.content.location.href != "about:blank") {
           win.gBrowser.loadURI("about:blank");
           return;
         }
         win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
-        executeSoon(function() callback(win));
+        executeSoon(() => callback(win));
       }, true);
       if (!options) {
         win.gBrowser.loadURI("about:blank");
       }
     }, false);
   }
 
   Services.prefs.setIntPref("browser.startup.page", 0);
--- a/dom/tests/mochitest/bugs/test_bug642026.html
+++ b/dom/tests/mochitest/bugs/test_bug642026.html
@@ -43,14 +43,14 @@ https://bugzilla.mozilla.org/show_bug.cg
 var expResult = ["NaN", "Infinity", "undefined", "eval", "parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "Object", "Function", "Array", "String", "Boolean", "Number", "Date", "Date", "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Math", "JSON"];
 
 var result = Object.getOwnPropertyNames(window);
 var result1 = {};
 for (var p in result) {
     result1[result[p]] = true;
 }
 
-ok(expResult.every(function(c) result1[c]), "all of the standard classes have been enumerated");
+ok(expResult.every(c => result1[c]), "all of the standard classes have been enumerated");
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/chrome/focus_frameset.html
+++ b/dom/tests/mochitest/chrome/focus_frameset.html
@@ -1,15 +1,15 @@
 <html id="outer">
 
 <script type="application/javascript"
         src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 <script>
 if (opener)
-  SimpleTest.waitForFocus(function () opener.framesetWindowLoaded(window));
+  SimpleTest.waitForFocus(() => opener.framesetWindowLoaded(window));
 // Don't try to call finish() in this frame, since it will get upset that we
 // ran no tests.
 SimpleTest.waitForExplicitFinish();
 </script>
 
 <frameset rows="30%, 70%">
   <frame src="data:text/html,&lt;html id='f1' &gt;&lt;body id='framebody1'&gt;&lt;input id='f2'&gt;&lt;body&gt;&lt;/html&gt;">
   <frameset cols="30%, 33%, 34%">
--- a/dom/tests/mochitest/chrome/focus_window2.xul
+++ b/dom/tests/mochitest/chrome/focus_window2.xul
@@ -8,17 +8,17 @@
         src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
 <script>
 <![CDATA[
 
 function focused()
 {
   if (window.arguments)
-    setTimeout(function () window.arguments[0](window, window.arguments[1]), 0);
+    setTimeout(() => window.arguments[0](window, window.arguments[1]), 0);
 }
 
 SimpleTest.waitForFocus(focused);
 
 ]]>
 </script>
 
 <button id="other" label="OK"/>
--- a/dom/tests/mochitest/chrome/sizemode_attribute.xul
+++ b/dom/tests/mochitest/chrome/sizemode_attribute.xul
@@ -11,42 +11,42 @@
 
 <script type="text/javascript;version=1.8">
 let tests = [
   function test1() {
     checkAndContinue("normal");
   },
 
   function test2() {
-    listen("fullscreen", function() checkAndContinue("fullscreen"));
+    listen("fullscreen", () => checkAndContinue("fullscreen"));
     window.fullScreen = true;
   },
 
   function test3() {
-    listen("fullscreen", function() checkAndContinue("normal"));
+    listen("fullscreen", () => checkAndContinue("normal"));
     window.fullScreen = false;
   },
 
   function test4() {
-    listen("resize", function() checkAndContinue("maximized"));
+    listen("resize", () => checkAndContinue("maximized"));
     window.maximize();
   },
 
   function test5() {
-    listen("fullscreen", function() checkAndContinue("fullscreen"));
+    listen("fullscreen", () => checkAndContinue("fullscreen"));
     window.fullScreen = true;
   },
 
   function test6() {
-    listen("fullscreen", function() checkAndContinue("maximized"));
+    listen("fullscreen", () => checkAndContinue("maximized"));
     window.fullScreen = false;
   },
 
   function test7() {
-    listen("resize", function() checkAndContinue("normal"));
+    listen("resize", () => checkAndContinue("normal"));
     window.restore();
   },
 
   function test8() {
     window.opener.wrappedJSObject.done();
   }
 ];
 
--- a/dom/tests/mochitest/chrome/window_focus.xul
+++ b/dom/tests/mochitest/chrome/window_focus.xul
@@ -310,35 +310,35 @@ function mouseOnElement(element, expecte
 {
   var expectedWindow = (element.ownerDocument.defaultView == gChildWindow) ? gChildWindow : window;
   // on Mac, form elements are not focused when clicking, except for lists and textboxes.
   var noFocusOnMouse = !mouseWillTriggerFocus(element)
 
   if (noFocusOnMouse) {
     // no focus so the last focus method will be 0
     gLastFocusMethod = 0;
-    expectFocusShift(function () synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
                      expectedWindow, null, true, testid);
     gLastFocusMethod = fm.FLAG_BYMOUSE;
   }
   else {
-    expectFocusShift(function () synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
                      element.ownerDocument.defaultView,
                      expectedElement, focusChanged, testid);
   }
 }
 
 function done()
 {
   var opener = window.opener;
   window.close();
   opener.wrappedJSObject.SimpleTest.finish();
 }
 
-var pressTab = function () synthesizeKey("VK_TAB", { });
+var pressTab = () => synthesizeKey("VK_TAB", { });
 
 function setFocusTo(id, fwindow)
 {
   gLastFocus = getById(id);
   gLastFocusWindow = fwindow;
   if (gLastFocus)
     gLastFocus.focus();
   else
@@ -395,53 +395,53 @@ function startTest()
   if (gPartialTabbing) {
     var partialTabList = ["t3", "t5", "t9", "t10", "t11", "t12", "t13", "t14", "t15",
                           "t16", "t19", "t20", "t21", "t22", "t26", "t27", "t28", "t29", "t30"];
     for (var idx = 0; idx < partialTabList.length; idx++) {
       expectFocusShift(pressTab, null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
     }
     setFocusTo("last", window);
     expectFocusShift(pressTab, null, getById(partialTabList[0]), true, "partial tab key wrap to start");
-    expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                      null, getById("last"), true, "partial shift tab key wrap to end");
     for (var idx = partialTabList.length - 1; idx >= 0; idx--) {
-      expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+      expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                        null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
     }
   }
   else {
     // TAB key
     for (var idx = 1; idx <= kTabbableSteps; idx++) {
       expectFocusShift(pressTab, null, getById("t" + idx), true, "tab key t" + idx);
     }
 
     // wrapping around at end with TAB key
     setFocusTo("last", window);
     expectFocusShift(pressTab, null, getById("t1"), true, "tab key wrap to start");
-    expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                      null, getById("last"), true, "shift tab key wrap to end");
 
     // Shift+TAB key
     setFocusTo("o5", window);
     for (idx = kTabbableSteps; idx > 0; idx--) {
-      expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+      expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                        null, getById("t" + idx), true, "shift tab key t" + idx);
     }
   }
 
   var t19 = getById("t19");
   is(t19.selectionStart, 0, "input focused from tab key selectionStart");
   is(t19.selectionEnd, 5, "input focused from tab key selectionEnd");
   t19.setSelectionRange(0, 0);
 
   gLastFocusMethod = 0;
   var selectFired = false;
   function selectListener() { selectFired = true; }
   t19.addEventListener("select", selectListener, false); 
-  expectFocusShift(function() t19.select(),
+  expectFocusShift(() => t19.select(),
                    null, getById("t" + 19), true, "input.select()");
   t19.removeEventListener("select", selectListener, false); 
   ok(selectFired, "select event fires for input");
 
   // mouse clicking
   gLastFocusMethod = fm.FLAG_BYMOUSE;
   for (idx = kTabbableSteps; idx >= 1; idx--) {
     // skip the document root and the overflow element
@@ -482,64 +482,64 @@ function startTest()
     gLastFocusMethod = idx % 2 ? 0 : fm.FLAG_BYMOUSE;
 
     mouseOnElement(element, idx % 2 ? null: element, true, "mouse on unfocusable element n" + idx);
   }
 
   if (idx == kOverflowElementIndex) {
     gLastFocusMethod = fm.FLAG_BYMOUSE;
     var element = getById("t" + idx);
-    expectFocusShift(function () synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
                      window, null, true, "mouse on scrollable element");
   }
 
   // focus() method
   gLastFocusMethod = 0;
   for (idx = kTabbableSteps; idx >= 1; idx--) {
     if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
       continue;
-    expectFocusShift(function () getById("t" + idx).focus(),
+    expectFocusShift(() => getById("t" + idx).focus(),
                      null, getById("t" + idx), true, "focus method on element t" + idx);
   }
 
   $("t1").focus();
   ok(gEvents === "", "focusing element that is already focused");
 
   $("t2").blur();
   $("t7").blur();
   ok(gEvents === "", "blurring element that is not focused");
   is(document.activeElement, $("t1"), "old element still focused after blur() on another element");
 
   // focus() method on elements that are not tabbable 
   for (idx = 1; idx <= kFocusSteps; idx++) {
     var expected = getById("o" + (idx % 2 ? idx : idx - 1));
-    expectFocusShift(function () getById("o" + idx).focus(),
+    expectFocusShift(() => getById("o" + idx).focus(),
                      expected.ownerDocument.defaultView,
                      expected, idx % 2, "focus method on non-tabbable element o" + idx);
   }
 
   // focus() method on elements that are not tabbable and have user-focus: none
   // or are not focusable for other reasons (for instance, being disabled)
   for (idx = 1; idx <= kNoFocusSteps; idx++) {
     var expected = getById("o" + (idx % 2 ? idx : idx - 1));
-    expectFocusShift(function () getById("o" + idx).focus(),
+    expectFocusShift(() => getById("o" + idx).focus(),
                      expected.ownerDocument.defaultView,
                      expected, idx % 2, "focus method on unfocusable element n" + idx);
   }
 
   // the focus() method on the legend element should focus the legend if it is
   // focusable, or the first element after the legend if it is not focusable.
   if (!gPartialTabbing) {
     gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
     var legend = getById("legend");
-    expectFocusShift(function () legend.focus(),
+    expectFocusShift(() => legend.focus(),
                      null, getById("t28"), true, "focus method on unfocusable legend");
     gLastFocusMethod = 0;
     legend.tabIndex = "0";
-    expectFocusShift(function () legend.focus(),
+    expectFocusShift(() => legend.focus(),
                      null, getById("legend"), true, "focus method on focusable legend");
     legend.tabIndex = "-1";
   }
 
   var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
                          { ctrlKey : true } : { altKey : true };
 
   // test accesskeys
@@ -555,54 +555,54 @@ function startTest()
     // and on Mac, the alt key must be pressed for content area access keys
     var isContent = (getById(keys[k]).ownerDocument.defaultView == gChildWindow);
     if (navigator.platform.indexOf("Mac") == -1) {
       accessKeyDetails.shiftKey = isContent;
     } else {
       accessKeyDetails.altKey = isContent;
     }
 
-    expectFocusShift(function () synthesizeKey(key, accessKeyDetails),
+    expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
                      null, getById(keys[k]), true, "accesskey " + key);
   }
 
   // clicking on the labels
   gLastFocusMethod = fm.FLAG_BYMOVEFOCUS | fm.FLAG_BYMOUSE;
   mouseOnElement(getById("ad"), getById("t29"), true, "mouse on html label with content inside");
   mouseOnElement(getById("ag"), getById("n6"), true, "mouse on html label with for attribute");
   gLastFocusMethod = 0;
-  expectFocusShift(function () synthesizeMouse(getById("aj"), 2, 2, { }),
+  expectFocusShift(() => synthesizeMouse(getById("aj"), 2, 2, { }),
                    null, getById("o9"), true, "mouse on xul label with content inside");
-  expectFocusShift(function () synthesizeMouse(getById("ak"), 2, 2, { }),
+  expectFocusShift(() => synthesizeMouse(getById("ak"), 2, 2, { }),
                    null, getById("n4"), true, "mouse on xul label with control attribute");
 
   // test accesskeys that shouldn't work
   k = "o".charCodeAt(0);
   while (k++ < "v".charCodeAt(0)) {
     var key = String.fromCharCode(k);
-    expectFocusShift(function () synthesizeKey(key, accessKeyDetails),
+    expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
                      window, getById("n4"), false, "non accesskey " + key);
   }
   gLastFocusMethod = -1;
 
   // should focus the for element when using the focus method on a label as well
-  expectFocusShift(function () getById("ad").focus(),
+  expectFocusShift(() => getById("ad").focus(),
                    null, getById("t29"), true, "mouse on html label using focus method");
 
   // make sure that the text is selected when clicking a label associated with an input
   getById("ag").htmlFor = "t19";
-  expectFocusShift(function () synthesizeMouse(getById("ag"), 2, 2, { }, gChildWindow),
+  expectFocusShift(() => synthesizeMouse(getById("ag"), 2, 2, { }, gChildWindow),
                    null, getById("t19"), true, "mouse on html label with for attribute changed");
   is(t19.selectionStart, 0, "input focused from label, selectionStart");
   is(t19.selectionEnd, 5, "input focused from label, selectionEnd");
 
   // switch to another panel in a tabbox and ensure that tabbing moves between
   // elements on the new panel.
   $("tabbox").selectedIndex = 1;
-  expectFocusShift(function () getById("t" + kBeforeTabboxIndex).focus(),
+  expectFocusShift(() => getById("t" + kBeforeTabboxIndex).focus(),
                    null, getById("t" + kBeforeTabboxIndex), true, "focus method on element before tabbox");
 
   if (!gPartialTabbing) {
     expectFocusShift(pressTab, null, getById("tab2"), true, "focus method on tab");
     expectFocusShift(pressTab, null, getById("htab1"), true, "tab key switch tabpanel 1");
     expectFocusShift(pressTab, null, getById("htab2"), true, "tab key switch tabpanel 2");
     expectFocusShift(pressTab, null, getById("t" + (kBeforeTabboxIndex + 4)), true, "tab key switch tabpanel 3");
   }
@@ -610,95 +610,95 @@ function startTest()
 
   // ---- the following checks when the focus changes during a blur or focus event ----
 
   var o5 = $("o5");
   var o9 = $("o9");
   var t3 = $("t3");
   var t17 = getById("t17");
   var t19 = getById("t19");
-  var shiftFocusParentDocument = function() o9.focus();
-  var shiftFocusChildDocument = function() t17.focus();
+  var shiftFocusParentDocument = () => o9.focus();
+  var shiftFocusChildDocument = () => t17.focus();
 
   var trapBlur = function (element, eventListener, blurFunction)
   {
     element.focus();
     gEvents = "";
     element.addEventListener("blur", eventListener, false);
     blurFunction();
     element.removeEventListener("blur", eventListener, false);
   }
 
   var functions = [
-    function(element) element.focus(),
-    function(element) synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView)
+    element => element.focus(),
+    element => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView)
   ];
 
   // first, check cases where the focus is adjusted during the blur event. Iterate twice,
   // once with the focus method and then focusing by mouse clicking
   for  (var l = 0; l < 2; l++) {
     var adjustFocus = functions[l];
     var mod = (l == 1) ? " with mouse" : "";
 
     // an attempt is made to switch the focus from one element (o5) to another
     // element (t3) within the same document, yet the focus is shifted to a
     // third element (o9) in the same document during the blur event for the
     // first element.
-    trapBlur(o5, shiftFocusParentDocument, function () adjustFocus(t3));
+    trapBlur(o5, shiftFocusParentDocument, () => adjustFocus(t3));
     compareEvents("commandupdate: cu blur: o5 commandupdate: cu focus: o9",
                   window, o9, "change focus to sibling during element blur, attempted sibling" + mod);
 
     // similar, but the third element (t17) is in a child document
-    trapBlur(o9, shiftFocusChildDocument, function () adjustFocus(t3));
+    trapBlur(o9, shiftFocusChildDocument, () => adjustFocus(t3));
     compareEvents("commandupdate: cu blur: o9 blur: outer-document blur: outer-window " +
                   "focus: child-document focus: child-window commandupdate: cu focus: t17",
                   gChildWindow, t17, "change focus to child document during element blur, attempted sibling" + mod);
 
     // similar, but an attempt to switch focus within the same document, but the
     // third element (t17) is in a parent document
-    trapBlur(t17, shiftFocusParentDocument, function () adjustFocus(t19));
+    trapBlur(t17, shiftFocusParentDocument, () => adjustFocus(t19));
     compareEvents("commandupdate: cu blur: t17 blur: child-document blur: child-window " +
                   "focus: outer-document focus: outer-window commandupdate: cu focus: o9",
                   window, o9, "change focus to parent document during element blur, attempted sibling" + mod);
 
     // similar, but blur is called instead of switching focus
-    trapBlur(t3, shiftFocusParentDocument, function () t3.blur());
+    trapBlur(t3, shiftFocusParentDocument, () => t3.blur());
     compareEvents("commandupdate: cu blur: t3 commandupdate: cu focus: o9",
                   window, o9, "change focus to same document during clear focus" + mod);
 
     // check when an element in the same document is focused during the
     // element's blur event, but an attempt was made to focus an element in the
     // child document. In this case, the focus in the parent document should be
     // what was set during the blur event, but the actual focus should still
     // move to the child document.
-    trapBlur(t3, shiftFocusParentDocument, function () adjustFocus(t17));
+    trapBlur(t3, shiftFocusParentDocument, () => adjustFocus(t17));
     compareEvents("commandupdate: cu blur: t3 commandupdate: cu focus: o9 " +
                   "blur: outer-document blur: outer-window " +
                   "focus: child-document focus: child-window commandupdate: cu focus: t17",
                   gChildWindow, t17, "change focus to sibling during element blur, attempted child" + mod);
     is(fm.getFocusedElementForWindow(window, false, {}), $("childframe"),
        "change focus to sibling during element blur, attempted child, focused in parent" + mod);
 
     // similar, but with a parent
-    trapBlur(t19, shiftFocusChildDocument, function () adjustFocus(t3));
+    trapBlur(t19, shiftFocusChildDocument, () => adjustFocus(t3));
     compareEvents("commandupdate: cu blur: t19 commandupdate: cu focus: t17 " +
                   "blur: child-document blur: child-window " +
                   "focus: outer-document focus: outer-window commandupdate: cu focus: t3",
                   window, t3, "change focus to sibling during element blur, attempted parent" + mod);
     is(fm.getFocusedElementForWindow(gChildWindow, false, {}), t17,
        "change focus to sibling during element blur, attempted child, focused in child" + mod);
 
     // similar, with a child, but the blur event focuses a child element also
-    trapBlur(t3, shiftFocusChildDocument, function () adjustFocus(t19));
+    trapBlur(t3, shiftFocusChildDocument, () => adjustFocus(t19));
     compareEvents("commandupdate: cu blur: t3 blur: outer-document blur: outer-window " +
                   "focus: child-document focus: child-window commandupdate: cu focus: t17",
                   gChildWindow, t17, "change focus to child during element blur, attempted child" + mod);
 
     // similar, with a parent, where the blur event focuses a parent element also
-    trapBlur(t17, shiftFocusParentDocument, function () adjustFocus(t3));
+    trapBlur(t17, shiftFocusParentDocument, () => adjustFocus(t3));
     compareEvents("commandupdate: cu blur: t17 blur: child-document blur: child-window " +
                   "focus: outer-document focus: outer-window commandupdate: cu focus: o9",
                   window, o9, "change focus to parent during element blur, attempted parent" + mod);
   }
 
   var trapFocus = function (element, eventListener)
   {
     element.addEventListener("focus", eventListener, false);
@@ -728,17 +728,17 @@ function startTest()
   trapFocus(t19, shiftFocusParentDocument);
   compareEvents("commandupdate: cu blur: t17 " +
                 "commandupdate: cu focus: t19 commandupdate: cu blur: t19 " +
                 "blur: child-document blur: child-window " +
                 "focus: outer-document focus: outer-window commandupdate: cu focus: o9",
                 window, o9, "change focus to parent document during element focus");
 
   // clear the focus during the focus event
-  trapFocus(t3, function () fm.clearFocus(window));
+  trapFocus(t3, () => fm.clearFocus(window));
   compareEvents("commandupdate: cu blur: o9 commandupdate: cu focus: t3 commandupdate: cu blur: t3",
                 window, null, "clear focus during focus event");
 
   if (!gPartialTabbing)
     doCommandDispatcherTests();
 
   testMoveFocus();
 
@@ -762,26 +762,26 @@ function startTest()
   // just make sure that this doesn't crash
   fm.moveCaretToFocus(null);
 
   // ---- tests for the FLAG_NOSWITCHFRAME flag
   getById("o5").focus();
   gLastFocusMethod = 0;
   gEvents = "";
   // focus is being shifted in a child, so the focus should not change
-  expectFocusShift(function () fm.setFocus(getById("t20"), fm.FLAG_NOSWITCHFRAME),
+  expectFocusShift(() => fm.setFocus(getById("t20"), fm.FLAG_NOSWITCHFRAME),
                    window, getById("o5"), false, "no switch frame focus to child");
   setFocusTo("t20", gChildWindow);
 
   // here, however, focus is being shifted in a parent, which will have to blur
   // the child, so the focus will always change
-  expectFocusShift(function () fm.setFocus(getById("o5"), fm.FLAG_NOSWITCHFRAME),
+  expectFocusShift(() => fm.setFocus(getById("o5"), fm.FLAG_NOSWITCHFRAME),
                    window, getById("o5"), true, "no switch frame focus to parent");
 
-  expectFocusShift(function () fm.setFocus(getById("t1"), fm.FLAG_NOSWITCHFRAME),
+  expectFocusShift(() => fm.setFocus(getById("t1"), fm.FLAG_NOSWITCHFRAME),
                    window, getById("t1"), true, "no switch frame focus to same window");
 
   // ---- tests for focus and scrolling into view ----
   var inscroll = getById("inscroll");
   inscroll.tabIndex = 0;
   is(inscroll.parentNode.scrollTop, 0, "scroll position before focus");
   inscroll.focus();
   ok(inscroll.parentNode.scrollTop > 5, "scroll position after focus");
@@ -799,68 +799,68 @@ function startTest()
 
   var textbox1 = document.createElement("textbox");
   $("innerbox").appendChild(textbox1);
 
   var textbox2 = document.createElement("textbox");
   $("innerbox").appendChild(textbox2);
 
   gLastFocusMethod = 0;
-  expectFocusShift(function () textbox2.focus(),
+  expectFocusShift(() => textbox2.focus(),
                    null, textbox2.inputField, true, "focus on textbox");
   gLastFocusMethod = fm.FLAG_BYKEY;
-  expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+  expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                    null, textbox1.inputField, true, "shift+tab on textbox");
 
   textbox1.tabIndex = 2;
   textbox2.tabIndex = 2;
   gLastFocusMethod = 0;
-  expectFocusShift(function () textbox2.focus(),
+  expectFocusShift(() => textbox2.focus(),
                    null, textbox2.inputField, true, "focus on textbox with tabindex set");
   gLastFocusMethod = fm.FLAG_BYKEY;
-  expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+  expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                    null, textbox1.inputField, true, "shift+tab on textbox with tabindex set");
 
   // ---- test for bug 618907 which ensures that canceling the mousedown event still focuses the
   //      right frame
 
   var childContentFrame = document.getElementById("ifa")
   childContentFrame.style.MozUserFocus = "";
 
   var frab = childContentFrame.contentDocument.getElementById("fra-b");
-  var mouseDownListener = function(event) event.preventDefault();
+  var mouseDownListener = event => event.preventDefault();
   frab.addEventListener("mousedown", mouseDownListener, false);
 
   var childElementToFocus = childContentFrame.contentDocument.getElementById("fra");
   gLastFocus = childElementToFocus;
   gLastFocusWindow = childContentFrame.contentWindow;
   gLastFocus.focus();
   gEvents = "";
 
   setFocusTo("t1", window);
 
   gLastFocusMethod = -1;
-  expectFocusShift(function () synthesizeMouse(frab, 5, 5, { }, childContentFrame.contentWindow),
+  expectFocusShift(() => synthesizeMouse(frab, 5, 5, { }, childContentFrame.contentWindow),
                    null, childElementToFocus, true,
                    "mousedown event canceled - chrome to content");
 
   frab.removeEventListener("mousedown", mouseDownListener, false);
 
   var t5 = getById("t5");
   t5.addEventListener("mousedown", mouseDownListener, false);
   synthesizeMouse(t5, 10, 10, { })
   t5.removeEventListener("mousedown", mouseDownListener, false);
   is(fm.focusedElement, childElementToFocus,
      "mousedown event cancelled - content to chrome - element");
   is(fm.focusedWindow, childContentFrame.contentWindow, "mousedown event cancelled - content to chrome - window");
 
   // ---- test to check that refocusing an element during a blur event doesn't succeed
 
   var t1 = getById("t1");
-  t1.addEventListener("blur", function() t1.focus(), true);
+  t1.addEventListener("blur", () => t1.focus(), true);
   t1.focus();
   var t3 = getById("t3");
   synthesizeMouse(t3, 2, 2, { });
   is(fm.focusedElement, t3, "focus during blur");
 
   setFocusTo("t9", window);
   gLastFocusMethod = -1;
   window.openDialog("focus_window2.xul", "_blank", "chrome", otherWindowFocused);
@@ -869,33 +869,33 @@ function startTest()
 function doCommandDispatcherTests()
 {
   var t19 = getById("t19");
   t19.focus();
   gLastFocusWindow = gChildWindow;
   gLastFocus = t19;
   gEvents = "";
 
-  expectFocusShift(function () document.commandDispatcher.focusedElement = getById("o9"),
+  expectFocusShift(() => document.commandDispatcher.focusedElement = getById("o9"),
                    null, getById("o9"), true, "command dispatcher set focusedElement");
-  expectFocusShift(function () document.commandDispatcher.advanceFocus(),
+  expectFocusShift(() => document.commandDispatcher.advanceFocus(),
                    null, getById("o13"), true, "command dispatcher advanceFocus");
-  expectFocusShift(function () document.commandDispatcher.rewindFocus(),
+  expectFocusShift(() => document.commandDispatcher.rewindFocus(),
                    null, getById("o9"), true, "command dispatcher rewindFocus");
-  expectFocusShift(function () document.commandDispatcher.focusedElement = null,
+  expectFocusShift(() => document.commandDispatcher.focusedElement = null,
                    null, null, true, "command dispatcher set focusedElement to null");
-  expectFocusShift(function () document.commandDispatcher.focusedWindow = gChildWindow,
+  expectFocusShift(() => document.commandDispatcher.focusedWindow = gChildWindow,
                    null, getById("t19"), true, "command dispatcher set focusedElement to null");
-  expectFocusShift(function () document.commandDispatcher.focusedElement = null,
+  expectFocusShift(() => document.commandDispatcher.focusedElement = null,
                    gChildWindow, null, true, "command dispatcher set focusedElement to null in child");
-  expectFocusShift(function () document.commandDispatcher.advanceFocusIntoSubtree(getById("t19")),
+  expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(getById("t19")),
                    null, getById("t20"), true, "command dispatcher advanceFocusIntoSubtree child");
-  expectFocusShift(function () document.commandDispatcher.advanceFocusIntoSubtree(null),
+  expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(null),
                    null, getById("t21"), true, "command dispatcher advanceFocusIntoSubtree null child");
-  expectFocusShift(function () document.commandDispatcher.advanceFocusIntoSubtree(getById("o9").parentNode),
+  expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(getById("o9").parentNode),
                    null, getById("o9"), true, "command dispatcher advanceFocusIntoSubtree parent");
 }
 
 function doRemoveTests()
 {
   // next, some tests which remove elements
   var t19 = getById("t19");
   t19.focus();
@@ -920,72 +920,72 @@ function doRemoveTests()
 function testMoveFocus()
 {
   setFocusTo("t6", window);
 
   // moving focus while an element is already focused
   var newFocus;
   gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
   var expectedFirst = getById(gPartialTabbing ? "t3" : "t1");
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
                    window, expectedFirst, true, "moveFocus to first null window null content");
   is(newFocus, fm.focusedElement, "moveFocus to first null window null content return value");
 
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
                    window, getById("last"), true, "moveFocus to last null window null content");
   is(newFocus, fm.focusedElement, "moveFocus to last null window null content return value");
 
   gLastFocusMethod = 0;
   newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_ROOT, 0);
   is(newFocus, null, "moveFocus to root null window null content return value");
   is(fm.focusedWindow, window, "moveFocus to root null window null content focusedWindow");
   is(fm.focusedElement, null, "moveFocus to root null window null content focusedElement");
 
   // moving focus while no element is focused
   fm.clearFocus(window);
   gEvents = "";
   gLastFocus = null;
   gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
                    window, expectedFirst, true, "moveFocus to first null window null content no focus");
   is(newFocus, fm.focusedElement, "moveFocus to first null window null content no focus return value");
   fm.clearFocus(window);
   gEvents = "";
   gLastFocus = null;
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
                    window, getById("last"), true, "moveFocus to last null window null content no focus");
   is(newFocus, fm.focusedElement, "moveFocus to last null window null content no focus return value");
   fm.clearFocus(window);
   gEvents = "";
   gLastFocusMethod = 0;
   newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_ROOT, 0);
   is(newFocus, null, "moveFocus to root null window null content no focus return value");
   is(fm.focusedWindow, window, "moveFocus to root null window null content no focus focusedWindow");
   is(fm.focusedElement, null, "moveFocus to root null window null content no focus focusedElement");
 
   // moving focus from a specified element
   setFocusTo("t6", window);
   gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
-  expectFocusShift(function () newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_FIRST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_FIRST, 0),
                    window, getById("t3"), true, "moveFocus to first null window with content");
 // XXXndeakin P3 this doesn't work
-//  expectFocusShift(function () newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_LAST, 0),
+//  expectFocusShift(() => newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_LAST, 0),
 //                   window, getById("o3"), true, "moveFocus to last null window with content");
 
   // move focus to first in child window
-  expectFocusShift(function () newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_FIRST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_FIRST, 0),
                    gChildWindow, getById("t" + (kChildDocumentRootIndex + 1)), true,
                    "moveFocus to first child window null content");
   is(newFocus, getById("t" + (kChildDocumentRootIndex + 1)),
      "moveFocus to first child window null content return value");
 
   // move focus to last in child window
   setFocusTo("t6", window);
   var expectedLast = getById(gPartialTabbing ? "t30" : "t" + (kBeforeTabboxIndex - 1));
-  expectFocusShift(function () newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_LAST, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_LAST, 0),
                    gChildWindow, expectedLast, true,
                    "moveFocus to last child window null content");
   is(newFocus, getById(expectedLast),
      "moveFocus to last child window null content return value");
 
   // move focus to root in child window
   setFocusTo("t6", window);
   var childroot = getById("t" + kChildDocumentRootIndex);
@@ -1044,47 +1044,47 @@ function testMoveFocus()
   if (!gPartialTabbing) {
     getById("t24").blur();
     gEvents = "";
     gLastFocus = null;
     gLastFocusWindow = gChildWindow;
     gLastFocusMethod = fm.FLAG_BYKEY;
 
     selection.selectAllChildren(getById("hiddenspan"));
-    expectFocusShift(function () synthesizeKey("VK_TAB", { }),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { }),
                      gChildWindow, getById("t26"), true, "tab with selection on hidden content");
 
     setFocusTo($("o15"), window);
     $("o15").hidden = true;
     document.documentElement.getBoundingClientRect(); // flush after hiding
-    expectFocusShift(function () synthesizeKey("VK_TAB", { }),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { }),
                      window, $("o17"), true, "tab with focus on hidden content");
 
     $("o17").hidden = true;
     document.documentElement.getBoundingClientRect();
-    expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
                      window, $("o13"), true, "shift+tab with focus on hidden content");
   }
 
   // cases with selection in an <input>
 
   var t19 = getById("t19");
   t19.setSelectionRange(0, 0);
   setFocusTo("t18", gChildWindow);
 
   gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, 0),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, 0),
                    gChildWindow, t19, true, "moveFocus to next textbox");
   is(t19.selectionStart, 0, "input focused after moveFocus selectionStart");
   is(t19.selectionEnd, 5, "input focused after moveFocus selectionEnd");
 
   t19.setSelectionRange(0, 0);
   setFocusTo("t18", gChildWindow);
   gLastFocusMethod = fm.FLAG_BYKEY;
-  expectFocusShift(function () newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, fm.FLAG_BYKEY),
+  expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, fm.FLAG_BYKEY),
                    gChildWindow, t19, true, "moveFocus to next textbox by key");
   is(t19.selectionStart, 0, "input focused after moveFocus by key selectionStart");
   is(t19.selectionEnd, 5, "input focused after moveFocus by key selectionEnd");
 }
 
 function otherWindowFocused(otherWindow)
 {
   var expectedElement = getById("t9");
@@ -1182,79 +1182,79 @@ function framesetWindowLoaded(framesetWi
   is(fm.activeWindow, getTopWindow(framesetWindow), "frameset window active");
   gOldExpectedWindow = getTopWindow(framesetWindow);
 
   gMoveToFocusFrame = true;
   for (var idx = 1; idx <= 8; idx++) {
     gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
     if (idx % 2)
       initEvents(gNewExpectedWindow);
-    expectFocusShift(function () synthesizeKey("VK_TAB", { }, framesetWindow),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
                      gNewExpectedWindow, getById("f" + idx), true, "frameset tab key f" + idx);
     gMoveToFocusFrame = false;
     gOldExpectedWindow = gNewExpectedWindow;
   }
 
   gNewExpectedWindow = framesetWindow.frames[0];
-  expectFocusShift(function () synthesizeKey("VK_TAB", { }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
                    gNewExpectedWindow, getById("f1"), true, "frameset tab key wrap to start");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[3];
-  expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f8"), true, "frameset shift tab key wrap to end");
 
   for (idx = 7; idx >= 1; idx--) {
     gOldExpectedWindow = gNewExpectedWindow;
     gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
-    expectFocusShift(function () synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
+    expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
                      gNewExpectedWindow, getById("f" + idx), true, "frameset shift tab key f" + idx);
   }
 
   // document shifting
   // XXXndeakin P3 ctrl+tab doesn't seem to be testable currently for some reason
   gNewExpectedWindow = framesetWindow.frames[1];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f3"), true, "switch document forward with f6");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[2];
-  expectFocusShift(function () synthesizeKey("VK_F6", { }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { }, framesetWindow),
                    gNewExpectedWindow, getById("f5"), true, "switch document forward with ctrl+tab");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[3];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f7"), true, "switch document forward with ctrl+f6");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[0];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f1"), true, "switch document forward and wrap");
 
 // going backwards by document and wrapping doesn't currently work, but didn't work
 // before the focus reworking either
 
 /*
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[3];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f7"), true, "switch document backward and wrap");
  */
 
   fm.moveFocus(framesetWindow.frames[3], null, fm.MOVEFOCUS_ROOT, 0);
   gEvents = "";
 
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[2];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f5"), true, "switch document backward with f6");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[1];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f3"), true, "switch document backward with ctrl+tab");
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = framesetWindow.frames[0];
-  expectFocusShift(function () synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
+  expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
                    gNewExpectedWindow, getById("f1"), true, "switch document backward with ctrl+f6");
 
   // skip the window switching tests for now on Linux, as raising and lowering
   // a window is asynchronous there
   if (navigator.platform.indexOf("Linux") == -1) {
     window.openDialog("focus_window2.xul", "_blank", "chrome", switchWindowTest, framesetWindow);
   }
   else {
@@ -1277,23 +1277,23 @@ function switchWindowTest(otherWindow, f
   is(fm.focusedElement, otherElement, "focus after inactive window focus");
 
   gLastFocus = otherElement;
   gLastFocusWindow = otherWindow;
   gEvents = "";
   gOldExpectedWindow = otherWindow;
   gNewExpectedWindow = framesetWindow.frames[1];
 
-  expectFocusShift(function () gNewExpectedWindow.focus(),
+  expectFocusShift(() => gNewExpectedWindow.focus(),
                    gNewExpectedWindow, getById("f4"), true, "switch to frame in another window");
   is(fm.getFocusedElementForWindow(otherWindow, false, {}).id, "other", "inactive window has focused element");
 
   gOldExpectedWindow = framesetWindow.frames[1];
   gNewExpectedWindow = otherWindow;
-  expectFocusShift(function () otherWindow.focus(),
+  expectFocusShift(() => otherWindow.focus(),
                    gNewExpectedWindow, getById("other"), true, "switch to another window");
 
   var exh = false;
   try {
     fm.activeWindow = framesetWindow.frames[0];
   }
   catch (ex) { exh = true; }
   is(exh, true, "activeWindow set to non top-level window");
@@ -1316,23 +1316,23 @@ function switchWindowTest(otherWindow, f
      otherWindow.document.commandDispatcher.getControllerForCommand("cmd_copy"),
      "getControllerForCommand for two windows different");
   ok(topWindow.document.commandDispatcher.getControllers() !=
      otherWindow.document.commandDispatcher.getControllers(),
      "getControllers for two windows different");
 
   gOldExpectedWindow = otherWindow;
   gNewExpectedWindow = framesetWindow.frames[1];
-  expectFocusShift(function () fm.activeWindow = topWindow,
+  expectFocusShift(() => fm.activeWindow = topWindow,
                    gNewExpectedWindow, getById("f4"), true, "switch to frame activeWindow");
 
   fm.clearFocus(otherWindow);
   gOldExpectedWindow = gNewExpectedWindow;
   gNewExpectedWindow = otherWindow;
-  expectFocusShift(function () fm.setFocus(otherElement, fm.FLAG_RAISE),
+  expectFocusShift(() => fm.setFocus(otherElement, fm.FLAG_RAISE),
                    gNewExpectedWindow, getById("other"), true, "switch to window with raise");
 
   getTopWindow(framesetWindow).document.commandDispatcher.focusedWindow = gOldExpectedWindow;
   is(fm.activeWindow, gNewExpectedWindow, "setting commandDispatcher focusedWindow doesn't raise window");
 
   fm.moveFocus(otherWindow, null, fm.MOVEFOCUS_FORWARD, 0);
   var otherTextbox = otherWindow.document.getElementById("other-textbox");
   otherTextbox.setSelectionRange(2, 3);
--- a/dom/tests/mochitest/general/test_497898.html
+++ b/dom/tests/mochitest/general/test_497898.html
@@ -9,17 +9,17 @@ SimpleTest.waitForExplicitFinish();
 function done()
 {
   is("passed", "passed", "test passed without crashing");
   SimpleTest.finish();
 }
 
 function switchFocus()
 {
-  setTimeout(function () window.open('497633.html', '_new', 'width=300,height=300'), 0);
+  setTimeout(() => window.open('497633.html', '_new', 'width=300,height=300'), 0);
 }
 </script>
 </head>
 <body>
 <iframe src="data:text/html;charset=utf-8,%3Chtml%3E%0A%3Chead%3E%3C/head%3E%0A%3Cbody%3E%0A%3Cbutton%20id%3D%22a%22%20onfocus%3D%22parent.switchFocus%28%29%22%20onblur%3D%22window.frameElement.parentNode.removeChild%28window.frameElement%29%22%3ESwitching%20focus%20to%20a%20different%20program%20should%20not%20crash%20Mozilla%3C/button%3E%0A%3Cscript%3E%0Adocument.getElementById%28%27a%27%29.focus%28%29%3B%0A%3C/script%3E%0A%3C/body%3E%0A%3C/html%3E"></iframe>
 
 <p id="display"></p>
 <div id="content" style="display: none"></div>
--- a/dom/tests/mochitest/general/test_domWindowUtils_scrollbarSize.html
+++ b/dom/tests/mochitest/general/test_domWindowUtils_scrollbarSize.html
@@ -13,36 +13,36 @@
       let cwindow = iframe.contentWindow;
       let utils = SpecialPowers.getDOMWindowUtils(cwindow);
       let doc = cwindow.document;
 
       function haveNonFloatingScrollbars() {
         return doc.getElementById("float").offsetWidth > 200;
       }
 
-      checkScrollbarSizeFlush(utils, function (w, h) w == 0 && h == 0,
+      checkScrollbarSizeFlush(utils, (w, h) => w == 0 && h == 0,
         "[overflow=hidden] corrrect scrollbar size after flushing");
 
       // Some platforms (esp. mobile) may have floating scrollbars that don't
       // affect layout. Thus getScrollbarSize() would always return zeros.
       if (haveNonFloatingScrollbars()) {
         let body = doc.querySelector("body");
         body.style.overflowY = "scroll";
 
-        checkScrollbarSize(utils, function (w, h) w == 0 && h == 0,
+        checkScrollbarSize(utils, (w, h) => w == 0 && h == 0,
           "[overflowY=scroll] correct scrollbar size w/o flushing");
 
-        checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h == 0,
+        checkScrollbarSizeFlush(utils, (w, h) => w > 0 && h == 0,
           "[overflowY=scroll] correct scrollbar size after flushing");
 
         body.style.overflowX = "scroll";
-        checkScrollbarSize(utils, function (w, h) w > 0 && h == 0,
+        checkScrollbarSize(utils, (w, h) => w > 0 && h == 0,
           "[overflowXY=scroll] correct scrollbar size w/o flushing");
 
-        checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h > 0,
+        checkScrollbarSizeFlush(utils, (w, h) => w > 0 && h > 0,
           "[overflowXY=scroll] correct scrollbar size after flushing");
       }
 
       SimpleTest.finish();
     }
 
     function checkScrollbarSize(utils, check, msg, flush = false) {
       let width = {}, height = {};
--- a/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing_perwindowpb.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing_perwindowpb.html
@@ -241,17 +241,17 @@ function doTest() {
         is(aWin.content.localStorage.getItem("persistent"), "persistent1", "back in normal mode");
         aWin.content.localStorage.clear();
         aWin.close();
 
         prefBranch.clearUserPref("browser.startup.page")
         prefBranch.clearUserPref("browser.startup.homepage_override.mstone");
         SimpleTest.finish();
       };
-      SimpleTest.executeSoon(function() testOnWindow(true, callback));
+      SimpleTest.executeSoon(() => testOnWindow(true, callback));
     });
   });
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 
--- a/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
@@ -34,17 +34,17 @@ function startTest() {
     info("Private window loaded");
     var frame = aWindow.content.document.createElement("iframe");
     aWindow.content.document.body.appendChild(frame);
     aWindow.content.addEventListener("message", function(aEvent) {
       onMessageReceived(aEvent, aWindow)
     }, false);
     slave = aWindow.content.frames[0];
 
-    SimpleTest.waitForFocus(function() doNextTest(aWindow), aWindow);
+    SimpleTest.waitForFocus(() => doNextTest(aWindow), aWindow);
   });
 }
 
 function doNextTest(aWindow) {
   info("Running test: " + currentTest);
   switch (currentTest) {
     // Initialy setup the quota to testing value of 1024B and
     // set a 500 bytes key with name length 1 (allocate 501 bytes)