Bug 1441376 - Stop the Syncing animation manually in browser_remote_tabs_button.js test. r=Paolo a=test-only DEVEDITION_60_0b5_BUILD1 DEVEDITION_60_0b5_RELEASE FENNEC_60_0b5_BUILD1 FENNEC_60_0b5_RELEASE FIREFOX_60_0b5_BUILD1 FIREFOX_60_0b5_RELEASE
authorEdouard Oger <eoger@fastmail.com>
Fri, 09 Mar 2018 16:03:48 -0500
changeset 774168 760d74c088b29012c8f37a8ef61981b80fda22ac
parent 774167 80b491577ef9c29be320e9eb79b3297fabff522a
child 774169 d50cee55dd748dae29f730d88bac93dbebbbeec0
push id104369
push usermixedpuppy@gmail.com
push dateWed, 28 Mar 2018 19:17:18 +0000
reviewersPaolo, test-only
bugs1441376
milestone60.0
Bug 1441376 - Stop the Syncing animation manually in browser_remote_tabs_button.js test. r=Paolo a=test-only The UIState.ON_UPDATE notification should be enough to reset the state of the panel every time the test is about to be executed. Wrong. In response to this notification, gSync.onActivityStop() is called, which disables the syncing animation immediately ONLY if it has been running for at least 1.5sec (which is almost never happening in tests), otherwise we get a setTimeout with the remaining time. When the sync animation is running, we also do not react to clicks (disabled), hence the test failing. We fix this by stopping the animation ourselves manually at the end of the test, so any subsequent test will start with a correct UI state. MozReview-Commit-ID: CrEb82Tw5SO
browser/components/customizableui/test/browser_remote_tabs_button.js
--- a/browser/components/customizableui/test/browser_remote_tabs_button.js
+++ b/browser/components/customizableui/test/browser_remote_tabs_button.js
@@ -41,16 +41,20 @@ add_task(async function testSyncRemoteTa
   ok(remoteTabsPanel.getAttribute("visible"), "Sync Panel is in view");
 
   // Find and click the "setup" button.
   let syncNowButton = document.getElementById("PanelUI-remotetabs-syncnow");
   syncNowButton.click();
   info("The sync now button was clicked");
 
   await waitForCondition(() => syncWasCalled);
+
+  // We need to stop the Syncing animation manually otherwise the button
+  // will be disabled at the beginning of a next test.
+  gSync._onActivityStop();
 });
 
 add_task(async function asyncCleanup() {
   // reset the panel UI to the default state
   await resetCustomization();
   ok(CustomizableUI.inDefaultState, "The panel UI is in default state again.");
 
   if (isOverflowOpen()) {
@@ -64,20 +68,20 @@ add_task(async function asyncCleanup() {
 
 function mockFunctions() {
   // mock UIState.get()
   UIState.get = () => ({
     status: UIState.STATUS_SIGNED_IN,
     email: "user@mozilla.com"
   });
 
-  service.sync = mocked_syncAndReportErrors;
+  service.sync = mocked_sync;
 }
 
-function mocked_syncAndReportErrors() {
+function mocked_sync() {
   syncWasCalled = true;
 }
 
 function restoreValues() {
   UIState.get = getState;
   service.sync = originalSync;
 }