');
+ assert.isFalse(rule.matches(null, vNode));
});
it('returns false for input buttons', function() {
['reset', 'submit', 'button'].forEach(function(type) {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', 'foo');
- elm.type = type;
- fixture.appendChild(elm);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture(
+ '
'
+ );
+ assert.isFalse(rule.matches(null, vNode));
});
});
it('returns false for elements with an empty autocomplete', function() {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', ' ');
- fixture.appendChild(elm);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture('
');
+ assert.isFalse(rule.matches(null, vNode));
});
it('returns false for intput[type=hidden]', function() {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', 'foo');
- elm.type = 'hidden';
- fixture.appendChild(elm);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture(
+ '
'
+ );
+ assert.isFalse(rule.matches(null, vNode));
});
it('returns false for disabled fields', function() {
['input', 'select', 'textarea'].forEach(function(tagName) {
- var elm = document.createElement(tagName);
- elm.setAttribute('autocomplete', 'foo');
- elm.disabled = true;
- fixture.appendChild(elm);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture(
+ '<' + tagName + ' id="target" disabled autocomplete="foo">'
+ );
+ assert.isFalse(rule.matches(null, vNode));
});
});
it('returns false for aria-disabled=true fields', function() {
['input', 'select', 'textarea'].forEach(function(tagName) {
- var elm = document.createElement(tagName);
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('aria-disabled', 'true');
- fixture.appendChild(elm);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture(
+ '<' + tagName + ' id="target" aria-disabled="true" autocomplete="foo">'
+ );
+ assert.isFalse(rule.matches(null, vNode));
});
});
it('returns true for aria-disabled=false fields', function() {
['input', 'select', 'textarea'].forEach(function(tagName) {
- var elm = document.createElement(tagName);
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('aria-disabled', 'false');
- fixture.appendChild(elm);
- assert.isTrue(rule.matches(elm));
+ var vNode = queryFixture(
+ '<' + tagName + ' id="target" aria-disabled="false" autocomplete="foo">'
+ );
+ assert.isTrue(rule.matches(null, vNode));
});
});
it('returns false for non-widget roles with tabindex=-1', function() {
var nonWidgetRoles = ['application', 'fakerole', 'main'];
nonWidgetRoles.forEach(function(role) {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('role', role);
- elm.setAttribute('tabindex', '-1');
- fixture.appendChild(elm);
+ var vNode = queryFixture(
+ '
'
+ );
assert.isFalse(
- rule.matches(elm),
+ rule.matches(null, vNode),
'Expect role=' + role + ' to be ignored when it has tabindex=-1'
);
});
@@ -121,36 +105,30 @@ describe('autocomplete-matches', function() {
it('returns true for form fields with a widget role with tabindex=-1', function() {
var nonWidgetRoles = ['button', 'menuitem', 'slider'];
nonWidgetRoles.forEach(function(role) {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('role', role);
- elm.setAttribute('tabindex', '-1');
- fixture.appendChild(elm);
- assert.isTrue(rule.matches(elm));
+ var vNode = queryFixture(
+ '
'
+ );
+ assert.isTrue(rule.matches(null, vNode));
});
});
it('returns true for form fields with tabindex=-1', function() {
['input', 'select', 'textarea'].forEach(function(tagName) {
- var elm = document.createElement(tagName);
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('tabindex', -1);
- fixture.appendChild(elm);
- assert.isTrue(rule.matches(elm));
+ var vNode = queryFixture(
+ '<' + tagName + ' id="target" tabindex="-1" autocomplete="foo">'
+ );
+ assert.isTrue(rule.matches(null, vNode));
});
});
it('returns false for off screen and hidden form fields with tabindex=-1', function() {
- var elm = document.createElement('input');
- elm.setAttribute('autocomplete', 'foo');
- elm.setAttribute('tabindex', -1);
- elm.setAttribute('style', 'position:absolute; top:-9999em');
-
- var parent = document.createElement('div');
- parent.appendChild(elm);
- parent.setAttribute('aria-hidden', 'true');
-
- fixture.appendChild(parent);
- assert.isFalse(rule.matches(elm));
+ var vNode = queryFixture(
+ '
' +
+ '' +
+ '
'
+ );
+ assert.isFalse(rule.matches(null, vNode));
});
});