Subj : Re: Mozilla javascript context? To : Howard Chu From : Brendan Eich Date : Sun Jun 27 2004 09:02 pm Howard Chu wrote: > In older versions of Netscape (4.x, judging from available docs) there > was support for writing message filters in Javascript. This support was > removed subsequently. I'm interested in adding something like it back > in, but I don't really have any idea where to begin. The XPConnect docs > and JSAPI docs seem to be aimed at writing a standalone app that uses > JavaScript, how to setup the runtime etc. But obviously Mozilla has > already got a runtime and several contexts set up. Wouldn't it be smart > to just grab an existing context for this purpose? How would you do it? You should ask over in n.p.m.mail-news too. Make a fresh context for any JS mail filters; there's no compelling reason to reuse one that I can see, and a few unlikely but real hazards if you do. To get the runtime used by XPConnect, use JSRuntime *rt = nsnull; nsCOMPtr rtsvc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1"); if (rtsvc) rtsvc->GetRuntime(&rt); if (rt) { . . . } /be .