]> source.dussan.org Git - jquery.git/commitdiff
Tests: Adjust by actual scroll position, rather than expected
authorRichard Gibson <richard.gibson@gmail.com>
Sat, 29 Apr 2017 05:22:55 +0000 (01:22 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Sat, 29 Apr 2017 05:22:55 +0000 (01:22 -0400)
Ref 1d2df772b4d6e5dbf91df6e75f4a1809f7879ab0

test/data/testinit.js
test/unit/offset.js

index 52179547634dd929a78470f789c5e179c5e43b8f..b0592779e862631cab85cee2a451ae5672180bc1 100644 (file)
@@ -247,7 +247,7 @@ this.testIframe = function( title, fileName, func, wrapper ) {
                                        width: "500px"
                                } );
 
-               // Overcome TestSwarm iframe visibilty quirks
+               // Try to overcome TestSwarm iframe visibilty quirks
                if ( QUnit.isSwarm ) {
                        $iframe.css( { left: "0" } );
                }
index 4f04d73af7df2e07e7e595abfa2961253dd15431..425768f35dcbea0248fb33102e7c2fc9b27d58d8 100644 (file)
@@ -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 ],