Absolute path to the jsbridge XULRunner extension directory.
This should be used by mozrunner when starting XULRunner applications:
import mozrunner
profile = mozrunner.FirefoxProfile(plugins=[jsbridge.extension_path])
runner = mozrunner.FirefoxRunner(profile=profile, cmdargs=["-jsbridge", "24242"])
runner.start()
Returns a BackChannel instance and a Bridge instance for the given host and port configuration:
back_channel, bridge = create_network("127.0.0.1", 24242)
Wait for the the given host/port to become available for connection or timeout and then run create_network().
host and port are the values to be passed to create_network().
Default timeout is 10. timeout defines wait threshold in seconds.
Python to JavaScript TCP interface.
Back channel callback TCP interface.
host and port are string and integer values respectively.
Add listener for events of a specified uuid or eventType.
Any callable() can be used for callback argument. Should accept a single argument the result object.
Callbacks can be specific to an individual event uuid or to all events of a given eventType.
Add a listener to all events.
Any callable() can be used as callback, should accept two positional arguments; eventType and result.
Python representation of a live JavaScript object.
Requires an instance of Bridge and a str() of JavaScript to resolve the object on the other side of the bridge.
Once you have a JSObject instance you can treat it like a normal Python object and all attribute set/get operations and function calls will happen seamlessly through the bridge:
>>> runner.start() >>> back_channel, bridge = wait_and_create_network("127.0.0.1", 24242)>>> window_string = "Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('')" >>> browser_window = JSObject(bridge, window_string) >>> browser_window.title u"Welcome to Firefox" >>> browser_window.title = "Remember; no matter where you go, there you are. - B. Banzai"
Command Line Interface.
Inherits from mozrunner.CLI and overrides relevant methods to start jsbridge.
Also adds new command line options to for Python shell and debug modes.
Starting jsbridge in your own script:
import mozrunner
import jsbridge
profile = mozrunner.FirefoxProfile(plugins=[jsbridge.extension_path])
runner = mozrunner.FirefoxRunner(profile=profile, cmdargs=["-jsbridge", "24242"])
runner.start()
back_channel, bridge = wait_and_create_network("127.0.0.1", 24242)