[Project_owners] Generating HTML DOM in xpcshell?

Samuel L. Bayer sam at mitre.org
Wed Mar 15 14:32:52 EST 2006


Hi all -

I posted this message to the jslib list, but perhaps this is a more 
appropriate place - I've also figured out more about what I'm trying to 
do since then.

I'd like to generate an HTML DOM from a URL. I'm using xpcshell, so I 
don't have a document object of any kind. (I'm using Seamonkey 1.0 on 
MacOS X 10.3.9, if it makes a difference.) I thought the following would 
work:

var domServ = 
Components.classes["@mozilla.org/content/syncload-dom-service;1"].getService(Components.interfaces.nsISyncLoadDOMService);
var ioServ = 
Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var uri = ioServ.newURI("http://foo.com", null, null);
var ch = ioServ.newChannelFromURI(uri);
domServ.loadDocument(ch, null);

I'm behind a firewall, and I've tried three cases: an existing site on 
the other side of the firewall; an existing side on the same side of the 
firewall; and a nonexistent site on the same side of the firewall.

When the site is on the other side of the firewall, the call to 
loadDocument() hangs. This doesn't surprise me, since I haven't done 
anything about proxies (I'll leave that question for later). The 
nonexistent internal site returns an empty document. The existing 
internal site generates an error:

uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsISyncLoadDOMService.loadDocument]" 
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: typein 
:: <TOP_LEVEL> :: line 5"  data: no]

So what am I doing wrong? And where's the most likely place to find help 
and guidance? I've been poking around xulplanet and mozdev, but I can't 
really find enough resources. What am I missing?

Thanks in advance -
Sam Bayer
The MITRE Corporation
sam at mitre.org



More information about the Project_owners mailing list