As far as I know the easiest way is to create a hiddenWindow, access its docshell and doing what ever wanted (no better way?).
Is there a XP way in doing that?
I tried this:
int main (int argc, char **argv)
{
nsresult rv;
rv = NS_InitEmbedding(nsnull, nsnull);
if(NS_FAILED(rv)) {
NS_ERROR("Could not init embedding");
NS_TermEmbedding();
return rv;
}nsCOMPtr<nsIAppShellService> appShellService(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService("@mozilla.org/appshell/commandLineService;1", &rv));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
cmdLineArgs->Initialize(argc, argv);
rv=appShellService->Initialize(cmdLineArgs, nsnull); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
appShellService->CreateHiddenWindow(); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIXULWindow> hiddenWindow; appShellService->GetHiddenWindow(getter_AddRefs(hiddenWindow)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> item; rv=hiddenWindow->GetPrimaryContentShell(getter_AddRefs(item)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> docshell(do_QueryInterface(item, &rv)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
... }
But the window has no content shell (GetPrimaryContentShell returns null) and using the XULWindow's top level docshell (tried a loadURI(...) to mozilla.org) loads the page (checked with tcpdump) but the the DOM does not contain the loaded document.
Any ideas?
Regards /Jeremias Reith
