Help with nsISSLStatusProvider - Mozilla

This is a discussion on Help with nsISSLStatusProvider - Mozilla ; I'm trying to do this inside of an extension: // on event from DOMContentLoaded getCipher: function(event) { var gb = getBrowser(); var targetBrowser = gb.getBrowserForDocument(event.target); var ui = targetBrowser.securityUI; var sslStatus = ui.QueryInterface (Components.interfaces.nsISSLStatusProvider).SSLSt atus; alert(sslStatus.cipherName); } This works when ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Help with nsISSLStatusProvider

  1. Help with nsISSLStatusProvider

    I'm trying to do this inside of an extension:

    // on event from DOMContentLoaded
    getCipher: function(event) {

    var gb = getBrowser();

    var targetBrowser = gb.getBrowserForDocument(event.target);
    var ui = targetBrowser.securityUI;
    var sslStatus = ui.QueryInterface
    (Components.interfaces.nsISSLStatusProvider).SSLSt atus;

    alert(sslStatus.cipherName);

    }

    This works when loading a page in the foreground, but when a page
    loads in the background, I get "undefined." Any idea why? Is this a
    bug?

  2. Re: Help with nsISSLStatusProvider

    Tried this as well, same results. Although I note that if I change
    target to always look a specific browser (say index 0, the first),
    then I can get cipherName and everything else just fine, but only if
    it is loaded in the foreground. If I then leave it open but select
    another tab, wait 10-20 seconds, and attempt to query index 0 again
    _without_ selecting it, all the values go to "undefined"!! Once I
    select it again, the values are back for another 10-20 seconds.

    Can I get any help with this issue?


    // event called from DOMContentLoaded
    function tryToGetCipher(event) {

    var gb = getBrowser();
    var ci = Components.interfaces;

    if (event.target instanceof XULDocument) {
    var target = gb.selectedBrowser; //
    foreground
    } else {
    var target = gb.getBrowserForDocument(event.target); //
    background
    }

    var targetUI = target.securityUI;
    var sslStatus = targetUI.QueryInterface
    (ci.nsISSLStatusProvider).SSLStatus;

    if(sslStatus) {
    return sslStatus.cipherName; // or any SSLStatus attribute
    } else return "no SSLStatus";

    }



    MkFly wrote:
    > I'm trying to do this inside of an extension:
    >
    > // on event from DOMContentLoaded
    > getCipher: function(event) {
    >
    > var gb = getBrowser();
    >
    > var targetBrowser = gb.getBrowserForDocument(event.target);
    > var ui = targetBrowser.securityUI;
    > var sslStatus = ui.QueryInterface
    > (Components.interfaces.nsISSLStatusProvider).SSLSt atus;
    >
    > alert(sslStatus.cipherName);
    >
    > }
    >
    > This works when loading a page in the foreground, but when a page
    > loads in the background, I get "undefined." Any idea why? Is this a
    > bug?


  3. Re: Help with nsISSLStatusProvider

    Thanks Neil for the response.

    Neil wrote:
    > However, there is then a time window during which,
    > when your code retrieves the SSL status, XPConnect will say "wait,
    > here's one I made earlier" and hands you the nsISSLStatus object.


    That makes sense, since in another test I set up, I would focus a tab,
    then after unfocusing it, I could still access the SSL status for
    about 10 to 20 seconds without refocusing it. I assume now that that
    is when the garbage collector trashed it.

    > Of course the browser only updates the lock icon for the active tab, so
    > that when you retrieve the SSL status for a background tab you get a
    > plain nsISupports object.


    So am I going about this entirely wrong? Is there any way to access
    the SSL attributes such as cipherName of a document loaded in the
    background?

    Thanks again.

  4. Re: Help with nsISSLStatusProvider

    Neil wrote:
    > Sure, but you have to use instanceof or QueryInterface to tell XPConnect
    > that you really want an nsISSLStatus object, just in case.


    Ahhhh ... perfect. Thanks Neil, that was exactly what I was missing.
    It works great after I changed it to:

    if (sslStatus instanceof ci.nsISSLStatus) alert(sslStatus.cipherName);

+ Reply to Thread