From e5afb9024730534297a9e259898a98193ba8eae8 Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Mon, 6 Oct 2014 15:36:07 -0700 Subject: [PATCH] Bug 1078261 - Don't fetch Loop call data for the FxA session if we aren't logged in. r=pkerr --HG-- extra : rebase_source : e9dc9ddfa4c62254801889275c3fe46121036655 --- browser/components/loop/MozLoopService.jsm | 4 +++- .../components/loop/test/xpcshell/test_loopservice_busy.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/browser/components/loop/MozLoopService.jsm b/browser/components/loop/MozLoopService.jsm index 161a8a8f2bb..52f9a834e46 100644 --- a/browser/components/loop/MozLoopService.jsm +++ b/browser/components/loop/MozLoopService.jsm @@ -677,7 +677,9 @@ let MozLoopServiceInternal = { // Make the call to get the GUEST session regardless of whether the FXA // request fails. - this._getCalls(LOOP_SESSION_TYPE.FXA, version).catch(() => {}); + if (MozLoopService.userProfile) { + this._getCalls(LOOP_SESSION_TYPE.FXA, version).catch(() => {}); + } this._getCalls(LOOP_SESSION_TYPE.GUEST, version).catch( error => {this._hawkRequestError(error);}); }, diff --git a/browser/components/loop/test/xpcshell/test_loopservice_busy.js b/browser/components/loop/test/xpcshell/test_loopservice_busy.js index d0efa8204c7..3d067991cbd 100644 --- a/browser/components/loop/test/xpcshell/test_loopservice_busy.js +++ b/browser/components/loop/test/xpcshell/test_loopservice_busy.js @@ -52,6 +52,10 @@ function run_test() { setupFakeLoopServer(); + // Setup fake login (profile) state so we get FxA requests. + const serviceGlobal = Cu.import("resource:///modules/loop/MozLoopService.jsm", {}); + serviceGlobal.gFxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"}; + // 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 @@ -97,6 +101,9 @@ function run_test() // Revert original Chat.open implementation Chat.open = openChatOrig; + // Revert fake login state + serviceGlobal.gFxAOAuthProfile = null; + // clear test pref Services.prefs.clearUserPref("loop.seenToS"); });