From 8e0e7b5acd6fbd06c246637dba19e5cbe5640245 Mon Sep 17 00:00:00 2001 From: "silver%warwickcompsoc.co.uk" Date: Sat, 31 May 2008 23:10:26 +0000 Subject: [PATCH] Bug 435772 - Carefully avoid touching Java when figuring out our execution environment, to prevent the plugin from unnecessarily starting. ChatZilla only. r=gijs --- extensions/irc/js/lib/utils.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/extensions/irc/js/lib/utils.js b/extensions/irc/js/lib/utils.js index 3b29f49843c..4349a8b15a7 100644 --- a/extensions/irc/js/lib/utils.js +++ b/extensions/irc/js/lib/utils.js @@ -110,17 +110,25 @@ if (DEBUG) { } var jsenv = new Object(); +// Netscape/Mozilla security manager, for gaining priviledges with consent. jsenv.HAS_SECURITYMANAGER = ((typeof netscape == "object") && (typeof netscape.security == "object")); +// XPCOM, one of two socket implementation providers. jsenv.HAS_XPCOM = ((typeof Components == "object") && - (typeof Components.classes == "object")); -jsenv.HAS_JAVA = (typeof java == "object"); -jsenv.HAS_RHINO = (typeof defineClass == "function"); -jsenv.HAS_DOCUMENT = (typeof document == "object"); -jsenv.HAS_NSPR_EVENTQ = jsenv.HAS_DOCUMENT; -jsenv.HAS_STREAM_PROVIDER = ("nsIStreamProvider" in Components.interfaces); -jsenv.HAS_SERVER_SOCKETS = ("nsIServerSocket" in Components.interfaces); -jsenv.HAS_THREAD_MANAGER = ("nsIThreadManager" in Components.interfaces); + (typeof Components.classes == "object") && + (typeof Components.interfaces == "object")); +// Rhino (JS-in-Java), the other socket implementation provider. +// XXX Bug 435772 - we avoid any Java tests if we have XPCOM so as to avoid +// the Java plugin instanciating itself to answer our query. +jsenv.HAS_RHINO = !jsenv.HAS_XPCOM && (typeof defineClass == "function"); +// NSPR Event Queue, i.e. we're living in a browser/GUI-like place. +jsenv.HAS_NSPR_EVENTQ = (typeof document == "object"); +// Specific XPCOM interfaces that we really care about. +var ci = jsenv.HAS_XPCOM ? Components.interfaces : {}; +jsenv.HAS_STREAM_PROVIDER = ("nsIStreamProvider" in ci); +jsenv.HAS_SERVER_SOCKETS = ("nsIServerSocket" in ci); +jsenv.HAS_THREAD_MANAGER = ("nsIThreadManager" in ci); +delete ci; function dumpObject (o, pfx, sep) {