diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2016-04-08 12:00:17 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2016-04-11 13:29:11 -0400 |
commit | 08d73d7f9c7eec2f0abd14d00bf903625728ef17 (patch) | |
tree | a6cfec625dfcde55eed1d88eebd0164356dbcb52 /test | |
parent | 755e7ccf018eb150eddefe78063a9ec58b3229e3 (diff) | |
download | jquery-08d73d7f9c7eec2f0abd14d00bf903625728ef17.tar.gz jquery-08d73d7f9c7eec2f0abd14d00bf903625728ef17.zip |
Tests: Make iframe tests wait after checking isReady
Ref gh-3040
Diffstat (limited to 'test')
-rw-r--r-- | test/data/dimensions/documentLarge.html | 5 | ||||
-rw-r--r-- | test/data/offset/absolute.html | 1 | ||||
-rw-r--r-- | test/data/offset/body.html | 1 | ||||
-rw-r--r-- | test/data/offset/fixed.html | 1 | ||||
-rw-r--r-- | test/data/offset/relative.html | 1 | ||||
-rw-r--r-- | test/data/offset/scroll.html | 1 | ||||
-rw-r--r-- | test/data/offset/static.html | 1 | ||||
-rw-r--r-- | test/data/offset/table.html | 1 | ||||
-rw-r--r-- | test/data/selector/html5_selector.html | 4 | ||||
-rw-r--r-- | test/data/selector/sizzle_cache.html | 5 | ||||
-rw-r--r-- | test/data/testinit.js | 31 | ||||
-rw-r--r-- | test/unit/dimensions.js | 4 | ||||
-rw-r--r-- | test/unit/offset.js | 23 | ||||
-rw-r--r-- | test/unit/selector.js | 8 |
14 files changed, 35 insertions, 52 deletions
diff --git a/test/data/dimensions/documentLarge.html b/test/data/dimensions/documentLarge.html index a6598fcc8..c977fac96 100644 --- a/test/data/dimensions/documentLarge.html +++ b/test/data/dimensions/documentLarge.html @@ -12,6 +12,11 @@ <body> <div> <script src="../../jquery.js"></script> + <script> + jQuery( function() { + window.parent.iframeCallback( jQuery, window, document ); + } ); + </script> </div> </body> </html> diff --git a/test/data/offset/absolute.html b/test/data/offset/absolute.html index 58f0cbd2a..84a9e33de 100644 --- a/test/data/offset/absolute.html +++ b/test/data/offset/absolute.html @@ -24,6 +24,7 @@ $(this).css({ top: pos.top, left: pos.left }); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/body.html b/test/data/offset/body.html index c0de297b7..cada87a15 100644 --- a/test/data/offset/body.html +++ b/test/data/offset/body.html @@ -16,6 +16,7 @@ $("marker").css( $(this).offset() ); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/fixed.html b/test/data/offset/fixed.html index c695ba4dd..e54389596 100644 --- a/test/data/offset/fixed.html +++ b/test/data/offset/fixed.html @@ -20,6 +20,7 @@ $("#marker").css( $(this).offset() ); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/relative.html b/test/data/offset/relative.html index f88c82ab9..b413e05ee 100644 --- a/test/data/offset/relative.html +++ b/test/data/offset/relative.html @@ -20,6 +20,7 @@ $(this).css({ position: 'absolute', top: pos.top, left: pos.left }); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/scroll.html b/test/data/offset/scroll.html index c8c08020f..49304eee7 100644 --- a/test/data/offset/scroll.html +++ b/test/data/offset/scroll.html @@ -24,6 +24,7 @@ $("#marker").css( $(this).offset() ); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/static.html b/test/data/offset/static.html index f8cafa882..125ad740f 100644 --- a/test/data/offset/static.html +++ b/test/data/offset/static.html @@ -19,6 +19,7 @@ $(this).css({ position: 'absolute', top: pos.top, left: pos.left }); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/offset/table.html b/test/data/offset/table.html index ff2b8579e..1e37957ce 100644 --- a/test/data/offset/table.html +++ b/test/data/offset/table.html @@ -17,6 +17,7 @@ $("#marker").css( $(this).offset() ); return false; }); + window.parent.iframeCallback( jQuery, window, document ); }); </script> </head> diff --git a/test/data/selector/html5_selector.html b/test/data/selector/html5_selector.html index 30f25c9d5..bf0e5ba5e 100644 --- a/test/data/selector/html5_selector.html +++ b/test/data/selector/html5_selector.html @@ -15,6 +15,10 @@ document.createElement('audio'); document.createElement('article'); document.createElement('details'); + + jQuery( function() { + window.parent.iframeCallback( jQuery, window, document ); + } ); </script> </head> <body> diff --git a/test/data/selector/sizzle_cache.html b/test/data/selector/sizzle_cache.html index 1055c75ae..4320fdcfd 100644 --- a/test/data/selector/sizzle_cache.html +++ b/test/data/selector/sizzle_cache.html @@ -17,5 +17,10 @@ <div class="test"> <a href="#" id="collision">Worlds collide</a> </div> + <script> + jQuery( function() { + window.parent.iframeCallback( jQuery, window, document ); + } ); + </script> </body> </html> diff --git a/test/data/testinit.js b/test/data/testinit.js index dfae73d7c..70c9bbd5a 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -232,37 +232,6 @@ this.ajaxTest = function( title, expect, options ) { } ); }; -this.testIframe = function( fileName, name, fn ) { - QUnit.test( name, function( assert ) { - var done = assert.async(); - - // load fixture in iframe - var iframe = loadFixture(), - win = iframe.contentWindow, - interval = setInterval( function() { - if ( win && win.jQuery && win.jQuery.isReady ) { - clearInterval( interval ); - - // call actual tests passing the correct jQuery instance to use - fn.call( this, win.jQuery, win, win.document, assert ); - done(); - document.body.removeChild( iframe ); - iframe = null; - } - }, 15 ); - } ); - - function loadFixture() { - var src = url( "./data/" + fileName + ".html" ), - iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ]; - iframe.style.cssText = "width: 500px; height: 500px; position: absolute; " + - "top: -600px; left: -600px; visibility: hidden;"; - - iframe.contentWindow.location = src; - return iframe; - } -}; - this.testIframeWithCallback = function( title, fileName, func ) { QUnit.test( title, 1, function( assert ) { var iframe; diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 31c5aa48b..1f8ff5007 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -469,9 +469,9 @@ QUnit.test( "setters with and without box-sizing:border-box", function( assert ) } ); } ); -testIframe( - "dimensions/documentLarge", +testIframeWithCallback( "window vs. large document", + "dimensions/documentLarge.html", function( jQuery, window, document, assert ) { assert.expect( 2 ); diff --git a/test/unit/offset.js b/test/unit/offset.js index 52113fb9f..65483107e 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -35,13 +35,6 @@ QUnit.module( "offset", { setup: function() { forceScroll.detach(); }, teardown: moduleTeardown } ); -/* - Closure-compiler will roll static methods off of the jQuery object and so they will - not be passed with the jQuery object across the windows. To differentiate this, the - testIframe callbacks use the "$" symbol to refer to the jQuery object passed from - the iframe window and the "jQuery" symbol is used to access any static methods. -*/ - QUnit.test( "empty set", function( assert ) { assert.expect( 2 ); assert.strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" ); @@ -75,7 +68,7 @@ QUnit.test( "hidden (display: none) element", function( assert ) { assert.equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" ); } ); -testIframe( "offset/absolute", "absolute", function( $, iframe, document, assert ) { +testIframeWithCallback( "absolute", "offset/absolute.html", function( $, iframe, document, assert ) { assert.expect( 4 ); var doc = iframe.document, @@ -100,7 +93,7 @@ testIframe( "offset/absolute", "absolute", function( $, iframe, document, assert } ); } ); -testIframe( "offset/absolute", "absolute", function( $, window, document, assert ) { +testIframeWithCallback( "absolute", "offset/absolute.html", function( $, window, document, assert ) { assert.expect( 178 ); var tests, offset; @@ -185,7 +178,7 @@ testIframe( "offset/absolute", "absolute", function( $, window, document, assert } ); } ); -testIframe( "offset/relative", "relative", function( $, window, document, assert ) { +testIframeWithCallback( "relative", "offset/relative.html", function( $, window, document, assert ) { assert.expect( 64 ); // get offset @@ -243,7 +236,7 @@ testIframe( "offset/relative", "relative", function( $, window, document, assert } ); } ); -testIframe( "offset/static", "static", function( $, window, document, assert ) { +testIframeWithCallback( "static", "offset/static.html", function( $, window, document, assert ) { assert.expect( 80 ); // get offset @@ -305,7 +298,7 @@ testIframe( "offset/static", "static", function( $, window, document, assert ) { } ); } ); -testIframe( "offset/fixed", "fixed", function( $, window, document, assert ) { +testIframeWithCallback( "fixed", "offset/fixed.html", function( $, window, document, assert ) { assert.expect( 34 ); var tests, $noTopLeft; @@ -395,7 +388,7 @@ testIframe( "offset/fixed", "fixed", function( $, window, document, assert ) { } } ); -testIframe( "offset/table", "table", function( $, window, document, assert ) { +testIframeWithCallback( "table", "offset/table.html", function( $, window, document, assert ) { assert.expect( 4 ); assert.equal( $( "#table-1" ).offset().top, 6, "jQuery('#table-1').offset().top" ); @@ -405,7 +398,7 @@ testIframe( "offset/table", "table", function( $, window, document, assert ) { assert.equal( $( "#th-1" ).offset().left, 10, "jQuery('#th-1').offset().left" ); } ); -testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) { +testIframeWithCallback( "scroll", "offset/scroll.html", function( $, win, doc, assert ) { assert.expect( 26 ); assert.equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" ); @@ -464,7 +457,7 @@ testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) { assert.strictEqual( $().scrollLeft(), undefined, "jQuery().scrollLeft() testing getter on empty jquery object" ); } ); -testIframe( "offset/body", "body", function( $, window, document, assert ) { +testIframeWithCallback( "body", "offset/body.html", function( $, window, document, assert ) { assert.expect( 4 ); assert.equal( $( "body" ).offset().top, 1, "jQuery('#body').offset().top" ); diff --git a/test/unit/selector.js b/test/unit/selector.js index 1263c7cf6..1b5de1317 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -289,9 +289,9 @@ QUnit[ jQuery.find.compile ? "test" : "skip" ]( "disconnected nodes", function( assert.equal( $opt.is( ":selected" ), true, "selected option" ); } ); -testIframe( - "selector/html5_selector", +testIframeWithCallback( "attributes - jQuery.attr", + "selector/html5_selector.html", function( jQuery, window, document, assert ) { assert.expect( 38 ); @@ -489,9 +489,9 @@ QUnit.test( "jQuery.uniqueSort", function( assert ) { assert.strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" ); } ); -testIframe( - "selector/sizzle_cache", +testIframeWithCallback( "Sizzle cache collides with multiple Sizzles on a page", + "selector/sizzle_cache.html", function( jQuery, window, document, assert ) { var $cached = window[ "$cached" ]; |