Totally depends. I'll admit it can be confusing to understand it's
scope sometimes. Usually I'll use one of these:

-----------8<-----------
window.opener
----------->8-----------

or:

-----------8<-----------
getDocumentDOM().docShell.document.*
getDocumentDOM().contentDocument.*


function getDocumentDOM() {
// Request DOM mediation for focused window.
var mediate = Components.classes["@mozilla.org/appshell/window-
mediator;1"].getService(Components.interfaces.nsIWindowMediato r);
var FocusedWindow = mediate.getMostRecentWindow("navigator:browser");
var doc = FocusedWindow.getBrowser();
return doc;
}
----------->8-----------