add: this.getHrefXPathLocator, 
context: function EventManager(listener) {	this.listener = listener;	var log = new Log("EventManager");	var self = this;	this.startForAllBrowsers = function() {		forEachBrowser(new RegisterHandler());	}	this.startForContentWindow = function(contentWindow) {		callForWindow(new RegisterHandler(), contentWindow);	}	this.stopForAllBrowsers = function() {		forEachBrowser(new DeregisterHandler());	}	function forEachBrowser(handler) {		log.debug("forEachBrowser");		var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);		var e = wm.getEnumerator("navigator:browser");		var window;		var browsers;		var i;		while (e.hasMoreElements()) {			window = e.getNext();			log.debug("window=" + window);			browsers = window.getBrowser().browsers;			for (i = 0; i < browsers.length; i++) {				log.debug("browser=" + browsers[i]);				callForWindow(handler, browsers[i].contentWindow);			}		}	}	function callForWindow(handler, contentWindow) {		var documents = getDocuments(contentWindow);		for (var i = 0; i < documents.length; i++) {			handler.handleDocument(documents[i], contentWindow);		}	}	function RegisterHandler(w) {	}	RegisterHandler.prototype.handleDocument = function(document, window) {		if (!document._Selenium_IDE_listeners) {			log.debug("registering event listeners for " + document);						function findClickableElement(e, window) {				if (!e.tagName) return null;				var tagName = e.tagName.toLowerCase();				var type = e.type;				if (e.hasAttribute("onclick") || e.hasAttribute("href") || tagName == "button" ||					(tagName == "input" && 					 (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) {					return e;				} else {					if (e.parentNode != null) {						return findClickableElement(e.parentNode, window);					} else {						return null;					}				}			}						var listeners = {				change: function(event) {					if (!self.listener.recordingEnabled) return;										var tagName = event.target.tagName.toLowerCase();					log.debug("change event: tagName=" + tagName);					var type = event.target.type;					if ('select' == tagName) {						var label = event.target.options[event.target.selectedIndex].innerHTML;						var value = "label=" + label.replace(/^\s*(.*?)\s*$/, "$1");						self.listener.addCommand("select", self.getLocator(window, event.target), value, window);					} else if (('input' == tagName && ('text' == type || 'password' == type || 'file' == type)) ||							   'textarea' == tagName) {						self.listener.addCommand("type", self.getLocator(window, event.target), event.target.value, window);					} else {						log.debug("ignoring change event: tagName=" + tagName);					}				},				click: function(event) {					if (!self.listener.recordingEnabled) return;										if (event.button == 0) {						var clickable = findClickableElement(event.target);						if (clickable) {							self.listener.addCommand("click", self.getLocator(window, clickable), '', window);						}					}				},				mousedown: function(event) {					self.listener.clickedElement = event.target;				}			}			for (name in listeners) {				document.addEventListener(name, listeners[name], false);			}						document._Selenium_IDE_listeners = listeners;						return true;		} else {			return false;		}	};		function DeregisterHandler() {	}		DeregisterHandler.prototype.handleDocument = function(document, window) {		//window.removeEventListener(window, e._changeEventListener, false);		if (document._Selenium_IDE_listeners) {			log.debug("unregistering event listeners");			var listeners = document._Selenium_IDE_listeners;			for (name in listeners) {				document.removeEventListener(name, listeners[name], false);			}			delete document._Selenium_IDE_listeners;		}		delete window._locator_pageBot;	};	this.getLocator = function(window, e) {		var locatorDetectors = 		  [this.getLinkLocator, 		   this.getIDLocator, 		   this.getNameLocator, 		   this.getLinkXPathLocator,		   this.getAttributesXPathLocator, 		   this.getPositionXPathLocator];		var i = 0;		var xpathLevel = 0;		var maxLevel = 10;		var locator;		var pageBot = this.getPageBot(window);		log.debug("getLocator for element " + e);		for (var i = 0; i < locatorDetectors.length; i++) {			locator = locatorDetectors[i].call(this, e, pageBot);			if (locator) {				log.debug("locator=" + locator);				// test the locator				try {					if (e == pageBot.findElement(locator)) {						return locator;					}				} catch (error) {					log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator);				}			}		}		return "LOCATOR_DETECTION_FAILED";	}	function getDocuments(frame) {		var documents = new Array();		var frames = frame.frames;		documents.push(frame.document);		for (var i = 0; i < frames.length; i++) {			documents = documents.concat(getDocuments(frames[i]));		}		return documents;	}		function getBrowser() {		var browser = opener.getBrowser();		return browser;	}}
meta: 3175	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/3175/4f08e58d98f8f98a7f1612587fa44323e01e45e9/eventManager.js/clean/src/content/eventManager.js