Closed Bug 949242 Opened 12 years ago Closed 12 years ago

[inter-app-comm-api] Wrongly filters out messages when the page has a hash

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: kgrandon, Assigned: kgrandon)

References

Details

(Whiteboard: [c= p=2 s=2014.01.17 u=])

Attachments

(1 file, 3 obsolete files)

See: http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/InterAppMessagePort.js#192 When a page changes its hash value, it should still receive messages.
Attached patch naive-patch.patch (obsolete) — Splinter Review
There's probably a better way of doing this. Feel free to take this patch over if you'd like. Thanks.
Attachment #8346252 - Flags: feedback?(gene.lian)
Thanks Kevin for catching this. So, If we have two pages URL: app://pubApp.gaiamobile.org/handler.html?aaa app://pubApp.gaiamobile.org/handler.html?bbb and each of them hold a port waiting to receive message. Under this circumstance, the page ?aaa will receive the message that is supposed to be sent to ?bbb. It doesn't sound reasonable to me. Or these two pages ?aaa and ?bbb actually represent the *same* page in reality? If yes, I think I can then pass the review. :)
Flags: needinfo?(kgrandon)
Hi Fabrice, I'd like to ask one quick question: do we have any existing utility functions to remove the suffix of |?...| or |#...|? For example, app://pubApp.gaiamobile.org/handler.html?aaa -> app://pubApp.gaiamobile.org/handler.html app://pubApp.gaiamobile.org/handler.html#aaa -> app://pubApp.gaiamobile.org/handler.html
Flags: needinfo?(fabrice)
(In reply to Gene Lian [:gene] (needinfo? encouraged) from comment #2) > Or these two pages ?aaa and ?bbb actually represent the *same* page in > reality? If yes, I think I can then pass the review. :) Honestly I suppose it would be up to each application as to whether or not it would consider them a "page". After thinking about it, I suppose my recommendation here would be to actually stop using a string and use a regex pattern instead. This patch would be a larger change, and I'm not sure how to go about proposing it or making it. This is similar to how we filter in web activities, and may end up being more flexible. E.g.: "connections": { "my-connection": { "pattern": "/(foo|bar)\.html.*", "rules": {} } }
Flags: needinfo?(kgrandon)
(In reply to Gene Lian [:gene] (needinfo? encouraged) from comment #3) > Hi Fabrice, I'd like to ask one quick question: do we have any existing > utility functions to remove the suffix of |?...| or |#...|? For example, > > app://pubApp.gaiamobile.org/handler.html?aaa -> > app://pubApp.gaiamobile.org/handler.html > app://pubApp.gaiamobile.org/handler.html#aaa -> > app://pubApp.gaiamobile.org/handler.html Try nsIURI.ref http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIURI.idl#225
Yes, you can use URI.specIgnoringRef for the #, and probably just string search for "?". Another way may be to resolve "." against the current url, that should strip query parameters and ref.
Flags: needinfo?(fabrice)
Gene, Fabrice - What are your thoughts on using a pattern here instead (or in addition) to allow maximum flexibility for developers?
Flags: needinfo?(gene.lian)
Flags: needinfo?(fabrice)
(In reply to Kevin Grandon :kgrandon from comment #7) > Gene, Fabrice - > > What are your thoughts on using a pattern here instead (or in addition) to > allow maximum flexibility for developers? If you don't have a concrete use case that needs pattern, I'm very tempted to say "no"!
Flags: needinfo?(fabrice)
(In reply to Fabrice Desré [:fabrice] from comment #8) > (In reply to Kevin Grandon :kgrandon from comment #7) > If you don't have a concrete use case that needs pattern, I'm very tempted > to say "no"! Ok, then I suppose I would be happy if we just strip querystrings and hashes for now.
Flags: needinfo?(gene.lian)
Comment on attachment 8346252 [details] [diff] [review] naive-patch.patch Review of attachment 8346252 [details] [diff] [review]: ----------------------------------------------------------------- Hi Gene - Swapping this over to a review if you think this is good enough. I'm not really sure how to utilize specIgnoringRef, and I think that this is a pretty clean way of solving the problem. If you think that it would be better to explore using some other utility, we can certainly try.
Attachment #8346252 - Flags: feedback?(gene.lian) → review?(gene.lian)
Hi Kevin, could you please try uri.specIgnoringRef first to ignore the ref? I guess it's something like: uri = Services.io.newURI(pageURL, null, null); pageURL = uri.specIgnoringRef;
Attachment #8346252 - Flags: review?(gene.lian)
Potential new patch, testing it.
Assignee: nobody → kgrandon
Attachment #8346252 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Whiteboard: [c= p=2 s= u=]
Comment on attachment 8355237 [details] [diff] [review] Bug-949242-inter-app-comm-api-Wrongly-filters-out-me.patch Fabrice - maybe you could also review this one since Gene is out till the 7th?
Attachment #8355237 - Flags: review?(gene.lian)
Attachment #8355237 - Flags: review?(fabrice)
Comment on attachment 8355237 [details] [diff] [review] Bug-949242-inter-app-comm-api-Wrongly-filters-out-me.patch Review of attachment 8355237 [details] [diff] [review]: ----------------------------------------------------------------- lgtm, but I'm not very familiar with this api design. Fernando, can you take over Gene review? ::: dom/apps/src/InterAppMessagePort.js @@ +60,5 @@ > this._manifestURL = appsService.getManifestURLByLocalId(principal.appId); > + this._pageURL = principal.URI.specIgnoringRef; > + > + // Remove querystrings > + this._pageURL = this._pageURL.split('?')[0]; nit: strings use double quotes in this file.
Attachment #8355237 - Flags: review?(gene.lian)
Attachment #8355237 - Flags: review?(ferjmoreno)
Attachment #8355237 - Flags: review?(fabrice)
Attachment #8355237 - Flags: review+
Updating quote style.
Attachment #8355237 - Attachment is obsolete: true
Attachment #8355237 - Flags: review?(ferjmoreno)
Attachment #8355450 - Flags: review?(ferjmoreno)
Comment on attachment 8355450 [details] [diff] [review] Bug-949242-inter-app-comm-api-Wrongly-filters-out-me.patch Review of attachment 8355450 [details] [diff] [review]: ----------------------------------------------------------------- Thanks Kevin for the update and Fabrice for the first review. r=gene ::: dom/apps/src/InterAppMessagePort.js @@ +59,5 @@ > let principal = aWindow.document.nodePrincipal; > this._manifestURL = appsService.getManifestURLByLocalId(principal.appId); > + this._pageURL = principal.URI.specIgnoringRef; > + > + // Remove querystrings nit: comment format should be: //[one_space][upper_case_letter]...[one_period] so, this comment should be: // Remove query string. Note that I added one space between "query" and "string" as well because it's supposed to be separate in a formal definition [1]. [1] http://en.wikipedia.org/wiki/Query_string
Attachment #8355450 - Flags: review?(ferjmoreno) → review+
Attachment #8355450 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Whiteboard: [c= p=2 s= u=] → [c= p=2 s=2013.01.17 u=]
Gene - I also think it would be very important to follow-up with some unit test for this. I'm not too familiar with the best way to test gecko code - or what the best testing strategy here would be. Could you give me any pointers for looking at this?
Flags: needinfo?(gene.lian)
Whiteboard: [c= p=2 s=2013.01.17 u=] → [c= p=2 s=2014.01.17 u=]
(In reply to Kevin Grandon :kgrandon from comment #22) > Gene - I also think it would be very important to follow-up with some unit > test for this. I'm not too familiar with the best way to test gecko code - > or what the best testing strategy here would be. Could you give me any > pointers for looking at this? Yes. Bug 915884, which is almost done. Sorry that I'm too busy to keep working on that. Hope I can finish that this week.
Flags: needinfo?(gene.lian)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: