aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/offset.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2017-04-29 01:22:55 -0400
committerRichard Gibson <richard.gibson@gmail.com>2017-04-29 01:22:55 -0400
commitda533c6acc3130a94d29c2f2611dd02f9af7f114 (patch)
treef9eb67ed3fd932ed8c747527e07468968819d076 /test/unit/offset.js
parentc0edd8dc18e02999a25768a4946093b015045f80 (diff)
downloadjquery-da533c6acc3130a94d29c2f2611dd02f9af7f114.tar.gz
jquery-da533c6acc3130a94d29c2f2611dd02f9af7f114.zip
Tests: Adjust by actual scroll position, rather than expected
Ref 1d2df772b4d6e5dbf91df6e75f4a1809f7879ab0
Diffstat (limited to 'test/unit/offset.js')
-rw-r--r--test/unit/offset.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 4f04d73af..425768f35 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -554,10 +554,9 @@ QUnit.test( "chaining", function( assert ) {
return props( position === "static" ? 0 : 8192, position === "static" ? 0 : 4096,
512, 256, 1024, 512, 2048, 1024, position,
position !== "fixed" && "documentElement" );
- },
- viewportScroll = { top: 2, left: 1 };
+ };
- function getExpectations( htmlPos, bodyPos ) {
+ function getExpectations( htmlPos, bodyPos, scrollTop, scrollLeft ) {
// Initialize data about page elements
var expectations = {
@@ -630,8 +629,8 @@ QUnit.test( "chaining", function( assert ) {
if ( props.style === "fixed" &&
( alwaysScrollable || expectations.documentElement.style !== "fixed" ) ) {
- offset.top += viewportScroll.top;
- offset.left += viewportScroll.left;
+ offset.top += scrollTop;
+ offset.left += scrollLeft;
}
} );
@@ -639,13 +638,13 @@ QUnit.test( "chaining", function( assert ) {
// Fudge the tests to work around <html>.gBCR() erroneously including margins
if ( /MSIE (?:9|10)\./.test( navigator.userAgent ) ) {
expectations.documentElement.pos.top -= expectations.documentElement.marginTop -
- viewportScroll.top;
+ scrollTop;
expectations.documentElement.offset.top -= expectations.documentElement.marginTop -
- viewportScroll.top;
+ scrollTop;
expectations.documentElement.pos.left -= expectations.documentElement.marginLeft -
- viewportScroll.left;
+ scrollLeft;
expectations.documentElement.offset.left -= expectations.documentElement.marginLeft -
- viewportScroll.left;
+ scrollLeft;
if ( htmlPos !== "static" ) {
delete expectations.documentElement;
delete expectations.body;
@@ -663,11 +662,10 @@ QUnit.test( "chaining", function( assert ) {
var label = "nonzero box properties - html." + htmlPos + " body." + bodyPos;
testIframe( label, "offset/boxes.html", function( assert, $, win, doc ) {
+ // Define expectations at runtime to properly account for scrolling
var scrollTop = win.pageYOffset,
scrollLeft = win.pageXOffset,
-
- // Define expectations at runtime so alwaysScrollable is correct
- expectations = getExpectations( htmlPos, bodyPos );
+ expectations = getExpectations( htmlPos, bodyPos, scrollTop, scrollLeft );
assert.expect( 1 + 3 * Object.keys( expectations ).length );
@@ -682,6 +680,7 @@ QUnit.test( "chaining", function( assert ) {
fixedRect = fixed.getBoundingClientRect();
assert.ok( "CI debug", JSON.stringify(
{
+ isSwarm: QUnit.isSwarm,
alwaysScrollable: alwaysScrollable,
"original scroll": [ scrollTop, scrollLeft ],
"scroll": [ win.pageYOffset, win.pageXOffset ],