forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
label with attribute tabIndex should be focused (closes DevExpress#3501)
- Loading branch information
1 parent
0a049f6
commit 118a0ba
Showing
13 changed files
with
162 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/functional/fixtures/regression/gh-3501/pages/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body id="body"> | ||
<div> | ||
<label id="label1" for="radio" tabindex="1">label1</label> | ||
<input type="radio" id="radio"> | ||
|
||
<label id="label2" for="checkbox" tabindex="2">label2</label> | ||
<input type="checkbox" id="checkbox"> | ||
</div> | ||
<span id='logger'></span> | ||
<script> | ||
var eventLog = []; | ||
|
||
function consoleLog (text) { | ||
var logger = document.querySelector('#logger'); | ||
|
||
logger.innerHTML += text + '<br/>'; | ||
} | ||
|
||
var label1 = document.querySelector('#label1'); | ||
var label2 = document.querySelector('#label2'); | ||
var radio = document.querySelector('#radio'); | ||
var checkbox = document.querySelector('#checkbox'); | ||
|
||
function handleEvent (event) { | ||
const text = event.type + '. Target: ' + event.target.id; | ||
|
||
eventLog.push(text); | ||
|
||
consoleLog(text); | ||
} | ||
|
||
label1.addEventListener('focus', handleEvent); | ||
label2.addEventListener('focus', handleEvent); | ||
|
||
label1.addEventListener('click', handleEvent); | ||
label2.addEventListener('click', handleEvent); | ||
|
||
radio.addEventListener('focus', handleEvent); | ||
checkbox.addEventListener('focus', handleEvent); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('[Regression](GH-3501) - Should focus label if it is bound to element and has tabIndex attribute', function () { | ||
it('Click label bound to radio', function () { | ||
return runTests('testcafe-fixtures/index.js', 'Label bound to radio is focused'); | ||
}); | ||
|
||
it('Click label bound to checkbox', function () { | ||
return runTests('testcafe-fixtures/index.js', 'Label bound to checkbox is focused'); | ||
}); | ||
}); | ||
|
||
|
38 changes: 38 additions & 0 deletions
38
test/functional/fixtures/regression/gh-3501/testcafe-fixtures/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
fixture `Should focus label if it is bound to element and has tabIndex attribute` | ||
.page `http://localhost:3000/fixtures/regression/gh-3501/pages/index.html`; | ||
|
||
import { Selector, ClientFunction } from 'testcafe'; | ||
|
||
const label1 = Selector('#label1'); | ||
const label2 = Selector('#label2'); | ||
|
||
const getLog = ClientFunction(() => { | ||
return window.eventLog; | ||
}); | ||
|
||
test(`Label bound to radio is focused`, async t => { | ||
await t.click(label1); | ||
|
||
const log = await getLog(); | ||
|
||
await t.expect(log).eql([ | ||
'focus. Target: label1', | ||
'click. Target: label1', | ||
'focus. Target: radio' | ||
]); | ||
|
||
|
||
}); | ||
|
||
test(`Label bound to checkbox is focused`, async t => { | ||
await t.click(label2); | ||
|
||
const log = await getLog(); | ||
|
||
await t.expect(log).eql([ | ||
'focus. Target: label2', | ||
'click. Target: label2', | ||
'focus. Target: checkbox' | ||
]); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters