Bug 1317164 - ensure browser_967000_button_sync.js cleans up after itself completely. r?malayaleecoder draft
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 25 Nov 2016 18:12:55 +1100
changeset 443777 618705c62dd28eaee450725138eb2848e32ae51e
parent 443602 bad312aefb42982f492ad2cf36f4c6c3d698f4f7
child 538141 cf7a90659eabac5a97eb4af997e1717d7230ea0d
push id37094
push userbmo:markh@mozilla.com
push dateFri, 25 Nov 2016 07:13:19 +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/");