def start_shell(self, runner): try: import IPython except: IPython = None if not hasattr(self, 'bridge'): self.start_jsbridge_network() jsobj = JSObject(self.bridge, window_string) if IPython is None or self.options.usecode: import code code.interact( local={ "jsobj": jsobj, "getBrowserWindow": lambda: getBrowserWindow(self.bridge), "back_channel": self.back_channel, }) else: from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed([]) ipshell( local_ns={ "jsobj": jsobj, "getBrowserWindow": lambda: getBrowserWindow(self.bridge), "back_channel": self.back_channel, }) runner.stop()
def getBrowserWindow(bridge): return JSObject( bridge, "Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator).getMostRecentWindow('')" )
def getBrowserWindow(bridge): return JSObject(bridge, "Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('')")