Hi all,
I have a bizarre problem you may be able to help with. It is a bit of a
killer for the Komodo project at the moment. It is very simple to repro.
Below, I have a XUL file with a button. When you click on this button,
some JS code uses the io-service and newChannelFromURI() to open a
"file://" URL and dump the contents.
The file IO works perfectly. However, after this, the code attempts to
load a standard Mozilla browser window. This new browser appears to
have no network connectivity at all - ie, sidebar (tinderbox etc) and
the page you request to load never complete. The barbershop and Moz
icons continually cycle, but nothing ever loads.
If you comment out the 20 or so lines of javascript, the new Mozilla
window loads fine - the page and all items on the sidebar open normally.
Once Mozilla in in this state, 2 warnings appear:
WARNING: not calling OnDataAvailable, file
F:\src\AS\mozilla\netwerk\base\src\nsAsyncStreamListener.cpp, line 410
I have tried tracking this in the debugger. For some reason, the
channel is canceled in response to a onStartRequest() event, but I
havent worked out exactly who is cancelling it, or why. (ie, the
GetStatus() call above this line succeeds, but the returned status is
"canceled".)
Hopefully the problem is simply that I am neglecting to close something.
However, only the streams appear to have close methods, and I am
calling these.
I am running from the tip (few days old now tho), Windows 2000, debug
and release builds. I can open files using a different technique (such
as the js IO library), but need the ability to open other schemes - such
as "chrome://" URLs to open resources. The problem is not js related,
as it can be reproduced without any javascript (with the Python bindings)
To reproduce the problem, place the XUL below in a chrome directory, and
load it via a "-chrome "chrome://..." command-line. A small window with
a button will appear. Clicking this button will dump the contents of
the named file, then create a browser window. The window will open, but
the contents will not load.
Any clues for me?
Thanks,
Mark.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin" type="text/css"?>
<window
id="test-io"
title="Channels kill async IO"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript">
function OpenMozilla() {
// **** Set this to a small, valid file
var url = "file://c:/temp/delme.txt";
// convert to nsIURL interface.
var url_ob = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance()
.QueryInterface(Components.interfaces.nsIURL);
url_ob.spec = url;
// Now open the URL.
var io_service =
Components.classes["@mozilla.org/network/io-service;1"]
.createInstance()
.QueryInterface(Components.interfaces.nsIIOService);
var channel = io_service.newChannelFromURI(url_ob);
var inputStream = channel.openInputStream();
// make the input stream scriptable.
var sinputStream =
Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance()
.QueryInterface(Components.interfaces.nsIScriptableInputStream);
sinputStream.init(inputStream);
dump("Read '" + sinputStream.read(-1) + "'\n");
// close everything I know how!
inputStream.close();
sinputStream.close();
openDialog('chrome://navigator/content/', '_blank', 'chrome,all',
'http://www.mozilla.org/');
return 1;
}
</script>
<button id="launch moz" value="launch moz" oncommand="return
OpenMozilla();"/>
</window>