<commit_before>FirefoxDriver.prototype.click = function(position) {
    var element = Utils.getElementAt(position, this.context);
    if (!element) {
        this.server.respond(this.context, "click");
        return;
    }

    // Attach a listener so that we can wait until any page load this causes to complete
    var driver = this;
    var server = this.server;
    var clickListener = new WebLoadingListener(this, function(event) {
        server.respond(driver.context, "click");
    });

    element.focus();
    Utils.fireMouseEventOn(this.context, element, "mousedown");

    // Now do the click
    if (element["click"]) {
        element.click();
    } else {
        // Send the mouse event too. Not sure if this will cause the thing to be double clicked....
        Utils.fireMouseEventOn(this.context, element, "click");
    }

    Utils.fireMouseEventOn(this.context, element, "mouseup");
	var browser = Utils.getBrowser(this.context);

    var checkForLoad = function() {
        // Returning should be handled by the click listener, unless we're not actually loading something. Do a check and return if we are.
        // There's a race condition here, in that the click event and load may have finished before we get here. For now, let's pretend that
        // doesn't happen. The other race condition is that we make this check before the load has begun. With all the javascript out there,
        // this might actually be a bit of a problem.
        var docLoaderService = Utils.getBrowser(driver.context).webProgress
        if (!docLoaderService.isLoadingDocument) {
            WebLoadingListener.removeListener(browser, clickListener);
            server.respond(driver.context, "click");
        }
    }

    Utils.getBrowser(this.context).contentWindow.setTimeout(checkForLoad, 50);
};

FirefoxDriver.prototype.getElementText = function(elementId) {
    var element = Utils.getElementAt(elementId, this.context);
	 if (element.tagName == "TITLE") {
		this.server.respond(this.context, "getElementText", Utils.getBrowser(this.context).contentTitle);
	} else {
    	this.server.respond(this.context, "getElementText", Utils.getText(element, true));
	}
}

FirefoxDriver.prototype.getElementValue = function(value) {
    var element = Utils.getElementAt(value, this.context);
    if (element.tagName.toLowerCase() == "textarea") {
        this.server.respond(this.context, "getElementValue", "OK\n" + element.value);
		return 
	}

	if (element.hasAttribute("value")) {
		this.server.respond(this.context, "getElementValue", "OK\n" + element.getAttribute("value"));
		return;
	}
	
	if (element["value"]) {
		this.server.respond(this.context, "getElementValue", "OK\n" + element.value);
		return;
	}
		
	this.server.respond(this.context, "getElementValue", "No match\n");
}

FirefoxDriver.prototype.setElementValue = function(value) {
    var spaceIndex = value.indexOf(" ");
    var element = Utils.getElementAt(value.substring(0, spaceIndex), this.context);
    spaceIndex = value.indexOf(" ", spaceIndex);
    var newValue = value.substring(spaceIndex + 1);

    Utils.type(this.context, element, newValue);

    this.server.respond(this.context, "setElementValue");
}

FirefoxDriver.prototype.getElementAttribute = function(value) {
    var spaceIndex = value.indexOf(" ");
    var element = Utils.getElementAt(value.substring(0, spaceIndex), this.context);
    spaceIndex = value.indexOf(" ", spaceIndex);
    var attributeName = value.substring(spaceIndex + 1);

    if (element.hasAttribute(attributeName)) {
        var response = element.getAttribute(attributeName);

        if (attributeName.toLowerCase() == "disabled") {
            response = element.disabled;
        } else if (attributeName.toLowerCase() == "selected") {
            response = element.selected;<commit_msg>SimonStewart: Rearranging order in which the value of an element is searched for to properly account for changes because of javascript<commit_after>FirefoxDriver.prototype.click = function(position) {
    var element = Utils.getElementAt(position, this.context);
    if (!element) {
        this.server.respond(this.context, "click");
        return;
    }

    // Attach a listener so that we can wait until any page load this causes to complete
    var driver = this;
    var server = this.server;
    var clickListener = new WebLoadingListener(this, function(event) {
        server.respond(driver.context, "click");
    });

    element.focus();
    Utils.fireMouseEventOn(this.context, element, "mousedown");

    // Now do the click
    if (element["click"]) {
        element.click();
    } else {
        // Send the mouse event too. Not sure if this will cause the thing to be double clicked....
        Utils.fireMouseEventOn(this.context, element, "click");
    }

    Utils.fireMouseEventOn(this.context, element, "mouseup");
	var browser = Utils.getBrowser(this.context);

    var checkForLoad = function() {
        // Returning should be handled by the click listener, unless we're not actually loading something. Do a check and return if we are.
        // There's a race condition here, in that the click event and load may have finished before we get here. For now, let's pretend that
        // doesn't happen. The other race condition is that we make this check before the load has begun. With all the javascript out there,
        // this might actually be a bit of a problem.
        var docLoaderService = Utils.getBrowser(driver.context).webProgress
        if (!docLoaderService.isLoadingDocument) {
            WebLoadingListener.removeListener(browser, clickListener);
            server.respond(driver.context, "click");
        }
    }

    Utils.getBrowser(this.context).contentWindow.setTimeout(checkForLoad, 50);
};

FirefoxDriver.prototype.getElementText = function(elementId) {
    var element = Utils.getElementAt(elementId, this.context);
	 if (element.tagName == "TITLE") {
		this.server.respond(this.context, "getElementText", Utils.getBrowser(this.context).contentTitle);
	} else {
    	this.server.respond(this.context, "getElementText", Utils.getText(element, true));
	}
}

FirefoxDriver.prototype.getElementValue = function(value) {
    var element = Utils.getElementAt(value, this.context);
    if (element.tagName.toLowerCase() == "textarea") {
        this.server.respond(this.context, "getElementValue", "OK\n" + element.value);
		return 
	}

	if (element["value"]) {
		this.server.respond(this.context, "getElementValue", "OK\n" + element.value);
		return;
	}

	if (element.hasAttribute("value")) {
		this.server.respond(this.context, "getElementValue", "OK\n" + element.getAttribute("value"));
		return;
	}
		
	this.server.respond(this.context, "getElementValue", "No match\n");
}

FirefoxDriver.prototype.setElementValue = function(value) {
    var spaceIndex = value.indexOf(" ");
    var element = Utils.getElementAt(value.substring(0, spaceIndex), this.context);
    spaceIndex = value.indexOf(" ", spaceIndex);
    var newValue = value.substring(spaceIndex + 1);

    Utils.type(this.context, element, newValue);

    this.server.respond(this.context, "setElementValue");
}

FirefoxDriver.prototype.getElementAttribute = function(value) {
    var spaceIndex = value.indexOf(" ");
    var element = Utils.getElementAt(value.substring(0, spaceIndex), this.context);
    spaceIndex = value.indexOf(" ", spaceIndex);
    var attributeName = value.substring(spaceIndex + 1);

    if (element.hasAttribute(attributeName)) {
        var response = element.getAttribute(attributeName);

        if (attributeName.toLowerCase() == "disabled") {
            response = element.disabled;
        } else if (attributeName.toLowerCase() == "selected") {
            response = element.selected;
{'fraction_non_alphanumeric': 0.12170882808466701, 'fraction_numerical': 0.0015487867836861124, 'mean_word_length': 3.5689858490566038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2394395', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2128, 'n_words': 567}