Access "unknown" function

Hi, I was wondering if anyone knew how the browser lets the user know if the page contains mixed content and if I could could gain access to that function?

Do you have any websites that display this message? I can help you find this function

No, Im asking if anyone knows how to access this function so I can use it in my add-on project

I understood that, I needed a site that had mixed context so I could inspect it and figure out. On irc someone had the same question and provided me with this site: Zabbix.org
I figured it out.

you get the window to your html frame then do this:

var htmlWindow = blah; // for example for window in tab 1 you would do `gBrowser.tabContainer.childNodes[0].linkedBrowser.contentWindow`
var SSLStatus = htmlWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).securityUI.QueryInterface(Components.interfaces.nsISSLStatusProvider).SSLStatus;

if (!SSLStatus) {
 // is untrusted
}

This tells you if its untrusted, im not sure about the mixed content but im sure its on the same lines, you owuld inspet the SSLStatus object, if you have a website that has mixed content share it with me so i can inspect it and help you out.

My bad sorry! Thank you so much for your help on this. A site with mixed content is https://www.bennish.net/mixed-content.html

I’m getting “gBrowser is not defined” when I run JPM RUN. I am running the code from within index.js

Oh I didn’t know you weren’t familiar with gBrowser.

gBrowser is basically the dom window but not exactly of each browser. There is no gBrowser object in sandboxes, you have to get a window then get a tabbrowser, which is the gBrowser.

So from jpm you would probably do something like this:

const { getMostRecentBrowserWindow } = require('sdk/window/utils');
var gBrowser = getMostRecentBrowserWindow(); // gets the most recent browsre window, note: you may have more then one browser window open.

var htmlWindow = gBrowser.tabContainer....

Thanks. I am reading up on it and still learning some of the different features and functions of SDK.

I am now getting “gBrowser.tabContainer” is not defined?

Will this work better out of the sandbox environment?

try

var gBrowser = getMostRecentBrowserWindow().gBrowser;

Im not an sdk guy myself i do stuff regular bootstrap way

I get “htmlWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).securityUI” is not defined

what is htmlWindow.location.href give you?

If I go to Google it will give me https://google.co.uk

Do I need to add some kind of “EventListener”

The error is a “type error”

I have also added “var { Ci } = require(‘chrome’);” for Ci

Oh yeah you’ll need that Ci thing at top.

No the event listener isn’t needed, as we are just trying to test a tab for its security level.

Ok so htmlWindow.locaiton.href works,

Its weird its saying securityUI is undefined

Maybe I could try out of the sandbox and see if anything changes? Don’t think it should though

UPDATE - Same error out of sandbox. Strange

How are you trying the code outside of the sandbox? Did you open scratchpad and set environment to browser and run that code? This is how to run scratchpad code: https://www.youtube.com/watch?v=oo4STWceGTM

Hey, I did get this working but by using another similar code.

It didn’t return any information with regards to mixed content though.

Maybe I need to look at the connection encryption as this is where the mixed content warning is displayed within FireFox under “security - technical details”

You’re right I checked on your mixed content site and it didnt show. Ill take a look a little later and see what I can do. :slight_smile:

Your a star! Thank you