Closed Bug 1065153 Opened 11 years ago Closed 11 years ago

Get Call URLs with the proper Hawk session

Categories

(Hello (Loop) :: Client, defect)

defect
Not set
normal
Points:
2

Tracking

(firefox34 verified, firefox35 verified)

VERIFIED FIXED
mozilla35
Iteration:
35.2
Tracking Status
firefox34 --- verified
firefox35 --- verified

People

(Reporter: MattN, Assigned: dmosedale)

References

Details

(Whiteboard: [loop-uplift][fig:verified])

User Story

As a user, when I am signed-in, I should get a call-url associated with my account.
As a user, when I am signed-out, I should get a call-url associated with my browser.

Implementation:

- Determine if the user is logged in or not.
- When getting the call URL, specify the FXA session type if logged-in, otherwise specify the GUEST type.

Attachments

(1 file, 2 obsolete files)

After bug 1065052 lands, there are two hawk sessions in use when logged in. We need to make sure we use the proper session when a user is logged in so that call URLs are either associated with the guest device or with the account (and all devices on it). My understanding is that initially logged in users won't be able to choose to generate a URL for the guest session so I don't think UI needs to change. See the "sessionType" argument to hawkRequest.
Flags: qe-verify+
Flags: firefox-backlog+
No longer blocks: 1065052
Depends on: 1065052
> My understanding is that initially logged in users won't be able to choose to generate a URL for the guest session so I don't think UI needs to change. I totally agree, the point of keeping both session is to be able to receive calls from anonymously created URLs.
My point was more that we're not currently going to let logged in users decide (via UI) whether to generate a call URL for the anonymous session or the FxA session. If they are logged in, the call URL will always be for the FxA session, not the anonymous one.
Yes, I totally agree.
Without looking at if/how we delete call URLs: If we are persisting them for the history view, I guess we will need to also persist whether it was an anonymous or FxA URL. The other option is to just delete on both sessions so we don't have to persist that info.
Points: --- → 3
Ok, comment 5 was actually forgetting this bug was about getting & deleting, not just deleting. I'm going to move the delete part to bug 1065155 as delete is reasonably closely coupled with the conversation window at the moment, so I think it makes sense to do that together. I've updated the user story with what I think needs doing here.
Points: 3 → 2
User Story: (updated)
Summary: Get/delete Call URLs with the proper Hawk session → Get Call URLs with the proper Hawk session
Depends on: 1047146
Assignee: nobody → dmose
I've much of the code working and content side unit tests passing, and in theory it should work. Except it has regressed the one functional test ("make a call"), so I need to figure out what's going on. I've made it possible to do xpcshell tests on at least pieces of MozLoopAPI.jsm and LoopStorage.jsm, and I'm about half done with writing unit tests for the browser-side changes as well.
I'm a bit surprised you needed xpcshell tests for MozLoopAPI, when we're already testing that in Mochitest. However, I won't object, though we might want to consider keeping those mainly in one place.
Comment on attachment 8489732 [details] [diff] [review] Auto-select and pass correct hawk sessionType through hawkRequest, WIP v1 This patch makes mozLoop.hawkRequest pass a sessionType variable, and I suspect that code works. It's based on top of jaws rebased patch bug 1047146. I've done some tweaking to make it possible to test MozLoopAPI using XPCShell, and I'm trying to get it to test accessing the mozLoop.LOOP_SESSION_TYPE values. I can make the tests session LOOP_SESSION_TYPE itself, but, interestingly enough, none of the properties. Turning on xrays doesn't seem to help. Could you take a look at this and see if you can see what I'm missing? I'm happy to pair on it over Skype or Hangouts, if you wish. Thanks!
Attachment #8489732 - Flags: feedback?(MattN+bmo)
To be more specific, when running "mach xpcshell-test --sequential browser/components/loop/test/xpcshell" The Assert on line 20 of test_loopapi_hawk_request passes, but the Assert on line 24 fails with this message: 0:04.44 TEST-UNEXPECTED-FAIL | /Users/dmose/r/gecko-dev/obj-x86_64-apple-darwin13.3.0/_tests/xpcshell/browser/components/loop/test/xpcshell/test_loopapi_hawk_request.js | "undefined" == 1 - See following stack: 0:04.44 /Users/dmose/r/gecko-dev/obj-x86_64-apple-darwin13.3.0/_tests/xpcshell/browser/components/loop/test/xpcshell/test_loopapi_hawk_request.js:hawk_session_scope_constants:24 0:04.44 _run_next_test@/Users/dmose/r/gecko-dev/testing/xpcshell/head.js:1308:9 0:04.44 do_execute_soon/<.run@/Users/dmose/r/gecko-dev/testing/xpcshell/head.js:570:9 0:04.44 _do_main@/Users/dmose/r/gecko-dev/testing/xpcshell/head.js:191:5 0:04.44 _execute_test@/Users/dmose/r/gecko-dev/testing/xpcshell/head.js:405:5 0:04.44 @-e:1:1
Comment on attachment 8489732 [details] [diff] [review] Auto-select and pass correct hawk sessionType through hawkRequest, WIP v1 Standard8 has led me to see the error of my ways. New patch soonish... :-)
Attachment #8489732 - Flags: feedback?(MattN+bmo)
This will fix it: LOOP_SESSION_TYPE: { enumerable: true, - value: function() { - var contentObj = Cu.cloneInto({GUEST: 1, FXA: 2}, targetWindow); + get: function() { + let contentObj = Cu.cloneInto(LOOP_SESSION_TYPE, targetWindow); return contentObj; }, }, It was a stupid mistake on my part since there was no consumer of the getter. I figured it out when I saw that typeof was outputting "function" and then I looked at the result of toSource() and saw the body of the "value" function above. Note I also changed |var| to |let| and referenced the original const again. Other feedback: * Use JS default argument syntax for keepUnsealedForTesting: "…, keepUnsealedForTesting = false)"
Attachment #8489732 - Attachment is obsolete: true
Attachment #8491081 - Flags: review?(MattN+bmo)
Comment on attachment 8491081 [details] [diff] [review] Support call URLs with both guest and FxA hawk session types Review of attachment 8491081 [details] [diff] [review]: ----------------------------------------------------------------- r=me with comments Woohoo! ::: browser/components/loop/LoopStorage.jsm @@ +10,5 @@ > + Cu.importGlobalProperties(["indexedDB"]); > +} catch (ex) { > + if (typeof window !== 'undefined' && "console" in window) { > + console.log("Failed to import indexedDB; if this isn't a unit test," + > + " something is wrong", ex); This is kinda gross. Cu.reportError would allow you to avoid the window and console checks. ::: browser/components/loop/content/js/client.js @@ +109,5 @@ > */ > _requestCallUrlInternal: function(nickname, cb) { > + var sessionType; > + if (!this.mozLoop.userProfile) { > + console.log("this.mozLoop.LOOP_SESSION_TYPE: ", Nit: I would remove the ! and reverse the two bodies just to avoid the negation @@ +110,5 @@ > _requestCallUrlInternal: function(nickname, cb) { > + var sessionType; > + if (!this.mozLoop.userProfile) { > + console.log("this.mozLoop.LOOP_SESSION_TYPE: ", > + this.mozLoop.LOOP_SESSION_TYPE); I'm guessing the console.log was just leftover from debugging. @@ +154,5 @@ > }.bind(this)); > }, > > _deleteCallUrlInternal: function(token, cb) { > + this.mozLoop.hawkRequest(this.mozLoop.LOOP_SESSION_TYPE.GUEST, Add XXX with a bug #? @@ +156,5 @@ > > _deleteCallUrlInternal: function(token, cb) { > + this.mozLoop.hawkRequest(this.mozLoop.LOOP_SESSION_TYPE.GUEST, > + "/call-url/" + token, "DELETE", null, function (error, responseText) { > + if (error) { Nit: the previous indentation aligning arguments on a new line with the first argument is more readable IMO. Nit: The inline function should probably be defined at the top of _deleteCallUrlInternal and referenced by name since it's so long and makes this hard to read. ::: browser/components/loop/test/xpcshell/test_loopapi_hawk_request.js @@ +1,5 @@ > +/* Any copyright is dedicated to the Public Domain. > + http://creativecommons.org/publicdomain/zero/1.0/ */ > + > +/** > + * Test the toolbar button states. Stale description @@ +67,5 @@ > +}); > + > +function run_test() > +{ > + run_next_test(); Nit: brace on the same line
Attachment #8491081 - Flags: review?(MattN+bmo) → review+
(In reply to Matthew N. [:MattN] from comment #15) > r=me with comments > > Woohoo! > Thanks for the quick review and encouragement! > ::: browser/components/loop/LoopStorage.jsm > @@ +10,5 @@ > > + Cu.importGlobalProperties(["indexedDB"]); > > +} catch (ex) { > > + if (typeof window !== 'undefined' && "console" in window) { > > + console.log("Failed to import indexedDB; if this isn't a unit test," + > > + " something is wrong", ex); > > This is kinda gross. > Cu.reportError would allow you to avoid the window and console checks. Comment added instead, as per IRC discussion. > ::: browser/components/loop/content/js/client.js > @@ +109,5 @@ > > */ > > _requestCallUrlInternal: function(nickname, cb) { > > + var sessionType; > > + if (!this.mozLoop.userProfile) { > > + console.log("this.mozLoop.LOOP_SESSION_TYPE: ", > > Nit: I would remove the ! and reverse the two bodies just to avoid the > negation > > @@ +110,5 @@ > > _requestCallUrlInternal: function(nickname, cb) { > > + var sessionType; > > + if (!this.mozLoop.userProfile) { > > + console.log("this.mozLoop.LOOP_SESSION_TYPE: ", > > + this.mozLoop.LOOP_SESSION_TYPE); > > I'm guessing the console.log was just leftover from debugging. Good catches, both. Fixed. All remaining nits fixed as well.
Comment on attachment 8491637 [details] [diff] [review] Support call URLs with guest or FxA hawk session types Review comments addressed; carrying forward r+.
Attachment #8491637 - Flags: review+
Adding [loop-uplift], as I'm sure we want to uplift the Fx Accounts stuff.
Whiteboard: [loop-uplift]
Status: NEW → ASSIGNED
Flags: in-testsuite+
Whiteboard: [loop-uplift] → [loop-uplift][fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [loop-uplift][fixed-in-fx-team] → [loop-uplift]
Target Milestone: --- → mozilla35
Iteration: --- → 35.2
Matt, I'm unclear how to test this using the latest Nightly. Can you please clarify steps to reproduce?
Flags: needinfo?(MattN+bmo)
Two aspects to test which require 2 profiles: A) Verify that an FxA call URL is generated when logged in: 1) Login with FxA on profile A 2) Login with FxA on profile B 3) Copy (FxA) call URL from profile A. 4) Logout in profile A. 5) Load the call URL and initiate the call. Expected result: * The call should ring on profile B but not on profile A. B) Verify that a non-FxA call URL is generated when logged out: 1) Login with FxA on profile A 2) Login with FxA on profile B 3) Logout on profile A. 4) Close the panel (this is a workaround for bug 1069750) on profile A. 5) Open the panel and copy the (non-FxA) call URL on profile A. 6) Load the call URL and initiate the call. Expected result: * The call should ring on profile A but not on profile B.
Flags: needinfo?(MattN+bmo)
Thanks Matt. Paul, can you please test this in the latest Nightly as per Matt's instructions?
Flags: needinfo?(paul.silaghi)
QA Contact: anthony.s.hughes → paul.silaghi
Whiteboard: [loop-uplift] → [loop-uplift][fig:verifyme]
Status: RESOLVED → VERIFIED
Flags: needinfo?(paul.silaghi)
Whiteboard: [loop-uplift][fig:verifyme] → [loop-uplift][fig:verified]
Comment on attachment 8491637 [details] [diff] [review] Support call URLs with guest or FxA hawk session types Approval Request Comment Uplift request for patches staged and tested on Fig
Attachment #8491637 - Flags: approval-mozilla-aurora?
Comment on attachment 8491637 [details] [diff] [review] Support call URLs with guest or FxA hawk session types I worked with Randell and Maire on uplifting a large number of Loop bugs at once. All of the bugs have been staged on Fig and tested by QE before uplift to Aurora. As well, all of the bugs are isolated to the Loop client. Randell handled the uplift with my approval. I am adding approval to the bug after the fact for bookkeeping.
Attachment #8491637 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Flags: in-moztrap-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: