Bug 1140092 - Remove handling of guest calls from the Loop backend. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Mon, 09 Mar 2015 23:42:08 +0000
changeset 249030 95efe38a63d65243c32aac59cda7b1455c0b85e8
parent 249029 e750aa4fc06c0c78e4adb2ef9bb8a6c26f4381c5
child 249031 db75b48611b58f3be057c6f6f6f18b5c666347d4
push id966
push usermleibovic@mozilla.com
push dateTue, 10 Mar 2015 01:36:33 +0000
reviewersmikedeboer
bugs1140092
milestone39.0a1
Bug 1140092 - Remove handling of guest calls from the Loop backend. r=mikedeboer
browser/components/loop/LoopCalls.jsm
browser/components/loop/MozLoopService.jsm
browser/components/loop/test/xpcshell/head.js
browser/components/loop/test/xpcshell/test_loopservice_busy.js
browser/components/loop/test/xpcshell/test_loopservice_dnd.js
browser/components/loop/test/xpcshell/test_loopservice_hawk_errors.js
browser/components/loop/test/xpcshell/test_loopservice_initialize.js
browser/components/loop/test/xpcshell/test_loopservice_notification.js
browser/components/loop/test/xpcshell/test_loopservice_registration_retry.js
browser/components/loop/test/xpcshell/test_loopservice_restart.js
browser/components/loop/test/xpcshell/test_loopservice_token_invalid.js
--- a/browser/components/loop/LoopCalls.jsm
+++ b/browser/components/loop/LoopCalls.jsm
@@ -216,18 +216,16 @@ let LoopCallsInternal = {
 
     // Request the information on the new call(s) associated with this version.
     // The registered FxA session is checked first, then the anonymous session.
     // Make the call to get the GUEST session regardless of whether the FXA
     // request fails.
 
     if (channelID == MozLoopService.channelIDs.callsFxA && MozLoopService.userProfile) {
       this._getCalls(LOOP_SESSION_TYPE.FXA, version);
-    } else {
-      this._getCalls(LOOP_SESSION_TYPE.GUEST, version);
     }
   },
 
   /**
    * Make a hawkRequest to GET/calls?=version for this session type.
    *
    * @param {LOOP_SESSION_TYPE} sessionType - type of hawk token used
    *        for the GET operation.
--- a/browser/components/loop/MozLoopService.jsm
+++ b/browser/components/loop/MozLoopService.jsm
@@ -153,47 +153,16 @@ let MozLoopServiceInternal = {
     } catch (x) {
       // Default to 5 seconds
       return 5000;
     }
     return initialDelay;
   },
 
   /**
-   * Gets the current latest expiry time for urls.
-   *
-   * In seconds since epoch.
-   */
-  get expiryTimeSeconds() {
-    try {
-      return Services.prefs.getIntPref("loop.urlsExpiryTimeSeconds");
-    } catch (x) {
-      // It is ok for the pref not to exist.
-      return 0;
-    }
-  },
-
-  /**
-   * Sets the expiry time to either the specified time, or keeps it the same
-   * depending on which is latest.
-   */
-  set expiryTimeSeconds(time) {
-    if (time > this.expiryTimeSeconds) {
-      Services.prefs.setIntPref("loop.urlsExpiryTimeSeconds", time);
-    }
-  },
-
-  /**
-   * Returns true if the expiry time is in the future.
-   */
-  urlExpiryTimeIsInFuture: function() {
-    return this.expiryTimeSeconds * 1000 > Date.now();
-  },
-
-  /**
    * Retrieves MozLoopService Firefox Accounts OAuth token.
    *
    * @return {Object} OAuth token
    */
   get fxAOAuthTokenData() {
     return getJSONPref("loop.fxa_oauth.tokendata");
   },
 
@@ -385,27 +354,30 @@ let MozLoopServiceInternal = {
       log.debug("promiseRegisteredWithServers: registration already completed or in progress:",
                 sessionType);
       return this.deferredRegistrations.get(sessionType);
     }
 
     let options = this.mocks.webSocket ? { mockWebSocket: this.mocks.webSocket } : {};
     this.pushHandler.initialize(options); // This can be called more than once.
 
