Bug 1317164 - ensure browser_967000_button_sync.js cleans up after itself completely. r=malayaleecoder
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 25 Nov 2016 18:12:55 +1100
changeset 325053 8ea964e7ab596c985f0b8d9ab86e251b64cadf49
parent 325052 437aab812660f23db1cb6cc9f321c56856da48f7
child 325054 6060c3c5634270024b22c7ef28f29063ce3e35fa
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmalayaleecoder
bugs1317164
milestone53.0a1
Bug 1317164 - ensure browser_967000_button_sync.js cleans up after itself completely. r=malayaleecoder MozReview-Commit-ID: DO5RbkGj0Dv
browser/components/customizableui/test/browser_967000_button_sync.js
--- a/browser/components/customizableui/test/browser_967000_button_sync.js
+++ b/browser/components/customizableui/test/browser_967000_button_sync.js
@@ -37,18 +37,28 @@ let mockedInternal = {
   hasSyncedThisSession: false,
 };
 
 
 add_task(function* setup() {
   let oldInternal = SyncedTabs._internal;
   SyncedTabs._internal = mockedInternal;
 
+  // This test hacks some observer states to simulate a user being signed
+  // in to Sync - restore them when the test completes.
+  let initialObserverStates = {};
+  for (let id of ["sync-reauth-state", "sync-setup-state", "sync-syncnow-state"]) {
+    initialObserverStates[id] = document.getElementById(id).hidden;
+  }
+
   registerCleanupFunction(() => {
     SyncedTabs._internal = oldInternal;
+    for (let [id, initial] of Object.entries(initialObserverStates)) {
+      document.getElementById(id).hidden = initial;
+    }
   });
 });
 
 // The test expects the about:preferences#sync page to open in the current tab
 function* openPrefsFromMenuPanel(expectedPanelId, entryPoint) {
   info("Check Sync button functionality");
   Services.prefs.setCharPref("identity.fxaccounts.remote.signup.uri", "http://example.com/");