summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_987185_syncButton.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/components/customizableui/test/browser_987185_syncButton.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/customizableui/test/browser_987185_syncButton.js')
-rwxr-xr-xbrowser/components/customizableui/test/browser_987185_syncButton.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_987185_syncButton.js b/browser/components/customizableui/test/browser_987185_syncButton.js
new file mode 100755
index 000000000..988d738be
--- /dev/null
+++ b/browser/components/customizableui/test/browser_987185_syncButton.js
@@ -0,0 +1,77 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+"use strict";
+
+var syncService = {};
+Components.utils.import("resource://services-sync/service.js", syncService);
+
+var needsSetup;
+var originalSync;
+var service = syncService.Service;
+var syncWasCalled = false;
+
+add_task(function* testSyncButtonFunctionality() {
+ info("Check Sync button functionality");
+ storeInitialValues();
+ mockFunctions();
+
+ // add the Sync button to the panel
+ CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
+
+ // check the button's functionality
+ yield PanelUI.show();
+ info("The panel menu was opened");
+
+ let syncButton = document.getElementById("sync-button");
+ ok(syncButton, "The Sync button was added to the Panel Menu");
+ // click the button - the panel should open.
+ syncButton.click();
+ let syncPanel = document.getElementById("PanelUI-remotetabs");
+ ok(syncPanel.getAttribute("current"), "Sync Panel is in view");
+
+ // Find and click the "setup" button.
+ let syncNowButton = document.getElementById("PanelUI-remotetabs-syncnow");
+ syncNowButton.click();
+
+ info("The sync button was clicked");
+
+ yield waitForCondition(() => syncWasCalled);
+});
+
+add_task(function* asyncCleanup() {
+ // reset the panel UI to the default state
+ yield resetCustomization();
+ ok(CustomizableUI.inDefaultState, "The panel UI is in default state again.");
+
+ if (isPanelUIOpen()) {
+ let panelHidePromise = promisePanelHidden(window);
+ PanelUI.hide();
+ yield panelHidePromise;
+ }
+
+ restoreValues();
+});
+
+function mockFunctions() {
+ // mock needsSetup
+ gSyncUI._needsSetup = () => Promise.resolve(false);
+
+ // mock service.errorHandler.syncAndReportErrors()
+ service.errorHandler.syncAndReportErrors = mocked_syncAndReportErrors;
+}
+
+function mocked_syncAndReportErrors() {
+ syncWasCalled = true;
+}
+
+function restoreValues() {
+ gSyncUI._needsSetup = needsSetup;
+ service.sync = originalSync;
+}
+
+function storeInitialValues() {
+ needsSetup = gSyncUI._needsSetup;
+ originalSync = service.sync;
+}