bard/mozrepl — Issue #23: Connect fails under OS X when no top-level window open
Author: dcolascione
Created: 2011-11-14 06:05:53+00:00
State: open

diff --git a/chrome/content/server.js b/chrome/content/server.js
index fdfa2a8..cdbbf63 100644
--- a/chrome/content/server.js
+++ b/chrome/content/server.js
@@ -121,6 +121,13 @@ function onSocketAccepted(serv, transport) {
.getService(Ci.nsIWindowMediator)
.getMostRecentWindow(typeof(contextWindowType) !== 'undefined' ?
contextWindowType : pref.getCharPref('startingContext'));
+
+ if(context === null) {
+ context = Cc["@mozilla.org/appshell/appShellService;1"]
+ .getService(Ci.nsIAppShellService)
+ .hiddenDOMWindow.wrappedJSObject;
+ }
+
var session = new REPL();
session.onOutput = function(string) {
outstream.write(string, string.length);