Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2012-06-21 20:44:27 -04:00
commit 8096434a64
5 changed files with 121 additions and 28 deletions

View File

@ -0,0 +1,69 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette_test import MarionetteTestCase
from errors import InvalidElementStateException
class TestClear(MarionetteTestCase):
def testWriteableTextInputShouldClear(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id", "writableTextInput")
element.clear()
self.assertEqual("", element.get_attribute("value"))
def testTextInputShouldNotClearWhenReadOnly(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id","readOnlyTextInput")
try:
element.clear()
self.fail("Should not have been able to clear")
except InvalidElementStateException:
pass
def testWritableTextAreaShouldClear(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id","writableTextArea")
element.clear()
self.assertEqual("", element.get_attribute("value"))
def testTextAreaShouldNotClearWhenDisabled(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id","textAreaNotenabled")
try:
element.clear()
self.fail("Should not have been able to clear")
except InvalidElementStateException:
pass
def testTextAreaShouldNotClearWhenReadOnly(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id","textAreaReadOnly")
try:
element.clear()
self.fail("Should not have been able to clear")
except InvalidElementStateException:
pass
def testContentEditableAreaShouldClear(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
element = self.marionette.find_element("id","content-editable")
element.clear()
self.assertEqual("", element.text())
def testTextInputShouldNotClearWhenDisabled(self):
test_html = self.marionette.absolute_url("test_clearing.html")
self.marionette.navigate(test_html)
try:
element = self.marionette.find_element("id","textInputnotenabled")
self.assertFalse(element.enabled())
element.clear()
self.fail("Should not have been able to clear")
except InvalidElementStateException:
pass

View File

@ -0,0 +1,24 @@
<html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<body>
<input id="writableTextInput" type="text" value="Test"/>
<input id="readOnlyTextInput" type="text" readonly value="Test"/>
<input id="textInputnotenabled" type="text" disabled="true" value="Test"/>
<textarea id="writableTextArea" rows="2" cols="20">
This is a sample text area which is supposed to be cleared
</textarea>
<textarea id="textAreaReadOnly" readonly rows="5" cols="20">
text area which is not supposed to be cleared</textarea>
<textarea rows="5" id="textAreaNotenabled" disabled="true" cols="20">
text area which is not supposed to be cleared</textarea>
<div id="content-editable" contentEditable="true">This is a contentEditable area</div>
</body>
</html>

View File

@ -443,7 +443,7 @@ MarionetteDriverActor.prototype = {
args = this.curBrowser.elementManager.convertWrappedArguments(args, aWindow);
}
catch(e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
return;
}
@ -918,7 +918,7 @@ MarionetteDriverActor.prototype = {
this.sendOk();
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -941,7 +941,7 @@ MarionetteDriverActor.prototype = {
id = this.curBrowser.elementManager.find(this.getCurrentWindow(),aRequest, notify, false);
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
return;
}
}
@ -965,7 +965,7 @@ MarionetteDriverActor.prototype = {
id = this.curBrowser.elementManager.find(this.getCurrentWindow(), aRequest, notify, true);
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
return;
}
}
@ -990,7 +990,7 @@ MarionetteDriverActor.prototype = {
this.sendOk();
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1013,7 +1013,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(utils.getElementAttribute(el, aRequest.name));
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1039,7 +1039,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(lines);
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1061,7 +1061,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(utils.isElementDisplayed(el));
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1089,7 +1089,7 @@ MarionetteDriverActor.prototype = {
}
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1120,7 +1120,7 @@ MarionetteDriverActor.prototype = {
}
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1145,7 +1145,7 @@ MarionetteDriverActor.prototype = {
this.sendOk();
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1174,7 +1174,7 @@ MarionetteDriverActor.prototype = {
this.sendOk();
}
catch (e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
}
}
else {
@ -1262,7 +1262,7 @@ MarionetteDriverActor.prototype = {
cb(message.result);
}
catch(e) {
this.sendError(e.message, e.num, e.stack);
this.sendError(e.message, e.code, e.stack);
return;
}
},

View File

@ -27,7 +27,7 @@ let XPATH = "xpath";
function ElementException(msg, num, stack) {
this.message = msg;
this.num = num;
this.code = num;
this.stack = stack;
}

View File

@ -343,7 +343,7 @@ function executeScript(msg, directInject) {
msg.json.args, curWindow);
}
catch(e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
return;
}
@ -446,7 +446,7 @@ function executeWithCallback(msg, timeout) {
msg.json.args, curWindow);
}
catch(e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
return;
}
@ -479,7 +479,7 @@ function setSearchTimeout(msg) {
elementManager.setSearchTimeout(msg.json.value);
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
return;
}
sendOk();
@ -545,7 +545,7 @@ function findElementContent(msg) {
id = elementManager.find(curWindow, msg.json, notify, false);
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -559,7 +559,7 @@ function findElementsContent(msg) {
id = elementManager.find(curWindow, msg.json, notify, true);
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -574,7 +574,7 @@ function clickElement(msg) {
sendOk();
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -587,7 +587,7 @@ function getElementAttribute(msg) {
sendResponse({value: utils.getElementAttribute(el, msg.json.name)});
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -600,7 +600,7 @@ function getElementText(msg) {
sendResponse({value: utils.getElementText(el)});
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -613,7 +613,7 @@ function isElementDisplayed(msg) {
sendResponse({value: utils.isElementDisplayed(el)});
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -626,7 +626,7 @@ function isElementEnabled(msg) {
sendResponse({value: utils.isElementEnabled(el)});
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -639,7 +639,7 @@ function isElementSelected(msg) {
sendResponse({value: utils.isElementSelected(el)});
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -653,7 +653,7 @@ function sendKeysToElement(msg) {
sendOk();
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -667,7 +667,7 @@ function clearElement(msg) {
sendOk();
}
catch (e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
}
}
@ -759,7 +759,7 @@ function emulatorCmdResult(msg) {
cb(message.result);
}
catch(e) {
sendError(e.message, e.num, e.stack);
sendError(e.message, e.code, e.stack);
return;
}
}