nsCOMPtr<nsIInterfaceRequestor> cb; mStreamChannel->GetNotificationCallbacks(getter_AddRefs(cb));  nsCOMPtr<nsIDocShell> docShell(do_GetInterface(cb));
nsCOMPtr<nsIDocShell> docShell; GetInterfaceFromChannel(mStreamChannel, NS_GET_IID(nsIDocShell), getter_AddRefs(docShell));
nsJSChannel::InternalOpen(PRBool aIsAsync, nsIStreamListener *aListener,                          nsISupports *aContext, nsIInputStream **aResult){    nsCOMPtr<nsILoadGroup> loadGroup;    // Add the javascript channel to its loadgroup so that we know if    // network loads were canceled or not...    mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));    if (loadGroup) {        loadGroup->AddRequest(this, aContext);    }    // Synchronously execute the script...    // mIsActive is used to indicate the the request is 'busy' during the    // the script evaluation phase.  This means that IsPending() will     // indicate the the request is busy while the script is executing...    mIsActive = PR_TRUE;    nsresult rv = mIOThunk->EvaluateScript(mStreamChannel);    // Remove the javascript channel from its loadgroup...    if (loadGroup) {        loadGroup->RemoveRequest(this, aContext, rv);    }    // We're no longer active, it's now up to the stream channel to do    // the loading, if needed.    mIsActive = PR_FALSE;    if (NS_SUCCEEDED(rv) && !mWasCanceled) {        // EvaluateScript() succeeded, and we were not canceled, that        // means there's data to parse as a result of evaluating the        // script.        // Get the stream channels load flags (!= mLoadFlags).        nsLoadFlags loadFlags;        mStreamChannel->GetLoadFlags(&loadFlags);        if (loadFlags & LOAD_DOCUMENT_URI) {            // We're loaded as the document channel. If we go on,            // we'll blow away the current document. Make sure that's            // ok. If so, stop all pending network loads.            nsCOMPtr<nsIInterfaceRequestor> cb;            mStreamChannel->GetNotificationCallbacks(getter_AddRefs(cb));            nsCOMPtr<nsIDocShell> docShell(do_GetInterface(cb));            if (docShell) {                nsCOMPtr<nsIContentViewer> cv;                docShell->GetContentViewer(getter_AddRefs(cv));                if (cv) {                    PRBool okToUnload;                    if (NS_SUCCEEDED(cv->PermitUnload(&okToUnload)) &&                        !okToUnload) {                        // The user didn't want to unload the current                        // page, translate this into an undefined                        // return from the javascript: URL...                        rv = NS_ERROR_DOM_RETVAL_UNDEFINED;                    }                }            }            if (NS_SUCCEEDED(rv)) {                rv = StopAll();            }        }        if (NS_SUCCEEDED(rv)) {            // This will add mStreamChannel to the load group.            if (aIsAsync) {                rv = mStreamChannel->AsyncOpen(aListener, aContext);            } else {                rv = mStreamChannel->Open(aResult);            }        }    }    if (NS_FAILED(rv)) {        // Propagate the failure down to the underlying channel...        mStreamChannel->Cancel(rv);    }    return rv;}