Bug 1197146: Part 6: Use dispatcher for listener clearElement

r=dburns

--HG--
extra : commitid : 35gcrZxPUW5
extra : source : 35f1b9173ef480dedd1869ec5ed1d0cbfd7a9e1b
This commit is contained in:
Andreas Tolfsen 2015-08-21 15:37:04 +01:00
Родитель 730495da38
Коммит 0a22490c2e
2 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -2309,7 +2309,7 @@ GeckoDriver.prototype.clearElement = function(cmd, resp) {
break; break;
case Context.CONTENT: case Context.CONTENT:
yield this.listener.clearElement({id: id}); yield this.listener.clearElement(id);
break; break;
} }
}; };

Просмотреть файл

@ -209,6 +209,7 @@ let findElementContentFn = dispatch(findElementContent);
let findElementsContentFn = dispatch(findElementsContent); let findElementsContentFn = dispatch(findElementsContent);
let isElementSelectedFn = dispatch(isElementSelected); let isElementSelectedFn = dispatch(isElementSelected);
let getElementLocationFn = dispatch(getElementLocation); let getElementLocationFn = dispatch(getElementLocation);
let clearElementFn = dispatch(clearElement);
/** /**
* Start all message listeners * Start all message listeners
@ -246,7 +247,7 @@ function startListeners() {
addMessageListenerId("Marionette:isElementSelected", isElementSelectedFn); addMessageListenerId("Marionette:isElementSelected", isElementSelectedFn);
addMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement); addMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement);
addMessageListenerId("Marionette:getElementLocation", getElementLocationFn); //deprecated addMessageListenerId("Marionette:getElementLocation", getElementLocationFn); //deprecated
addMessageListenerId("Marionette:clearElement", clearElement); addMessageListenerId("Marionette:clearElement", clearElementFn);
addMessageListenerId("Marionette:switchToFrame", switchToFrame); addMessageListenerId("Marionette:switchToFrame", switchToFrame);
addMessageListenerId("Marionette:deleteSession", deleteSession); addMessageListenerId("Marionette:deleteSession", deleteSession);
addMessageListenerId("Marionette:sleepSession", sleepSession); addMessageListenerId("Marionette:sleepSession", sleepSession);
@ -351,7 +352,7 @@ function deleteSession(msg) {
removeMessageListenerId("Marionette:isElementSelected", isElementSelectedFn); removeMessageListenerId("Marionette:isElementSelected", isElementSelectedFn);
removeMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement); removeMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement);
removeMessageListenerId("Marionette:getElementLocation", getElementLocationFn); removeMessageListenerId("Marionette:getElementLocation", getElementLocationFn);
removeMessageListenerId("Marionette:clearElement", clearElement); removeMessageListenerId("Marionette:clearElement", clearElementFn);
removeMessageListenerId("Marionette:switchToFrame", switchToFrame); removeMessageListenerId("Marionette:switchToFrame", switchToFrame);
removeMessageListenerId("Marionette:deleteSession", deleteSession); removeMessageListenerId("Marionette:deleteSession", deleteSession);
removeMessageListenerId("Marionette:sleepSession", sleepSession); removeMessageListenerId("Marionette:sleepSession", sleepSession);
@ -1641,25 +1642,24 @@ function getElementLocation(id) {
} }
/** /**
* Clear the text of an element * Clear the text of an element.
*/ */
function clearElement(msg) { function clearElement(id) {
let command_id = msg.json.command_id;
try { try {
let el = elementManager.getKnownElement(msg.json.id, curFrame); let el = elementManager.getKnownElement(id, curFrame);
if (el.type == "file") { if (el.type == "file") {
el.value = null; el.value = null;
} else { } else {
utils.clearElement(el); utils.clearElement(el);
} }
sendOk(command_id);
} catch (e) { } catch (e) {
// Bug 964738: Newer atoms contain status codes which makes wrapping // Bug 964738: Newer atoms contain status codes which makes wrapping
// this in an error prototype that has a status property unnecessary // this in an error prototype that has a status property unnecessary
if (e.name == "InvalidElementStateError") { if (e.name == "InvalidElementStateError") {
e = new InvalidElementStateError(e.message); throw new InvalidElementStateError(e.message);
} else {
throw e;
} }
sendError(e, command_id);
} }
} }