I'm narrowing my code's unhappiness with XPConnect down further. My html
example is now the one from the XPConnect Reference:
function evil() {
document.write("Asking security permission<br>");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var clazz = Components.classes['@mozilla.org/supports-array;1'];
dump(clazz);
dump("\n");
document.write("Got clazz by ID<br>");
var iid = Components.interfaces.nsISupportsArray;
dump("IID: ");
dump(iid);
dump("\n");
document.write("Got iid<br>");
var inst = clazz.createInstance();
dump("inst: ");
dump(inst);
dump("\n");
document.write("Got inst<br>");
}
which does exactly what's expected in TestGtkEmbed:
Class: @mozilla.org/supports-array;1
IID: nsISupportsArray
inst: [xpconnect wrapped nsISupports @ 0x82bb9b8]
plus all the garbage assertion failures (GetShellWidget() in nsWidget.cpp
line 3099; red herring).
So I try this in the following program (I wrote this to kill all the possible
functionality in my previous example; this is my "minimal mozilla embedding":
#include <gnome.h>
#include <gtkmozembed.h>
#include <stdio.h>
struct mozTest {
GtkWidget *app;
GtkWidget *mozEmbed;
mozTest();
};
mozTest::mozTest() {
app = gnome_app_new("MozTest","MozTest");
gtk_window_set_default_size((GtkWindow*)app, 500, 500);
gtk_signal_connect(GTK_OBJECT(app),
"delete_event",
GTK_SIGNAL_FUNC(gtk_main_quit),
NULL);
mozEmbed = gtk_moz_embed_new();
gnome_app_set_contents(GNOME_APP(app),mozEmbed);
gtk_widget_show_all(app);
printf("Loading the magic\n");
gtk_moz_embed_load_url((GtkMozEmbed*)mozEmbed,
"file:///home/aheitner/cvs/gnome_foo/test2.html");
}
int main(int argc, char **argv) {
gnome_init("moztest","0.1",argc,argv);
mozTest *m = new mozTest;
gtk_main();
return 0;
}
and ... the JS stops running after the securitypriviledge request. the
difference being that TestGtkEmbed is doing some magic to grok my personal
mozilla settings, and so the JS manages to set UniversalXPConnect without
prompting the user (whereas when I run it in my own tacky little embedding it
pops up a dialog asking permission to enable the priv).
Wish I knew why it fails right after that.
Chris, you'd make me real happy if you could give me a clue as to why this
is so unhappy. I *think* that the enable-priviledge magic broke somewhere
along the line (this worked fine with 0.7 and nightlies up thru january or
so). In a minute I'll coerce this thing into relinking against some old
mozillas and see wtf it does.
If I verify this i will file a bug :).
Cheers,
Ari Heitner