Bug 1441376 - Stop the Syncing animation manually in browser_remote_tabs_button.js test. r?Paolo
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
--- 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;
}