[tor-dev] How to run a headless second Firefox instance?

David Fifield david at bamsoftware.com
Thu Apr 10 15:25:04 UTC 2014


On Tue, Apr 08, 2014 at 11:29:25PM -0700, David Fifield wrote:
> We talked a while ago about using a browser extension to make HTTPS
> requests on behalf of a pluggable transport, so that the TLS doesn't
> stand out as unusual (#11183). I have that working pretty well and you
> can try it out. Using these bundles, you can run the meek pluggable
> transport and the TLS layer looks just like Firefox, because it is
> Firefox.
> 
> https://trac.torproject.org/projects/tor/ticket/11183#comment:16
> https://people.torproject.org/~dcf/pt-bundle/3.5.2.1-meek-5/
> 
> What I need some advice on: In order to prevent a browser window from
> opening in the second instance of firefox, the helper extension opens a
> modal dialog and never returns. If the dialog is ever closed, the whole
> browser is shut down. It looks like this (https://gitweb.torproject.org/pluggable-transports/meek.git/blob/d2de8adc0641a3bc021f905740a1bf2b6b7ee720:/firefox/components/main.js#l58):
>         try {
>             // Block forever.
>             var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
>                 .getService(Components.interfaces.nsIPromptService);
>             prompts.confirm(null, "Query", "Get down, get funky?");
>         } finally {
>             var app = Components.classes["@mozilla.org/toolkit/app-startup;1"]
>                 .getService(Components.interfaces.nsIAppStartup);
>             app.quit(app.eForceQuit);
>         }
> It gets the job done, but it sucks because the first thing you see is
> the dialog and you have to know not to close it. Is there a way to
> accomplish the same thing (keep the browser running, but don't show a
> browser window) without raising a conspicuous dialog?

I found this trick that seems to work:
            // Block forever.
            // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Threads#Waiting_for_a_background_task_to_complete
            var thread = Components.classes["@mozilla.org/thread-manager;1"].getService().currentThread;
            while (true)
                thread.processNextEvent(true);
It prevents any window from being opened for the second browser
instance. On Windows you don't get a second icon in the taskbar. On OS X
you do get a second icon (which is #11429), but I didn't see a way to
get the icon to open a window.

David Fifield


More information about the tor-dev mailing list