+ /**
+ * Returns a load context for the given thing, to be used with
+ * interfaces needing one for per-window private browsing support.
+ *
+ * @param {Window|Document|Node} thing The thing for which to return
+ * a load context.
+ */
+ getContext: function getContext(thing) {
+ if (!Ci.nsILoadContext)
+ return null;
+
+ if (thing instanceof Ci.nsIDOMNode && thing.ownerDocument)
+ thing = thing.ownerDocument;
+ if (thing instanceof Ci.nsIDOMDocument)
+ thing = thing.defaultView;
+ if (thing instanceof Ci.nsIInterfaceRequestor)
+ thing = thing.getInterface(Ci.nsIWebNavigation);
+ return thing.QueryInterface(Ci.nsILoadContext);
+ },
+