Closed
Bug 964769
Opened 11 years ago
Closed 11 years ago
Not able to access navigator.mozSetMessageHandler() from the test script without UI
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
INVALID
blocking-b2g | 1.4+ |
People
(Reporter: vasanth, Unassigned)
References
Details
Objective is to receive the broadcast message [1] in a test script. Only way seems like using navigator.mozSetMessageHandler() with the broadcast message name. That returns following error when tried from marionette test script without UI. However the same script is able to access navigtor.mozMobileConnection, mozSettings etc., [JavaScript Error: "principal.URI is null" {file: "jar:file:///system/b2g/omni.ja!/components/SystemMessageManager.js" line: 256}] Why this error comes and how can we resolve this? [1] http://dxr.mozilla.org/mozilla-central/source/dom/messages/interfaces/nsISystemMessagesInternal.idl#34
Blocks: b2g--telephony-1.4
No longer blocks: b2g--telephony-1.4
Comment 1•11 years ago
|
||
(In reply to vasanth from comment #0) > Objective is to receive the broadcast message [1] in a test script. > Only way seems like using navigator.mozSetMessageHandler() with the > broadcast message name. > > That returns following error when tried from marionette test script without > UI. > However the same script is able to access navigtor.mozMobileConnection, > mozSettings etc., > > [JavaScript Error: "principal.URI is null" {file: > "jar:file:///system/b2g/omni.ja!/components/SystemMessageManager.js" line: > 256}] > > Why this error comes and how can we resolve this? > > [1] > http://dxr.mozilla.org/mozilla-central/source/dom/messages/interfaces/ > nsISystemMessagesInternal.idl#34 Hi vasanth, May I know how you ran your marionette test script and what system message you expect to receive? I tried on my desktop (call navigator.mozSetMessageHandler) and got no error like you said. Thanks.
Updated•11 years ago
|
Component: General → DOM: Device Interfaces
Product: Firefox OS → Core
Comment 3•11 years ago
|
||
Why are we blocking on a testing enhancement? That seems a bit strange to me that this is a FC blocker.
Flags: needinfo?(mvines)
Comment 4•11 years ago
|
||
(In reply to Henry Chang [:henry] from comment #1) @henry What Vasanth means is that the tests are running in the chrome context ie. MARIONETTE_CONTEXT = 'chrome';
Comment 5•11 years ago
|
||
(In reply to Jason Smith [:jsmith] from comment #3) > Why are we blocking on a testing enhancement? That seems a bit strange to me > that this is a FC blocker. This issue is blocking some of our FC test execution.
Flags: needinfo?(mvines)
(In reply to Henry Chang [:henry] from comment #1) > May I know how you ran your marionette test script and what system message > you expect to receive? I tried on my desktop (call > navigator.mozSetMessageHandler) > and got no error like you said. My marionette script is something like this [1] I was expecting a system message something like this [2] I guess these scripts cannot access Gaia apps/UI. But from error message, it seems an URI is needed to deliver system message?[3] Can you share yours if its able to get system message [2] in marionette script like [1] (chrome context)? [1] http://dxr.mozilla.org/mozilla-central/source/dom/system/gonk/tests [2] https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/carrier_info_notifier.js#L11 [3] http://dxr.mozilla.org/mozilla-central/source/dom/messages/SystemMessageManager.js#255
Comment 7•11 years ago
|
||
Hi vasanth, From what I know and the implementation, system message does require an URL as an identifier to deliver messages. Needinfo Gene to make sure if it's by design. If you want test mixing content and chrome context, you might need to use gaia-ui-test, which lets you write python test script with marionette capabilities and switch chrome/content back and forth. (In reply to vasanth from comment #6) > (In reply to Henry Chang [:henry] from comment #1) > > May I know how you ran your marionette test script and what system message > > you expect to receive? I tried on my desktop (call > > navigator.mozSetMessageHandler) > > and got no error like you said. > > My marionette script is something like this [1] > I was expecting a system message something like this [2] > I guess these scripts cannot access Gaia apps/UI. But from error message, it > seems an URI is needed > to deliver system message?[3] > Can you share yours if its able to get system message [2] in marionette > script like [1] (chrome context)? > > [1] http://dxr.mozilla.org/mozilla-central/source/dom/system/gonk/tests > [2] > https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/ > carrier_info_notifier.js#L11 > [3] > http://dxr.mozilla.org/mozilla-central/source/dom/messages/ > SystemMessageManager.js#255
Flags: needinfo?(gene.lian)
Comment 8•11 years ago
|
||
Henri is correct, we need the page URI to register message handlers. I you want pure chrome tests (why? it's a web page API), you will need to "mock" the content side in some way.
Comment 9•11 years ago
|
||
Running in the chrome context, among other things, allows us to interact with web APIs without obscuring the screen with a test page. How can we go about creating mock content?
Comment 12•11 years ago
|
||
(In reply to Fabrice DesrΓ© [:fabrice] from comment #8) > Henri is correct, we need the page URI to register message handlers. I you > want pure chrome tests (why? it's a web page API), you will need to "mock" > the content side in some way. Fabrice, can you point us to an example of creating mock content?
Comment 13•11 years ago
|
||
I don't have any to show... mocking the full window object is no small task. If you are only interested in testing message broadcasting, you could make it so we don't throw at https://mxr.mozilla.org/mozilla-central/source/dom/messages/SystemMessageManager.js#255 and keep an undefined _uri. That should be enough for broadcastMessage(), but not for sendMessage()
Updated•11 years ago
|
Flags: needinfo?(gene.lian)
Reporter | ||
Comment 14•11 years ago
|
||
(In reply to Fabrice DesrΓ© [:fabrice] from comment #13) > If you are only interested in testing message broadcasting, you could make > it so we don't throw at > https://mxr.mozilla.org/mozilla-central/source/dom/messages/ > SystemMessageManager.js#255 and keep an undefined _uri. That should be > enough for broadcastMessage(), but not for sendMessage() Hi Fabrice, Our intention is to receive the broadcast message in test script like [1] I see _uri is a property in SystemMessageManager and as of now test script doesn't access SystemMessageManager similar to [1] Could you be more specific what exactly we can add in test script so we can avoid this error? [1] https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/carrier_info_notifier.js#L11
Flags: needinfo?(mschwart) → needinfo?(fabrice)
Comment 15•11 years ago
|
||
You need to patch SystemMessageManager.js to make it not fail in the case where _uri is undefined or null. Probably as simple as: this._uri = principal.URI ? principal.URI.spec : null; instead of https://mxr.mozilla.org/mozilla-central/source/dom/messages/SystemMessageManager.js#255 should work.
Flags: needinfo?(fabrice)
Comment 16•11 years ago
|
||
Vasanth Please review if we need anything else from MOZ
Flags: needinfo?(vasanth)
Reporter | ||
Comment 17•11 years ago
|
||
With Fabrice's suggestion, script doesn't throw error. But still we don't receive the broadcast message. Will debug and update here.
Reporter | ||
Comment 18•11 years ago
|
||
With Fabrice's suggestion, setting mozSetMessageHandler() bails out here [1] since uri and manifest are null. Now I do realize this api needs a manifest uri/page to deliver the messages. BTW, why the test script is not able to make use of current document's page uri and manifest? [1] http://dxr.mozilla.org/mozilla-central/source/dom/messages/SystemMessageInternal.js#412
Flags: needinfo?(vasanth)
Comment 19•11 years ago
|
||
Vasanth, who is your question directed to? Please add ni to get quick response.
Flags: needinfo?(vasanth)
Reporter | ||
Comment 20•11 years ago
|
||
Henry, I guess you might know the answer? Please move to the correct person if I'm wrong
Flags: needinfo?(vasanth) → needinfo?(hchang)
Comment 21•11 years ago
|
||
(In reply to vasanth from comment #20) > Henry, I guess you might know the answer? Please move to the correct person > if I'm wrong Hi Vasanth, That's because your marionette script will be running in the chrome context, which means your script is running in neither system app nor any of other apps. Is there any chance to run your script in the content context? Thanks!
Flags: needinfo?(hchang)
Comment 23•11 years ago
|
||
I'm just going to set ni on Vasanth so it's clear what the status here is.
Flags: needinfo?(vasanth)
Reporter | ||
Comment 24•11 years ago
|
||
I see navigator.mozSetMessageHandler() (or any UI dependent APIs) is not supported in chrome based tests. That makes this bug invalid. Is there somewhere it is documented? So next time we won't try this way. Closing this.
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(vasanth)
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•