thanks, Malini. That is what I was looking for. I am using Python as the
client.
As a followup question: for <code to trigger event> I need to telnet
into our NFC daemon process. I managed to do this in Python but then I
have to do this in a thread with a sleep since execute_async_script is
blocking. In Python I do:
nfcd = Telnet('localhost',1234)
nfcd.write("...")
How can I do the same in JS in <code to trigger event>?
TIA,
Arno
On 4/2/13 10:57 AM, Malini Das wrote:
On 2013-04-01 8:47 PM, Arno Puder wrote:
Hi,
I'm working on the NFC sub-system and need some insight into Marionette.
I get as far as injecting a test case into our NFC daemon. The way a
(privileged) application registers for NFC events is via:
navigator.mozNfc.onndefdiscovered = function(event) {...};
I need to get hold of 'event'. How can I do that? I guess I want to
temporarily store 'event' somewhere so I can read it with Marionette
after a short delay.
TIA,
Arno
Oh, I accidentally sent a personal response instead of answering in
thread. If anyone else has a similar issue, this was what answered
Arno's question:
It's not clear by your explanation how you're invoking marionette, but
if you want to inspect event and you're using the python client, you can
do something like this:
received_event = execute_async_script("navigator.mozNfc.onndefdiscovered
= function(event) { marionetteScriptFinished(event);}; <code to trigger
event>")
The marionetteScriptFinished call is what will return the event to you
after it is triggered. There is a timeout period, so if
marionetteScriptFinished isn't called after the timeout, the function
will throw an error. The default timeout is 10seconds, but you can
change it by calling set_script_timeout(<timeout in ms>) before the
execute_async_script call.
If this isn't what you need, and if you need to persist globals for any
other reason and you're using execute_script or execute_async_script in
python, you can persist variables as detailed here
https://developer.mozilla.org/en-US/docs/Marionette/Marionette#execute_script()
if you set new_sandbox to False. If not, you can still persist variables
by adding them to the window object.
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g