-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
5cad6a6
commit 7fd03a3
Showing
4 changed files
with
98 additions
and
2 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
75 changes: 75 additions & 0 deletions
75
test/functional/fixtures/regression/gh-1353/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,75 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no"> | ||
<title></title> | ||
<style> | ||
body { | ||
position: absolute; | ||
margin: 0; | ||
width: 100%; | ||
} | ||
|
||
#filler { | ||
height: 2000px; | ||
width: 200px; | ||
background-color: red; | ||
} | ||
|
||
#target { | ||
height: 200px; | ||
width: 200px; | ||
background-color: blue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="filler"></div> | ||
<div id="target" onclick="window.targetClicked = true"></div> | ||
|
||
// NOTE: scrolling has issues in iOS Simulator https://github.com/DevExpress/testcafe/issues/1237 | ||
<script> | ||
var userAgent = window.navigator.userAgent.toLocaleLowerCase(); | ||
var isIOS = /(iphone|ipod|ipad)/.test(userAgent); | ||
|
||
// NOTE: Try to avoid odd scrolls in iOS on sauceLabs | ||
if (isIOS) { | ||
var originWindowScrollTo = window.scrollTo; | ||
var lastScrollTop = window.scrollY; | ||
var lastScrollLeft = window.scrollX; | ||
|
||
window.scrollTo = function () { | ||
lastScrollLeft = arguments[0]; | ||
lastScrollTop = arguments[1]; | ||
|
||
originWindowScrollTo.apply(window, arguments); | ||
}; | ||
|
||
window.addEventListener('scroll', function () { | ||
if (window.scrollX !== lastScrollLeft || window.scrollY !== lastScrollTop) | ||
window.scrollTo(lastScrollLeft, lastScrollTop); | ||
}); | ||
|
||
Object.defineProperty(document.body, 'scrollTop', { | ||
get: function () { | ||
return window.scrollY; | ||
}, | ||
|
||
set: function (y) { | ||
window.scrollTo(window.scrollX, y); | ||
} | ||
}); | ||
|
||
Object.defineProperty(document.body, 'scrollLeft', { | ||
get: function () { | ||
return window.scrollX; | ||
}, | ||
|
||
set: function (x) { | ||
window.scrollTo(x, window.scrollY); | ||
} | ||
}); | ||
} | ||
</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,5 @@ | ||
describe('[Regression](GH-1353)', function () { | ||
it('Document should be scrolled if body has "position: absolute"', function () { | ||
return runTests('testcafe-fixtures/index-test.js', 'gh-1353'); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
test/functional/fixtures/regression/gh-1353/testcafe-fixtures/index-test.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 { ClientFunction } from 'testcafe'; | ||
|
||
fixture `gh-1353` | ||
.page `http://localhost:3000/fixtures/regression/gh-1353/pages/index.html`; | ||
|
||
const targetClicked = ClientFunction(() => window.targetClicked); | ||
|
||
test('gh-1353', async t => { | ||
await t | ||
.click('#target') | ||
.expect(targetClicked()).ok(); | ||
}); |