rem: var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); while(enumerator.hasMoreElements()) { var win = enumerator.getNext(); var browser = win.getBrowser(); for (var i = 0; i < browser.browsers.length; ++i) { var b = browser.browsers[i]; if (b && b.contentWindow == topContentWindow) { this.addCache(topContentWindow, browser); return browser; } } } 
add: var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); while(enumerator.hasMoreElements()) { var win = enumerator.getNext(); var browser = win.getBrowser(); for (var i = 0; i < browser.browsers.length; ++i) { var b = browser.browsers[i]; if (b && b.contentWindow == topContentWindow) { this.addCache(topContentWindow, browser); return browser; } } } 
context:     this.getBrowserForContentWindow = function(topContentWindow) {        var cached = this.checkCache(topContentWindow);        if(cached != null) return cached;        var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]            .getService(Components.interfaces.nsIWindowMediator);        var enumerator = wm.getEnumerator("navigator:browser");        while(enumerator.hasMoreElements()) {            var win = enumerator.getNext();            var browser = win.getBrowser();             for (var i = 0; i < browser.browsers.length; ++i) {                var b = browser.browsers[i];                if (b && b.contentWindow == topContentWindow) {                    this.addCache(topContentWindow, browser);                    return browser;                }            }        }        if(topContentWindow && topContentWindow.location)            this.logger.log(3, "No browser found: "+topContentWindow.location);        else            this.logger.log(3, "No browser found!");        return null;    };
meta: 3444	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/3444/7a73bce6e53c05c3c3da2a394c14da971dbbdd9e/window-mapper.js/buggy/src/components/window-mapper.js