Bug 1207490 - Part 5: Remove use of expression closure from browser/base/content/test/social/. r=Gijs
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Sep 2015 17:56:55 +0900
changeset 265247 b8815627054a7229b45ea5733231eb57906c28f6
parent 265246 1e3a9fcf73d8154495f63d74c3a260e9dd53f31f
child 265248 98d3300738e3c9eec467dabdfc7883cfa4c3de9e
push id65891
push userarai_a@mac.com
push dateWed, 30 Sep 2015 16:36:04 +0000
treeherdermozilla-inbound@10194aec7255 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1207490
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 1207490 - Part 5: Remove use of expression closure from browser/base/content/test/social/. r=Gijs
browser/base/content/test/social/browser_social_chatwindow.js
browser/base/content/test/social/browser_social_chatwindowfocus.js
browser/base/content/test/social/browser_social_errorPage.js
browser/base/content/test/social/browser_social_marks.js
browser/base/content/test/social/browser_social_multiworker.js
browser/base/content/test/social/browser_social_window.js
browser/base/content/test/social/head.js
--- a/browser/base/content/test/social/browser_social_chatwindow.js
+++ b/browser/base/content/test/social/browser_social_chatwindow.js
@@ -248,22 +248,22 @@ var tests = {
   },
 
   testMultipleProviderChat: function(next) {
     // test incomming chats from all providers
     let port0 = openChat(Social.providers[0], function() {
       let port1 = openChat(Social.providers[1], function() {
         let port2 = openChat(Social.providers[2], function() {
           let chats = document.getElementById("pinnedchats");
-          waitForCondition(function() chats.children.length == Social.providers.length,
+          waitForCondition(() => chats.children.length == Social.providers.length,
             function() {
               ok(true, "one chat window per provider opened");
               // test logout of a single provider
               port2.postMessage({topic: "test-logout"});
-              waitForCondition(function() chats.children.length == Social.providers.length - 1,
+              waitForCondition(() => chats.children.length == Social.providers.length - 1,
                 function() {
                   Task.spawn(closeAllChats).then(next);
                 },
                 "chat window didn't close");
             }, "chat windows did not open");
         });
       });
     });
@@ -283,17 +283,17 @@ var tests = {
         case "test-init-done":
           info("open first chat window");
           port.postMessage({topic: "test-worker-chat", data: chatUrl});
           break;
         case "got-chatbox-message":
           ok(true, "got a chat window opened");
           if (opened) {
             port.postMessage({topic: "test-logout"});
-            waitForCondition(function() document.getElementById("pinnedchats").firstChild == null,
+            waitForCondition(() => document.getElementById("pinnedchats").firstChild == null,
                              function() {
                               next();
                              },
                              "chat windows didn't close");
           } else {
             // open a second chat window
             opened = true;
             port.postMessage({topic: "test-worker-chat", data: chatUrl+"?id=1"});
--- a/browser/base/content/test/social/browser_social_chatwindowfocus.js
+++ b/browser/base/content/test/social/browser_social_chatwindowfocus.js
@@ -30,17 +30,17 @@ function openChatViaSidebarMessage(port,
 }
 
 function openChatViaWorkerMessage(port, data, callback) {
   // sadly there is no message coming back to tell us when the chat has
   // been opened, so we wait until one appears.
   let chatbar = getChatBar();
   let numExpected = chatbar.childElementCount + 1;
   port.postMessage({topic: "test-worker-chat", data: data});
-  waitForCondition(function() chatbar.childElementCount == numExpected,
+  waitForCondition(() => chatbar.childElementCount == numExpected,
                    function() {
                       // so the child has been added, but we don't know if it
                       // has been intialized - re-request it and the callback
                       // means it's done.  Minimized, same as the worker.
                       chatbar.openChat(SocialSidebar.provider.origin,
                                        SocialSidebar.provider.name,
                                        data,
                                        "minimized",
@@ -102,17 +102,17 @@ function test() {
   tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
     tab.linkedBrowser.removeEventListener("load", tabLoad, true);
     // before every test we focus the input field.
     let preSubTest = function(cb) {
       // XXX - when bug 604289 is fixed it should be possible to just do:
       // tab.linkedBrowser.contentWindow.focus()
       // but instead we must do:
       tab.linkedBrowser.contentDocument.getElementById("theinput").focus();
-      waitForCondition(function() isTabFocused(), cb, "tab should have focus");
+      waitForCondition(() => isTabFocused(), cb, "tab should have focus");
     }
     let postSubTest = function(cb) {
       Task.spawn(closeAllChats).then(cb);
     }
     // and run the tests.
     runSocialTestWithProvider(manifest, function (finishcb) {
       SocialSidebar.show();
       runSocialTests(tests, preSubTest, postSubTest, function () {
@@ -139,17 +139,17 @@ var tests = {
         is(chatbar.childElementCount, 1, "exactly 1 chat open");
         ok(isTabFocused(), "tab should still be focused");
         // re-request the same chat via a message.
         openChatViaSidebarMessage(port, {stealFocus: 1}, function() {
           is(chatbar.childElementCount, 1, "still exactly 1 chat open");
           ok(isTabFocused(), "tab should still be focused");
           // re-request the same chat via user event.
           openChatViaUser();
-          waitForCondition(function() isChatFocused(chatbar.selectedChat),
+          waitForCondition(() => isChatFocused(chatbar.selectedChat),
                            function() {
             is(chatbar.childElementCount, 1, "still exactly 1 chat open");
             is(chatbar.selectedChat, chatbar.firstElementChild, "chat should be selected");
             next();
           }, "chat should be focused");
         });
       });
     });
@@ -157,16 +157,16 @@ var tests = {
 
   // In this test we arrange for the sidebar to open the chat via a simulated
   // click.  This should cause the new chat to be opened and focused.
   testFocusWhenViaUser: function(next) {
     startTestAndWaitForSidebar(function(port) {
       let chatbar = getChatBar();
       openChatViaUser();
       ok(chatbar.firstElementChild, "chat opened");
-      waitForCondition(function() isChatFocused(chatbar.selectedChat),
+      waitForCondition(() => isChatFocused(chatbar.selectedChat),
                        function() {
         is(chatbar.selectedChat, chatbar.firstElementChild, "chat is selected");
         next();
       }, "chat should be focused");
     });
   },
 };
--- a/browser/base/content/test/social/browser_social_errorPage.js
+++ b/browser/base/content/test/social/browser_social_errorPage.js
@@ -129,17 +129,17 @@ var tests = {
       openChat(
         manifest.sidebarURL, /* empty html page */
         function() { // the panel api callback
           panelCallbackCount++;
         },
         function() { // the "load" callback.
           todo_is(panelCallbackCount, 0, "Bug 833207 - should be no callback when error page loads.");
           let chat = getChatBar().selectedChat;
-          waitForCondition(function() chat.content != null && chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
+          waitForCondition(() => chat.content != null && chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
                            function() {
                             chat.close();
                             next();
                             },
                            "error page didn't appear");
         }
       );
     });
@@ -157,24 +157,24 @@ var tests = {
       null,
       function() { // the "load" callback.
         let chat = getChatBar().selectedChat;
         is(chat.contentDocument.documentURI, url, "correct url loaded");
         // toggle to a detached window.
         chat.swapWindows().then(
           chat => {
             ok(!!chat.content, "we have chat content 1");
-            waitForCondition(function() chat.content != null && chat.contentDocument.readyState == "complete",
+            waitForCondition(() => chat.content != null && chat.contentDocument.readyState == "complete",
                              function() {
               // now go offline and reload the chat - about:socialerror should be loaded.
               goOffline().then(function() {
                 ok(!!chat.content, "we have chat content 2");
                 chat.contentDocument.location.reload();
                 info("chat reload called");
-                waitForCondition(function() chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
+                waitForCondition(() => chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
                                  function() {
                                   chat.close();
                                   next();
                                   },
                                  "error page didn't appear");
               });
             }, "swapped window loaded");
           }
--- a/browser/base/content/test/social/browser_social_marks.js
+++ b/browser/base/content/test/social/browser_social_marks.js
@@ -152,34 +152,34 @@ var tests = {
           case "test-init-done":
             ok(true, "test-init-done received");
             ok(provider.profile.userName, "profile was set by test worker");
             // first click marks the page, second click opens the page. We have to
             // synthesize so the command event happens
             EventUtils.synthesizeMouseAtCenter(btn, {});
             // wait for the button to be marked, click to open panel
             is(btn.panel.state, "closed", "panel should not be visible yet");
-            waitForCondition(function() btn.isMarked, function() {
+            waitForCondition(() => btn.isMarked, function() {
               EventUtils.synthesizeMouseAtCenter(btn, {});
             }, "button is marked");
             break;
           case "got-social-panel-visibility":
             ok(true, "got the panel message " + e.data.result);
             if (e.data.result == "shown") {
               // unmark the page via the button in the page
               ensureFrameLoaded(btn.content).then(() => {
                 let doc = btn.contentDocument;
                 let unmarkBtn = doc.getElementById("unmark");
                 ok(unmarkBtn, "testMarkPanel - got the panel unmark button");
                 EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
               });
             } else {
               // page should no longer be marked
               port.close();
-              waitForCondition(function() !btn.isMarked, function() {
+              waitForCondition(() => !btn.isMarked, function() {
                 // cleanup after the page has been unmarked
                 ensureBrowserTabClosed(tab).then(() => {
                   ok(btn.disabled, "button is disabled");
                   next();
                 });
               }, "button unmarked");
             }
             break;
@@ -240,17 +240,17 @@ var tests = {
       ok(!btn.disabled, "button is enabled");
       port.onmessage = function (e) {
         let topic = e.data.topic;
         switch (topic) {
           case "test-init-done":
             ok(true, "test-init-done received");
             ok(provider.profile.userName, "profile was set by test worker");
             port.postMessage({topic: "test-logout"});
-            waitForCondition(function() !provider.profile.userName,
+            waitForCondition(() => !provider.profile.userName,
                 function() {
                   // when the provider has not indicated to us that a user is
                   // logged in, the first click opens the page.
                   EventUtils.synthesizeMouseAtCenter(btn, {});
                 },
                 "profile was unset by test worker");
             break;
           case "got-social-panel-visibility":
@@ -263,17 +263,17 @@ var tests = {
                 let doc = btn.contentDocument;
                 let unmarkBtn = doc.getElementById("unmark");
                 ok(unmarkBtn, "testMarkPanelLoggedOut - got the panel unmark button");
                 EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
               });
             } else {
               // page should no longer be marked
               port.close();
-              waitForCondition(function() !btn.isMarked, function() {
+              waitForCondition(() => !btn.isMarked, function() {
                 // cleanup after the page has been unmarked
                 ensureBrowserTabClosed(tab).then(() => {
                   ok(btn.disabled, "button is disabled");
                   next();
                 });
               }, "button unmarked");
             }
             break;
--- a/browser/base/content/test/social/browser_social_multiworker.js
+++ b/browser/base/content/test/social/browser_social_multiworker.js
@@ -47,17 +47,17 @@ var tests = {
       };
       port.postMessage({topic: "test-init"});
     }
 
     for (let p of Social.providers) {
       oneWorkerTest(p);
     }
 
-    waitForCondition(function() messageReceived == Social.providers.length,
+    waitForCondition(() => messageReceived == Social.providers.length,
                      next, "received messages from all workers",
                      /* increase timeout because shutting down a child process is slow */ 60);
   },
 
    testMultipleWorkerEnabling: function(next) {
      // test that all workers are enabled when we allow multiple workers
      for (let p of Social.providers) {
        ok(p.enabled, "provider enabled");
--- a/browser/base/content/test/social/browser_social_window.js
+++ b/browser/base/content/test/social/browser_social_window.js
@@ -91,17 +91,17 @@ var tests = {
 
   // Check when providers are enabled and social is turned on at startup.
   testEnabledStartup: function(cbnext) {
     setManifestPref("social.manifest.test", manifest);
     ok(!SocialSidebar.opened, "sidebar is closed initially");
     SocialService.addProvider(manifest, function() {
       SocialService.addProvider(manifest2, function (provider) {
         SocialSidebar.show();
-        waitForCondition(function() SocialSidebar.opened,
+        waitForCondition(() => SocialSidebar.opened,
                      function() {
           ok(SocialSidebar.opened, "first window sidebar is open");
           openWindowAndWaitForInit(window, function(w1) {
             ok(w1.SocialSidebar.opened, "new window sidebar is open");
             ok(SocialService.hasEnabledProviders, "providers are enabled");
             checkSocialUI(w1);
             // now init is complete, open a second window
             openWindowAndWaitForInit(window, function(w2) {
@@ -135,17 +135,17 @@ var tests = {
     ok(!SocialSidebar.opened, "sidebar is closed initially");
     ok(!Services.prefs.prefHasUserValue("social.sidebar.provider"), "global state unset");
     // mimick no session state in opener so we exercise the global state via pref
     SessionStore.deleteWindowValue(window, "socialSidebar");
     ok(!SessionStore.getWindowValue(window, "socialSidebar"), "window state unset");
     SocialService.addProvider(manifest, function() {
       openWindowAndWaitForInit(window, function(w1) {
         w1.SocialSidebar.show();
-        waitForCondition(function() w1.SocialSidebar.opened,
+        waitForCondition(() => w1.SocialSidebar.opened,
                      function() {
           ok(Services.prefs.prefHasUserValue("social.sidebar.provider"), "global state set");
           ok(!SocialSidebar.opened, "1. main sidebar is still closed");
           ok(w1.SocialSidebar.opened, "1. window sidebar is open");
           closeWindow(w1, function() {
             // this time, the global state should cause the sidebar to be opened
             // in the new window
             openWindowAndWaitForInit(window, function(w1) {
--- a/browser/base/content/test/social/head.js
+++ b/browser/base/content/test/social/head.js
@@ -149,17 +149,17 @@ function runSocialTestWithProvider(manif
       }
 
       // If we've added all the providers we need, call the callback to start
       // the tests (and give it a callback it can call to finish them)
       if (providersAdded == manifests.length) {
         registerCleanupFunction(function () {
           finishSocialTest(true);
         });
-        waitForCondition(function() provider.enabled,
+        waitForCondition(() => provider.enabled,
                          function() {
           info("provider has been enabled");
           callback(finishSocialTest);
         }, "providers added and enabled");
       }
     });
   });
 }
@@ -584,17 +584,17 @@ function resizeAndCheckWidths(first, sec
   let count = checks.length;
   let [width, numExpectedVisible, why] = checks.shift();
   info("<< Check " + count + ": " + why);
   info(count + ": " + "resizing window to " + width + ", expect " + numExpectedVisible + " visible items");
   resizeWindowToChatAreaWidth(width, function(sizedOk) {
     checkPopup();
     ok(sizedOk, count+": window resized correctly");
     function collapsedObserver(r, m) {
-      if ([first, second, third].filter(function(item) !item.collapsed).length == numExpectedVisible) {
+      if ([first, second, third].filter(item => !item.collapsed).length == numExpectedVisible) {
         if (m) {
           m.disconnect();
         }
         ok(true, count + ": " + "correct number of chats visible");
         info(">> Check " + count);
         executeSoon(function() {
           resizeAndCheckWidths(first, second, third, checks, cb);
         });