Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent chrome from changing checkbox checked state when button or li…
…nk located inside the label is clicked(closes #6949) (#6950) * prevent chrome from changing checkbox checked state when button or link located inside the label is clicked(closes #6949) * code refactor
- Loading branch information
1 parent
b1acfc5
commit 36c3a8f
Showing
10 changed files
with
163 additions
and
6 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
16 changes: 16 additions & 0 deletions
16
test/functional/fixtures/regression/gh-6949/pages/with-button.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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
<div class="checkbox"> | ||
<input id="checkbox" type="checkbox"> | ||
<label for="checkbox" id="checkbox-label"> | ||
I have read and accept | ||
<button id="clickable-element" type="button">terms and conditions.</button> | ||
</label> | ||
</div> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
test/functional/fixtures/regression/gh-6949/pages/with-div.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,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
<div class="checkbox"> | ||
<input id="checkbox" type="checkbox"> | ||
<label for="checkbox" id="checkbox-label"> | ||
I have read and accept | ||
<div id="clickable-element" style="background-color: #00FF00; width: 200px; height: 50px;"> | ||
terms and conditions. | ||
</div> | ||
</label> | ||
</div> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
test/functional/fixtures/regression/gh-6949/pages/with-link-without-href.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,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
<div class="checkbox"> | ||
<input id="checkbox" type="checkbox"> | ||
<label for="checkbox" id="checkbox-label"> | ||
I have read and accept | ||
<a id="clickable-element"> | ||
terms and conditions. | ||
</a> | ||
</label> | ||
</div> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
test/functional/fixtures/regression/gh-6949/pages/with-link.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,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body> | ||
<div class="checkbox"> | ||
<input id="checkbox" type="checkbox"> | ||
<label for="checkbox" id="checkbox-label"> | ||
I have read and accept | ||
<a id="clickable-element" href="#"> | ||
terms and conditions. | ||
</a> | ||
</label> | ||
</div> | ||
</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,23 @@ | ||
describe('[Regression](GH-6949)', () => { | ||
it('Should change checkbox state when clicking checkbox label', () => { | ||
return runTests('./testcafe-fixtures/with-link.js', 'Click checkbox label'); | ||
}); | ||
|
||
it('Should NOT change checkbox state when clicking a LINK inside the checkbox label', () => { | ||
return runTests('./testcafe-fixtures/with-link.js', 'Click link inside checkbox label'); | ||
}); | ||
|
||
it('Should change checkbox state when clicking a LINK without href attribute inside the checkbox label', () => { | ||
//The behaviour in IE is different, so we should to exclude it from this test: | ||
return runTests('./testcafe-fixtures/with-link-without-href.js', 'Click link without href inside checkbox label', { skip: 'ie' }); | ||
}); | ||
|
||
it('Should NOT change checkbox state when clicking a BUTTON inside the checkbox label', () => { | ||
//The behaviour in IE is different, so we should to exclude it from this test: | ||
return runTests('./testcafe-fixtures/with-button.js', 'Click button inside checkbox label', { skip: 'ie' }); | ||
}); | ||
|
||
it('Should change checkbox state when clicking a DIV with onclick handler inside the checkbox label', () => { | ||
return runTests('./testcafe-fixtures/with-div.js', 'Click div inside checkbox label'); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/functional/fixtures/regression/gh-6949/testcafe-fixtures/with-button.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,12 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture`Getting Started` | ||
.page`http://localhost:3000/fixtures/regression/gh-6949/pages/with-button.html`; | ||
|
||
test('Click button inside checkbox label', async t => { | ||
const button = Selector('#clickable-element'); | ||
const checkBox = Selector('#checkbox'); | ||
|
||
await t.click(button); | ||
await t.expect(checkBox.checked).eql(false); | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/functional/fixtures/regression/gh-6949/testcafe-fixtures/with-div.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,12 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture`Getting Started` | ||
.page`http://localhost:3000/fixtures/regression/gh-6949/pages/with-div.html`; | ||
|
||
test('Click div inside checkbox label', async t => { | ||
const div = Selector('#clickable-element'); | ||
const checkBox = Selector('#checkbox'); | ||
|
||
await t.click(div); | ||
await t.expect(checkBox.checked).eql(true); | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/functional/fixtures/regression/gh-6949/testcafe-fixtures/with-link-without-href.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,12 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture`Getting Started` | ||
.page`http://localhost:3000/fixtures/regression/gh-6949/pages/with-link-without-href.html`; | ||
|
||
test('Click link without href inside checkbox label', async t => { | ||
const link = Selector('#clickable-element'); | ||
const checkBox = Selector('#checkbox'); | ||
|
||
await t.click(link); | ||
await t.expect(checkBox.checked).eql(true); | ||
}); |
20 changes: 20 additions & 0 deletions
20
test/functional/fixtures/regression/gh-6949/testcafe-fixtures/with-link.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,20 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture`Getting Started` | ||
.page`http://localhost:3000/fixtures/regression/gh-6949/pages/with-link.html`; | ||
|
||
test('Click checkbox label', async t => { | ||
const label = Selector('#checkbox-label'); | ||
const checkBox = Selector('#checkbox'); | ||
|
||
await t.click(label); | ||
await t.expect(checkBox.checked).eql(true); | ||
}); | ||
|
||
test('Click link inside checkbox label', async t => { | ||
const link = Selector('#clickable-element'); | ||
const checkBox = Selector('#checkbox'); | ||
|
||
await t.click(link); | ||
await t.expect(checkBox.checked).eql(false); | ||
}); |