Skip to content

Commit

Permalink
Bug 512789 - controller.check and controller.radio not working
Browse files Browse the repository at this point in the history
  • Loading branch information
whimboo committed Oct 5, 2009
1 parent 2c9cbfe commit 1a3f9c5
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions mozmill/extension/resource/modules/controller.js
Expand Up @@ -370,6 +370,46 @@ MozMillController.prototype.rightclick = function(){
this.rightClick.apply(this, arguments);
}

/**
* Enable/Disable a checkbox depending on the target state
*/
MozMillController.prototype.check = function(el, state) {
var result = false;
var element = el.getNode();

if (!element) {
throw new Error("could not find element " + el.getInfo());
return false;
}

state = (typeof(state) == "boolean") ? state : false;
if (state != element.checked) {
this.click(el);
this.waitForEval("subject.checked == " + state, 500, 100, element);
result = true;
}

frame.events.pass({'function':'Controller.check(' + el.getInfo() + ', state: ' + state + ')'});
return result;
}

/**
* Select the given radio button
*/
MozMillController.prototype.radio = function(el)
{
var element = el.getNode();
if (!element) {
throw new Error("could not find element " + el.getInfo());
return false;
}

this.click(el);
this.waitForEval("subject.selected == true", 500, 100, element);

frame.events.pass({'function':'Controller.radio(' + el.getInfo() + ')'});
return true;
}

MozMillController.prototype.sleep = sleep;
MozMillController.prototype.waitForEval = function (expression, timeout, interval, subject) {
Expand Down Expand Up @@ -552,20 +592,6 @@ MozMillController.prototype.refresh = function(){
return true;
}

//there is a problem with checking via click in safari
MozMillController.prototype.check = function(el){
//this.window.focus();
var element = el.getNode();
return MozMillController.click(element);
}

//Radio buttons are even WIERDER in safari, not breaking in FF
MozMillController.prototype.radio = function(el){
//this.window.focus();
var element = el.getNode();
return MozMillController.click(element);
}

MozMillController.prototype.assertText = function (el, text) {
//this.window.focus();
var n = el.getNode();
Expand Down

0 comments on commit 1a3f9c5

Please sign in to comment.