I found a problem and fixed it, but I don't understand why the fix works. 
I'm posting here to ask if anyone else can explain it.

The Problem
-------------

We have embedded Gecko in a C++ app. I'm calling docShell->LoadStream to 
load an HTML document. The HTML document has these two lines in its <HEAD> 
section:

<script src='file://C:/NTE/Tests/9991/Scripts/ITSMC.js' 
language='javascript'></script>
<script src='file://C:/NTE/Tests/9991/Scripts/NWEAMC.js' 
language='javascript'></script>

The document displays just fine but the code in the two JavaScript files 
never runs. The document also contains IMG tags with similar fully specified 
absolute file:// URLs and the images display correctly. If I load the same 
document via nsIWebNavigation::LoadURI the JavaScript code does run. My 
JavaScript event handlers respond as they should. The problem occurs only 
when loading from a stream. Here's my LoadStream command:

    rv = docShell->LoadStream(inputStream,
                nsnull,
                NS_LITERAL_CSTRING("text/html"),
                NS_LITERAL_CSTRING(""),
                nsnull);

The Solution
-------------

I can load from a stream and the JavaScript files work if I specify a 
protocol in the second parameter:

    rv = docShell->LoadStream(inputStream,
                "file://",
                NS_LITERAL_CSTRING("text/html"),
                NS_LITERAL_CSTRING(""),
                nsnull);

(No, that's not the exact code--the second parameter is really an nsIURI 
object, not a string. Yes, I do make a URI to hold the protocol string.)

That fixes the problem, but I don't understand why. The SRC attributes 
already say "file://".  Why does that parameter value make a difference?

Brian 


_______________________________________________
mozilla-embedding mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-embedding

Reply via email to