From 49f2da52325db867733cccf0313e86d239d74e3e Mon Sep 17 00:00:00 2001 From: David Burns Date: Thu, 21 Jun 2012 13:47:13 -0700 Subject: [PATCH] Bug 759920: have status codes on errors bubble up from Atoms r=mdas --- .../marionette/tests/unit/test_clearing.py | 69 +++++++++++++++++++ .../client/marionette/www/test_clearing.html | 24 +++++++ testing/marionette/marionette-actors.js | 26 +++---- testing/marionette/marionette-elements.js | 2 +- testing/marionette/marionette-listener.js | 28 ++++---- 5 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 testing/marionette/client/marionette/tests/unit/test_clearing.py create mode 100644 testing/marionette/client/marionette/www/test_clearing.html diff --git a/testing/marionette/client/marionette/tests/unit/test_clearing.py b/testing/marionette/client/marionette/tests/unit/test_clearing.py new file mode 100644 index 00000000000..e57434b5a84 --- /dev/null +++ b/testing/marionette/client/marionette/tests/unit/test_clearing.py @@ -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 diff --git a/testing/marionette/client/marionette/www/test_clearing.html b/testing/marionette/client/marionette/www/test_clearing.html new file mode 100644 index 00000000000..2aa3c6a21f3 --- /dev/null +++ b/testing/marionette/client/marionette/www/test_clearing.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + +
This is a contentEditable area
+ + diff --git a/testing/marionette/marionette-actors.js b/testing/marionette/marionette-actors.js index 8140226c30a..275faedccda 100644 --- a/testing/marionette/marionette-actors.js +++ b/testing/marionette/marionette-actors.js @@ -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; } }, diff --git a/testing/marionette/marionette-elements.js b/testing/marionette/marionette-elements.js index 3e1a67a0b3e..1a47c68a329 100644 --- a/testing/marionette/marionette-elements.js +++ b/testing/marionette/marionette-elements.js @@ -27,7 +27,7 @@ let XPATH = "xpath"; function ElementException(msg, num, stack) { this.message = msg; - this.num = num; + this.code = num; this.stack = stack; } diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js index 6a7d74931fa..618cd6db42b 100644 --- a/testing/marionette/marionette-listener.js +++ b/testing/marionette/marionette-listener.js @@ -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; } }