Bug 435772 - Carefully avoid touching Java when figuring out our execution environment, to prevent the plugin from unnecessarily starting. ChatZilla only. r=gijs

This commit is contained in:
silver%warwickcompsoc.co.uk 2008-05-31 23:10:26 +00:00
Родитель 86256d2de6
Коммит 8e0e7b5acd
1 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -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)
{