-    let callsID = sessionType == LOOP_SESSION_TYPE.GUEST ?
-          MozLoopService.channelIDs.callsGuest :
-          MozLoopService.channelIDs.callsFxA,
-        roomsID = sessionType == LOOP_SESSION_TYPE.GUEST ?
-          MozLoopService.channelIDs.roomsGuest :
-          MozLoopService.channelIDs.roomsFxA;
-
-    let regPromise = this.createNotificationChannel(
-      callsID, sessionType, "calls", LoopCalls.onNotification).then(() => {
-        return this.createNotificationChannel(
-          roomsID, sessionType, "rooms", roomsPushNotification)});
+    let regPromise;
+    if (sessionType == LOOP_SESSION_TYPE.GUEST) {
+      regPromise = this.createNotificationChannel(
+        MozLoopService.channelIDs.roomsGuest, sessionType, "rooms",
+        roomsPushNotification);
+    } else {
+      regPromise = this.createNotificationChannel(
+        MozLoopService.channelIDs.callsFxA, sessionType, "calls",
+        LoopCalls.onNotification).then(() => {
+          return this.createNotificationChannel(
+            MozLoopService.channelIDs.roomsFxA, sessionType, "rooms",
+            roomsPushNotification);
+        });
+    }
 
     log.debug("assigning to deferredRegistrations for sessionType:", sessionType);
     this.deferredRegistrations.set(sessionType, regPromise);
 
     // Do not return the new Promise generated by this catch() invocation.
     // This will be called along with any other onReject function attached to regPromise.
     regPromise.catch((error) => {
       log.error("Failed to register with Loop server with sessionType ", sessionType, error);
@@ -582,21 +554,18 @@ let MozLoopServiceInternal = {
 
     let handle401Error = (error) => {
       if (sessionType === LOOP_SESSION_TYPE.FXA) {
         return MozLoopService.logOutFromFxA().then(() => {
           // Set a user-visible error after logOutFromFxA clears existing ones.
           this.setError("login", error);
           throw error;
         });
-      } else if (this.urlExpiryTimeIsInFuture()) {
-        // If there are no Guest URLs in the future, don't use setError to notify the user since
-        // there isn't a need for a Guest registration at this time.
-        this.setError("registration", error);
       }
+      this.setError("registration", error);
       throw error;
     };
 
     return gHawkClient.request(path, method, credentials, payloadObj).then(
       (result) => {
         this.clearError("network");
         return result;
       },
@@ -1053,17 +1022,16 @@ let gInitializeTimerFunc = (deferredInit
 this.MozLoopService = {
   _DNSService: gDNSService,
   _activeScreenShares: [],
 
   get channelIDs() {
     // Channel ids that will be registered with the PushServer for notifications
     return {
       callsFxA: "25389583-921f-4169-a426-a4673658944b",
-      callsGuest: "801f754b-686b-43ec-bd83-1419bbf58388",
       roomsFxA: "6add272a-d316-477c-8335-f00f73dfde71",
       roomsGuest: "19d3f799-a8f3-4328-9822-b7cd02765832",
     };
   },
 
   set initializeTimerFunc(value) {
     gInitializeTimerFunc = value;
   },
@@ -1119,20 +1087,19 @@ this.MozLoopService = {
           message: MozLoopServiceInternal.localizedStrings.get("rooms_room_joined_label"),
           selectTab: "rooms"
         });
       }
     });
 
     LoopRooms.on("joined", this.maybeResumeTourOnRoomJoined.bind(this));
 
-    // If expiresTime is not in the future and the user hasn't
+    // If there's no guest room created and the user hasn't
     // previously authenticated then skip registration.
-    if (!MozLoopServiceInternal.urlExpiryTimeIsInFuture() &&
-        !LoopRooms.getGuestCreatedRoom() &&
+    if (!LoopRooms.getGuestCreatedRoom() &&
         !MozLoopServiceInternal.fxAOAuthTokenData) {
       return Promise.resolve("registration not needed");
     }
 
     let deferredInitialization = Promise.defer();
     gInitializeTimerFunc(deferredInitialization);
 
     return deferredInitialization.promise;
@@ -1199,21 +1166,20 @@ this.MozLoopService = {
     error => {
       // If we get a non-object then setError was already called for a different error type.
       if (typeof(error) == "object") {
         MozLoopServiceInternal.setError("initialization", error, () => MozLoopService.delayedInitialize(Promise.defer()));
       }
     });
 
     try {
-      if (MozLoopServiceInternal.urlExpiryTimeIsInFuture() ||
-          LoopRooms.getGuestCreatedRoom()) {
+      if (LoopRooms.getGuestCreatedRoom()) {
         yield this.promiseRegisteredWithServers(LOOP_SESSION_TYPE.GUEST);
       } else {
-        log.debug("delayedInitialize: URL expiry time isn't in the future so not registering as a guest");
+        log.debug("delayedInitialize: Guest Room hasn't been created so not registering as a guest");
       }
     } catch (ex) {
       log.debug("MozLoopService: Failure of guest registration", ex);
       deferredInitialization.reject(ex);
       yield completedPromise;
       return;
     }
 
@@ -1456,17 +1422,17 @@ this.MozLoopService = {
    * @return {Promise} that resolves when the FxA logout flow is complete.
    */
   logOutFromFxA: Task.async(function*() {
     log.debug("logOutFromFxA");
     try {
       yield MozLoopServiceInternal.unregisterFromLoopServer(LOOP_SESSION_TYPE.FXA);
     }
     catch (err) {
-      throw err
+      throw err;
     }
     finally {
       MozLoopServiceInternal.clearSessionToken(LOOP_SESSION_TYPE.FXA);
       MozLoopServiceInternal.fxAOAuthTokenData = null;
       MozLoopServiceInternal.fxAOAuthProfile = null;
       MozLoopServiceInternal.deferredRegistrations.delete(LOOP_SESSION_TYPE.FXA);
       // Unregister with PushHandler so these push channels will not get re-registered
       // if the connection is re-established by the PushHandler.
--- a/browser/components/loop/test/xpcshell/head.js
+++ b/browser/components/loop/test/xpcshell/head.js
@@ -27,16 +27,17 @@ const kUAID = "f47ac11b-58ca-4372-9567-0
 // Fake loop server
 var loopServer;
 
 // Ensure loop is always enabled for tests
 Services.prefs.setBoolPref("loop.enabled", true);
 
 // Cleanup function for all tests
 do_register_cleanup(() => {
+  Services.prefs.clearUserPref("loop.enabled");
   MozLoopService.errors.clear();
 });
 
 function setupFakeLoopServer() {
   loopServer = new HttpServer();
   loopServer.start(-1);
 
   Services.prefs.setCharPref("loop.server",
@@ -45,16 +46,29 @@ function setupFakeLoopServer() {
   MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
 
   do_register_cleanup(function() {
     loopServer.stop(function() {});
     MozLoopServiceInternal.mocks.pushHandler = undefined;
   });
 }
 
+/**
+ * Sets up the userProfile to make the service think we're logged into FxA.
+ */
+function setupFakeFxAUserProfile() {
+  MozLoopServiceInternal.fxAOAuthTokenData = { token_type: "bearer" };
+  MozLoopServiceInternal.fxAOAuthProfile = { email: "fake@invalid.com" };
+
+  do_register_cleanup(function() {
+    MozLoopServiceInternal.fxAOAuthTokenData = null;
+    MozLoopServiceInternal.fxAOAuthProfile = null;
+  });
+}
+
 function waitForCondition(aConditionFn, aMaxTries=50, aCheckInterval=100) {
   function tryAgain() {
     function tryNow() {
       tries++;
       if (aConditionFn()) {
         deferred.resolve();
       } else if (tries < aMaxTries) {
         tryAgain();
--- a/browser/components/loop/test/xpcshell/test_loopservice_busy.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_busy.js
@@ -17,65 +17,16 @@ let msgHandler = function(msg) {
   if (msg.messageType &&
       msg.messageType === "action" &&
       msg.event === "terminate" &&
       msg.reason === "busy") {
     actionReceived = true;
   }
 };
 
-add_task(function* test_busy_2guest_calls() {
-  actionReceived = false;
-
-  mockPushHandler.registrationPushURL = kEndPointUrl;
-
-  yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.GUEST);
-
-  let opened = 0;
-  let windowId;
-  Chat.open = function(contentWindow, origin, title, url) {
-    opened++;
-    windowId = url.match(/about:loopconversation\#(\d+)$/)[1];
-  };
-
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
-
-  yield waitForCondition(() => { return actionReceived && opened > 0; }).then(() => {
-    do_check_true(opened === 1, "should open only one chat window");
-    do_check_true(actionReceived, "should respond with busy/reject to second call");
-    LoopCalls.clearCallInProgress(windowId);
-  }, () => {
-    do_throw("should have opened a chat window for first call and rejected second call");
-  });
-});
-
-add_task(function* test_busy_1fxa_1guest_calls() {
-  actionReceived = false;
-
-  yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.GUEST);
-  yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.FXA);
-
-  let opened = 0;
-  let windowId;
-  Chat.open = function(contentWindow, origin, title, url) {
-    opened++;
-    windowId = url.match(/about:loopconversation\#(\d+)$/)[1];
-  };
-
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsFxA);
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
-
-  yield waitForCondition(() => { return actionReceived && opened > 0; }).then(() => {
-    do_check_true(opened === 1, "should open only one chat window");
-    do_check_true(actionReceived, "should respond with busy/reject to second call");
-    LoopCalls.clearCallInProgress(windowId);
-  }, () => {
-    do_throw("should have opened a chat window for first call and rejected second call");
-  });
-});
 
 add_task(function* test_busy_2fxa_calls() {
   actionReceived = false;
 
   yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.FXA);
 
   let opened = 0;
   let windowId;
@@ -90,55 +41,32 @@ add_task(function* test_busy_2fxa_calls(
     do_check_true(opened === 1, "should open only one chat window");
     do_check_true(actionReceived, "should respond with busy/reject to second call");
     LoopCalls.clearCallInProgress(windowId);
   }, () => {
     do_throw("should have opened a chat window for first call and rejected second call");
   });
 });
 
-add_task(function* test_busy_1guest_1fxa_calls() {
-  actionReceived = false;
-
-  yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.GUEST);
-  yield MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.FXA);
-
-  let opened = 0;
-  let windowId;
-  Chat.open = function(contentWindow, origin, title, url) {
-    opened++;
-    windowId = url.match(/about:loopconversation\#(\d+)$/)[1];
-  };
-
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsFxA);
-
-  yield waitForCondition(() => { return actionReceived && opened > 0; }).then(() => {
-    do_check_true(opened === 1, "should open only one chat window");
-    do_check_true(actionReceived, "should respond with busy/reject to second call");
-    LoopCalls.clearCallInProgress(windowId);
-  }, () => {
-    do_throw("should have opened a chat window for first call and rejected second call");
-  });
-});
-
 function run_test() {
   setupFakeLoopServer();
 
   // Setup fake login state so we get FxA requests.
   const MozLoopServiceInternal = Cu.import("resource:///modules/loop/MozLoopService.jsm", {}).MozLoopServiceInternal;
   MozLoopServiceInternal.fxAOAuthTokenData = {token_type:"bearer",access_token:"1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",scope:"profile"};
   MozLoopServiceInternal.fxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"};
 
   let mockWebSocket = new MockWebSocketChannel();
   mockWebSocket.defaultMsgHandler = msgHandler;
   LoopCallsInternal.mocks.webSocket = mockWebSocket;
 
   Services.io.offline = false;
 
+  mockPushHandler.registrationPushURL = kEndPointUrl;
+
   // For each notification received from the PushServer, MozLoopService will first query
   // for any pending calls on the FxA hawk session and then again using the guest session.
   // A pair of response objects in the callsResponses array will be consumed for each
   // notification. The even calls object is for the FxA session, the odd the Guest session.
 
   let callsRespCount = 0;
   let callsResponses = [
     {calls: [{callId: firstCallId,
--- a/browser/components/loop/test/xpcshell/test_loopservice_dnd.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_dnd.js
@@ -28,23 +28,23 @@ add_test(function test_set_do_not_distur
   run_next_test();
 });
 
 add_test(function test_do_not_disturb_disabled_should_open_chat_window() {
   MozLoopService.doNotDisturb = false;
 
   mockPushHandler.registrationPushURL = kEndPointUrl;
 
-  MozLoopService.promiseRegisteredWithServers().then(() => {
+  MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.FXA).then(() => {
     let opened = false;
     Chat.open = function() {
       opened = true;
     };
 
-    mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
+    mockPushHandler.notify(1, MozLoopService.channelIDs.callsFxA);
 
     waitForCondition(function() opened).then(() => {
       run_next_test();
     }, () => {
       do_throw("should have opened a chat window");
     });
   });
 });
@@ -53,27 +53,29 @@ add_test(function test_do_not_disturb_en
   MozLoopService.doNotDisturb = true;
 
   // We registered in the previous test, so no need to do that on this one.
   let opened = false;
   Chat.open = function() {
     opened = true;
   };
 
-  mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
+  mockPushHandler.notify(1, MozLoopService.channelIDs.callsFxA);
 
   do_timeout(500, function() {
     do_check_false(opened, "should not open a chat window");
     run_next_test();
   });
 });
 
 function run_test() {
   setupFakeLoopServer();
 
+  setupFakeFxAUserProfile();
+
   loopServer.registerPathHandler("/registration", (request, response) => {
     response.setStatusLine(null, 200, "OK");
     response.processAsync();
     response.finish();
   });
   loopServer.registerPathHandler("/calls", (request, response) => {
     response.setStatusLine(null, 200, "OK");
     response.write(JSON.stringify({calls: [{callId: 4444333221, websocketToken: "0deadbeef0"}]}));
--- a/browser/components/loop/test/xpcshell/test_loopservice_hawk_errors.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_hawk_errors.js
@@ -168,24 +168,24 @@ add_task(function* error_503() {
   });
 });
 
 add_task(cleanup_between_tests);
 
 function run_test() {
   setupFakeLoopServer();
 
-  // Set the expiry time one hour in the future so that an error is shown when the guest session expires.
-  MozLoopServiceInternal.expiryTimeSeconds = (Date.now() / 1000) + 3600;
+  Services.prefs.setBoolPref("loop.createdRoom", true);
 
   do_register_cleanup(() => {
     Services.prefs.clearUserPref("loop.hawk-session-token");
     Services.prefs.clearUserPref("loop.hawk-session-token.fxa");
     Services.prefs.clearUserPref("loop.urlsExpiryTimeSeconds");
     Services.prefs.clearUserPref("network.dns.offline-localhost");
+    Services.prefs.clearUserPref("loop.createdRoom");
     MozLoopService.errors.clear();
   });
 
   run_next_test();
 }
 
 function* cleanup_between_tests() {
   MozLoopService.errors.clear();
--- a/browser/components/loop/test/xpcshell/test_loopservice_initialize.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_initialize.js
@@ -13,50 +13,50 @@ add_task(function test_initialize_no_exp
   let initializedPromise = yield MozLoopService.initialize();
   Assert.equal(initializedPromise, "registration not needed",
                "Promise should be fulfilled");
   Assert.equal(startTimerCalled, false,
     "should not register when no expiry time is set");
 });
 
 /**
- * Tests that registration doesn't happen when the expiry time is
- * in the past.
+ * Tests that registration doesn't happen when there has been no
+ * room created.
  */
-add_task(function test_initialize_expiry_past() {
-  // Set time to be 2 seconds in the past.
-  let nowSeconds = Date.now() / 1000;
-  Services.prefs.setIntPref("loop.urlsExpiryTimeSeconds", nowSeconds - 2);
+add_task(function test_initialize_no_guest_rooms() {
+  Services.prefs.setBoolPref("loop.createdRoom", false);
   startTimerCalled = false;
 
   MozLoopService.initialize();
 
   Assert.equal(startTimerCalled, false,
-    "should not register when expiry time is in past");
+    "should not register when no guest rooms have been created");
 });
 
 /**
  * Tests that registration happens when the expiry time is in
  * the future.
  */
-add_task(function test_initialize_starts_timer() {
-  // Set time to be 1 minute in the future
-  let nowSeconds = Date.now() / 1000;
-  Services.prefs.setIntPref("loop.urlsExpiryTimeSeconds", nowSeconds + 60);
+add_task(function test_initialize_with_guest_rooms() {
+  Services.prefs.setBoolPref("loop.createdRoom", true);
   startTimerCalled = false;
 
   MozLoopService.initialize();
 
   Assert.equal(startTimerCalled, true,
-    "should start the timer when expiry time is in the future");
+    "should start the timer when guest rooms have been created");
 });
 
 function run_test() {
   setupFakeLoopServer();
 
   // Override MozLoopService's initializeTimer, so that we can verify the timeout is called
   // correctly.
   MozLoopService.initializeTimerFunc = function() {
     startTimerCalled = true;
   };
 
+  do_register_cleanup(function() {
+    Services.prefs.clearUserPref("loop.createdRoom");
+  });
+
   run_next_test();
 }
--- a/browser/components/loop/test/xpcshell/test_loopservice_notification.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_notification.js
@@ -7,23 +7,23 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 
 let openChatOrig = Chat.open;
 
 add_test(function test_openChatWindow_on_notification() {
   Services.prefs.setCharPref("loop.seenToS", "unseen");
 
   mockPushHandler.registrationPushURL = kEndPointUrl;
 
-  MozLoopService.promiseRegisteredWithServers().then(() => {
+  MozLoopService.promiseRegisteredWithServers(LOOP_SESSION_TYPE.FXA).then(() => {
     let opened = false;
     Chat.open = function() {
       opened = true;
     };
 
-    mockPushHandler.notify(1, MozLoopService.channelIDs.callsGuest);
+    mockPushHandler.notify(1, MozLoopService.channelIDs.callsFxA);
 
     waitForCondition(function() opened).then(() => {
       do_check_true(opened, "should open a chat window");
 
       do_check_eq(Services.prefs.getCharPref("loop.seenToS"), "seen",
                   "should set the pref to 'seen'");
 
       run_next_test();
@@ -32,16 +32,18 @@ add_test(function test_openChatWindow_on
     });
 
   });
 });
 
 function run_test() {
   setupFakeLoopServer();
 
+  setupFakeFxAUserProfile();
+
   loopServer.registerPathHandler("/registration", (request, response) => {
     response.setStatusLine(null, 200, "OK");
     response.processAsync();
     response.finish();
   });
   loopServer.registerPathHandler("/calls", (request, response) => {
     response.setStatusLine(null, 200, "OK");
     response.write(JSON.stringify({calls: [{callId: 4444333221, websocketToken: "0deadbeef0"}]}));
--- a/browser/components/loop/test/xpcshell/test_loopservice_registration_retry.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_registration_retry.js
@@ -54,18 +54,17 @@ function run_test() {
     if (data.simplePushURLs.rooms) {
       Assert.equal(data.simplePushURLs.rooms, kEndPointUrl,
                    "Should send correct rooms push url");
     }
 
     response.setStatusLine(null, 200, "OK");
   });
 
-  let nowSeconds = Date.now() / 1000;
-  Services.prefs.setIntPref("loop.urlsExpiryTimeSeconds", nowSeconds + 60);
+  Services.prefs.setBoolPref("loop.createdRoom", true);
 
   do_register_cleanup(function() {
     Services.prefs.clearUserPref("loop.hawk-session-token");
-    Services.prefs.clearUserPref("loop.urlsExpiryTimeSeconds");
+    Services.prefs.clearUserPref("loop.createdRoom");
   });
 
   run_next_test();
 }
--- a/browser/components/loop/test/xpcshell/test_loopservice_restart.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_restart.js
@@ -8,39 +8,39 @@ const FAKE_FXA_TOKEN_DATA = JSON.stringi
 });
 const FAKE_FXA_PROFILE = JSON.stringify({
   "email": "test@example.com",
   "uid": "999999994d9f4b08a2cbfc0999999999",
   "avatar": null
 });
 const LOOP_FXA_TOKEN_PREF = "loop.fxa_oauth.tokendata";
 const LOOP_FXA_PROFILE_PREF = "loop.fxa_oauth.profile";
-const LOOP_URL_EXPIRY_PREF = "loop.urlsExpiryTimeSeconds";
+const LOOP_CREATED_ROOM_PREF = "loop.createdRoom";
 const LOOP_INITIAL_DELAY_PREF = "loop.initialDelay";
 
 /**
  * This file is to test restart+reauth.
  */
 
-add_task(function test_initialize_with_expired_urls_and_no_auth_token() {
+add_task(function test_initialize_with_no_guest_rooms_and_no_auth_token() {
   // Set time to be 2 seconds in the past.
   var nowSeconds = Date.now() / 1000;
-  Services.prefs.setIntPref(LOOP_URL_EXPIRY_PREF, nowSeconds - 2);
+  Services.prefs.setBoolPref(LOOP_CREATED_ROOM_PREF, false);
   Services.prefs.clearUserPref(LOOP_FXA_TOKEN_PREF);
 
   yield MozLoopService.initialize().then((msg) => {
     Assert.equal(msg, "registration not needed", "Initialize should not register when the " +
                                                  "URLs are expired and there are no auth tokens");
   }, (error) => {
     Assert.ok(false, error, "should have resolved the promise that initialize returned");
   });
 });
 
-add_task(function test_initialize_with_urls_and_no_auth_token() {
-  Services.prefs.setIntPref(LOOP_URL_EXPIRY_PREF, Date.now() / 1000 + 10);
+add_task(function test_initialize_with_created_room_and_no_auth_token() {
+  Services.prefs.setBoolPref(LOOP_CREATED_ROOM_PREF, true);
   Services.prefs.clearUserPref(LOOP_FXA_TOKEN_PREF);
 
   loopServer.registerPathHandler("/registration", (request, response) => {
     response.setStatusLine(null, 200, "OK");
   });
 
   yield MozLoopService.initialize().then((msg) => {
     Assert.equal(msg, "initialized without FxA status", "Initialize should register as a " +
@@ -109,13 +109,13 @@ function run_test() {
   MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
   mockPushHandler.registrationPushURL = kEndPointUrl;
 
   do_register_cleanup(function() {
     MozLoopServiceInternal.mocks.pushHandler = undefined;
     Services.prefs.clearUserPref(LOOP_INITIAL_DELAY_PREF);
     Services.prefs.clearUserPref(LOOP_FXA_TOKEN_PREF);
     Services.prefs.clearUserPref(LOOP_FXA_PROFILE_PREF);
-    Services.prefs.clearUserPref(LOOP_URL_EXPIRY_PREF);
+    Services.prefs.clearUserPref(LOOP_CREATED_ROOM_PREF);
   });
 
   run_next_test();
 };
--- a/browser/components/loop/test/xpcshell/test_loopservice_token_invalid.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_token_invalid.js
@@ -29,17 +29,17 @@ add_test(function test_registration_inva
     }
     response.processAsync();
     response.finish();
   });
 
   MozLoopService.promiseRegisteredWithServers().then(() => {
     // Due to the way the time stamp checking code works in hawkclient, we expect a couple
     // of authorization requests before we reset the token.
-    Assert.equal(authorizationAttempts, 4); //hawk will repeat each registration attemtp twice: calls and rooms.
+    Assert.equal(authorizationAttempts, 2); // Hawk will repeat the registration attempt twice.
     Assert.equal(Services.prefs.getCharPref(LOOP_HAWK_PREF), fakeSessionToken2);
     run_next_test();
   }, err => {
     do_throw("shouldn't be a failure result: " + err);
   });
 });