Bug 759920: have status codes on errors bubble up from Atoms r=mdas

This commit is contained in:
David Burns 2012-06-21 13:47:13 -07:00
parent 516f42d157
commit 49f2da5232
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); args = this.curBrowser.elementManager.convertWrappedArguments(args, aWindow);
} }
catch(e) { catch(e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
return; return;
} }
@ -918,7 +918,7 @@ MarionetteDriverActor.prototype = {
this.sendOk(); this.sendOk();
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -941,7 +941,7 @@ MarionetteDriverActor.prototype = {
id = this.curBrowser.elementManager.find(this.getCurrentWindow(),aRequest, notify, false); id = this.curBrowser.elementManager.find(this.getCurrentWindow(),aRequest, notify, false);
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
return; return;
} }
} }
@ -965,7 +965,7 @@ MarionetteDriverActor.prototype = {
id = this.curBrowser.elementManager.find(this.getCurrentWindow(), aRequest, notify, true); id = this.curBrowser.elementManager.find(this.getCurrentWindow(), aRequest, notify, true);
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
return; return;
} }
} }
@ -990,7 +990,7 @@ MarionetteDriverActor.prototype = {
this.sendOk(); this.sendOk();
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1013,7 +1013,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(utils.getElementAttribute(el, aRequest.name)); this.sendResponse(utils.getElementAttribute(el, aRequest.name));
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1039,7 +1039,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(lines); this.sendResponse(lines);
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1061,7 +1061,7 @@ MarionetteDriverActor.prototype = {
this.sendResponse(utils.isElementDisplayed(el)); this.sendResponse(utils.isElementDisplayed(el));
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1089,7 +1089,7 @@ MarionetteDriverActor.prototype = {
} }
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1120,7 +1120,7 @@ MarionetteDriverActor.prototype = {
} }
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1145,7 +1145,7 @@ MarionetteDriverActor.prototype = {
this.sendOk(); this.sendOk();
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1174,7 +1174,7 @@ MarionetteDriverActor.prototype = {
this.sendOk(); this.sendOk();
} }
catch (e) { catch (e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
} }
} }
else { else {
@ -1262,7 +1262,7 @@ MarionetteDriverActor.prototype = {
cb(message.result); cb(message.result);
} }
catch(e) { catch(e) {
this.sendError(e.message, e.num, e.stack); this.sendError(e.message, e.code, e.stack);
return; return;
} }
}, },

View File

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

View File

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