Skip to content

Commit

Permalink
handle special case spellcheck attribute
Browse files Browse the repository at this point in the history
Fixes #1605
  • Loading branch information
lukeis committed Feb 9, 2016
1 parent 60009b1 commit 0f45bdd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions javascript/webdriver/atoms/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ webdriver.atoms.element.getAttribute = function(element, attribute) {
return /** @type {?string} */ (value);
}

if ('spellcheck' == name) {
value = bot.dom.getAttribute(element, name);
if (!goog.isNull(value)) {
if (value.toLowerCase() == 'false') {
return 'false';
} else if (value.toLowerCase() == 'true') {
return 'true';
}
}
// coerce the property value to a string
return bot.dom.getProperty(element, name) + '';
}

var propName = webdriver.atoms.element.PROPERTY_ALIASES_[attribute] ||
attribute;
if (goog.array.contains(webdriver.atoms.element.BOOLEAN_PROPERTIES_, name)) {
Expand Down
17 changes: 17 additions & 0 deletions javascript/webdriver/test/atoms/element_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@
assertEquals('true', webdriver.atoms.element.getAttribute(el, 'nowrap'));
}

function testShouldReturnFalseForSpellcheckFalse() {
var el = document.getElementById('nospell');
assertEquals('false', webdriver.atoms.element.getAttribute(el, 'spellcheck'));
}

function testShouldReturnTrueForSpellcheckTrue() {
var el = document.getElementById('spell');
assertEquals('true', webdriver.atoms.element.getAttribute(el, 'spellcheck'));
}

function testShouldReturnTrueForSpellcheckUndefined() {
var el = document.getElementById('normal');
assertEquals('true', webdriver.atoms.element.getAttribute(el, 'spellcheck'));
}

var newLine = bot.userAgent.IE_DOC_PRE9 ? '\r\n' : '\n';

function testTypingEnterKeyOnTextArea() {
Expand Down Expand Up @@ -263,6 +278,8 @@
</select>
</select>

<input id="nospell" spellcheck="false"/>
<input id="spell" spellcheck="true"/>
</form>

<img src="kitten.jpg" id="image">
Expand Down

0 comments on commit 0f45bdd

Please sign in to comment.