]> source.dussan.org Git - jquery.git/commitdiff
Tests: Refactor testIframe() to make it DRYer and more consistent
authorDave Methvin <dave.methvin@gmail.com>
Sun, 10 Apr 2016 19:42:44 +0000 (15:42 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 11 Apr 2016 17:32:51 +0000 (13:32 -0400)
Ref gh-3040
Closes gh-3049

42 files changed:
README.md
test/data/ajax/onunload.html
test/data/ajax/unreleasedXHR.html
test/data/core/aliased.html
test/data/core/cc_on.html
test/data/core/dynamic_ready.html
test/data/core/onready.html
test/data/css/cssWidthBeforeDocReady.html
test/data/data/dataAttrs.html
test/data/dimensions/documentLarge.html
test/data/event/focusElem.html
test/data/event/focusinCrossFrame.html
test/data/event/interactiveReady.html
test/data/event/promiseReady.html
test/data/event/syncReady.html
test/data/event/triggerunload.html
test/data/iframeTest.js [new file with mode: 0644]
test/data/manipulation/iframe-denied.html
test/data/manipulation/scripts-context.html
test/data/offset/absolute.html
test/data/offset/body.html
test/data/offset/fixed.html
test/data/offset/relative.html
test/data/offset/scroll.html
test/data/offset/static.html
test/data/offset/table.html
test/data/selector/html5_selector.html
test/data/selector/sizzle_cache.html
test/data/support/bodyBackground.html
test/data/support/csp.js
test/data/support/csp.php
test/data/testinit.js
test/unit/ajax.js
test/unit/core.js
test/unit/css.js
test/unit/data.js
test/unit/dimensions.js
test/unit/event.js
test/unit/manipulation.js
test/unit/offset.js
test/unit/selector.js
test/unit/support.js

index 5c1a90c041f63789b8e9d2c8e59671c42c315301..9e5b130c4322a0042b26957c5e25a367f33f6c64 100644 (file)
--- a/README.md
+++ b/README.md
@@ -340,24 +340,32 @@ url("data/test.php?foo=bar");
 ```
 
 
-### Load tests in an iframe (window.iframeCallback) ###
+### Run tests in an iframe ###
+
+Some tests may require a document other than the standard test fixture, and
+these can be run in a separate iframe. The actual test code and assertions
+remain in jQuery's main test files; only the minimal test fixture markup
+and setup code should be placed in the iframe file.
 
 ```js
-testIframeWithCallback( testName, fileName,
-  function callback( arg1, arg2, ... assert ) {
+testIframe( testName, fileName,
+  function testCallback(
+      assert, jQuery, window, document,
+         [ additional args ] ) {
        ...
   } );
 ```
 
-Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
-The iframe page is responsible for determining when `window.parent.iframeCallback`
-should be called, for example at document ready or window.onload time.
-Arguments passed to the callback are the same as the arguments passed
-to `window.parent.iframeCallback` by the iframe, plus the QUnit `assert`
-object from the `QUnit.test()` that this wrapper sets up for you.
-The iframe should send any objects needed by the unit test via arguments, for example
-its `jQuery`, `window`, and `document` objects from the iframe.
+This loads a page, constructing a url with fileName `"./data/" + fileName`.
+The iframed page determines when the callback occurs in the test by
+including the "/test/data/iframeTest.js" script and calling
+`startIframeTest( [ additional args ] )` when appropriate. Often this
+will be after either document ready or `window.onload` fires.
 
+The `testCallback` receives the QUnit `assert` object created by `testIframe`
+for this test, followed by the global `jQuery`, `window`, and `document` from
+the iframe. If the iframe code passes any arguments to `startIframeTest`,
+they follow the `document` argument.
 
 
 Questions?
index eb1bca263065660f5cee1c8067dc62b95bc5f540..ec6e4b702203843c04ac6ac05fed8763f94a3949 100644 (file)
@@ -4,6 +4,7 @@
        <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
        <title>onunload ajax requests (#14379)</title>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <form id="navigate" action="../iframe.html"></form>
@@ -17,7 +18,7 @@
                                        ajaxStatus = status;
                                }
                        });
-                       parent.iframeCallback( ajaxStatus );
+                       startIframeTest( ajaxStatus );
                });
 
                jQuery(function() {
index 8a41c4967ae19fa63015ee5dbccba807ebb5d8a7..3eedaabf8e01e0aa74c62da7aadb46d0a4ce3680 100644 (file)
@@ -4,13 +4,14 @@
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>Attempt to block tests because of dangling XHR requests (IE)</title>
 <script src="../../jquery.js"></script>
+<script src="../iframeTest.js"></script>
 <script type="text/javascript">
 window.onunload = function() {};
 jQuery(function() {
        setTimeout(function() {
                var parent = window.parent;
                document.write("");
-               parent.iframeCallback();
+               startIframeTest();
        }, 200 );
        var number = 50;
        while( number-- ) {
index ed06606af45d83b056d3e7d459c21242b0657a53..87b5871f463e77b92ecb9be18f403b1be99d4885 100644 (file)
                };
        </script>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <form>
                <input type="text" id="nodeName"/>
        </form>
        <script>
-               jQuery(function() {
-                       window.parent.iframeCallback( errors );
-               });
+               jQuery( function() {
+                       startIframeTest( errors );
+               } );
        </script>
 </body>
 </html>
index 131e2e8532eabee21829ce64ded30e3ff188745c..5db18916ca19137066f780aafe09039dd3bae273 100644 (file)
                };
        </script>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <script>
-               window.parent.iframeCallback( cc_on, errors, jQuery );
+               startIframeTest( cc_on, errors );
        </script>
 </body>
 </html>
index 3b29c1104815222cf298fcd7f27c6639f28aa4dc..1db068b958c2e6261f9549bd878e7bb5f0b54142 100644 (file)
@@ -4,6 +4,7 @@
        <meta charset="utf-8">
        <script src="../../jquery.js"></script>
        <script>var $j = jQuery.noConflict();</script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
 <iframe id="dont_return" src="dont_return.php"></iframe>
                        $(function () {
                                clearTimeout( timeoutId );
                                if ( !timeoutFired ) {
-                                       window.parent.iframeCallback( true );
+                                       startIframeTest( true );
                                }
                        });
                });
 
                timeoutId = setTimeout(function () {
                        timeoutFired = true;
-                       window.parent.iframeCallback( false );
+                       startIframeTest( false );
                }, 10000);
        });
 </script>
index 1e8f127e77a8d3f80157534720af63f41b7120b3..88ba94a077543b121543c2462b27e713e59fdb73 100644 (file)
@@ -8,6 +8,7 @@
                window.onready = function() { error = "Called window.onready"; };
        </script>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <form>
@@ -16,7 +17,7 @@
        <script>
                jQuery(function() {
                        setTimeout( function() {
-                               window.parent.iframeCallback( error );
+                               startIframeTest( error );
                        });
                });
        </script>
index a8fa4af0fff6f945477c31879f7b693644a34556..4ebc2c9d338f7153e753d1cdd49f4a36f7f45f73 100644 (file)
@@ -14,8 +14,9 @@
 <body>
 <div id="test"></div>
 <script src="../../jquery.js"></script>
+<script src="../iframeTest.js"></script>
 <script>
-       window.parent.iframeCallback( jQuery( "#test" ).css( 'width' ) );
+       startIframeTest( jQuery( "#test" ).css( 'width' ) );
 </script>
 </body>
 </html>
index 5e6e442a6b402cd12521ab698daf4d9e721cb552..785150eb8f7f4b37f63fd833d91c20e710807921 100644 (file)
@@ -4,9 +4,10 @@
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>IE11 onpageshow strangeness (#14894)</title>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
        <script>
                $(function(){
-                       window.parent.iframeCallback( $( "body" ).data().result );
+                       startIframeTest( $( "body" ).data().result );
                });
        </script>
 </head>
index c977fac96565ded4c380e2b2ad40bbbb1c10147c..9d6a7291d855fb89c93a5aff8a6fe475cdb491a5 100644 (file)
@@ -8,14 +8,13 @@
                        height: 1000px;
                }
        </style>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <div>
                <script src="../../jquery.js"></script>
                <script>
-                       jQuery( function() {
-                               window.parent.iframeCallback( jQuery, window, document );
-                       } );
+                       jQuery( startIframeTest );
                </script>
        </div>
 </body>
index a9a9765184fa8bf101c02a2221285d23adeeea89..1940e8b61de8fad7008eb2031568fe8e9b6cb1ab 100644 (file)
@@ -5,12 +5,13 @@
        <title>.focus() (activeElement access #13393)</title>
 
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <a href="#" id="frame-link"></a>
        <script>
                jQuery( "#frame-link" ).trigger( "focus" );
-               window.parent.iframeCallback( true );
+               startIframeTest( true );
        </script>
 </body>
 </html>
index 487f8de8fd6354b68762f9c544dd4b6c8d4a2f2e..6dd187e902eab6b2ae33463e0793511d3d6e6389 100644 (file)
@@ -5,13 +5,14 @@
        <title>focusin event cross-frame (#14180)</title>
 
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
 </head>
 <body>
        <input type="text" id="frame-input" />
        <script>
                // Call parent when this frame is fully loaded, it will mess with #frame-input
                jQuery( window ).one( "load", function() {
-                       window.parent.iframeCallback( document );
+                       startIframeTest();
                });
        </script>
 </body>
index 77b37104d0fefeb877c302e33c3196c24276dad1..3fb25f907dc62c4d554b2166b17bba470753a5fd 100644 (file)
@@ -4,13 +4,14 @@
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>Test case for gh-2100</title>
 <script src="../../jquery.js"></script>
+<script src="../iframeTest.js"></script>
 </head>
 <body>
 
 <script type="text/javascript">
-jQuery( document ).ready(function () {
-       window.parent.iframeCallback( jQuery("#container").length === 1 );
-});
+jQuery( function () {
+       startIframeTest( jQuery("#container").length === 1 );
+} );
 </script>
 
 <!-- external resources that come before elements trick
index 17b6e7f2c6e6277b6663ab5e2e3608f9517156bf..c6e086245af556d1acee2088efbec43bf32293eb 100644 (file)
@@ -4,10 +4,11 @@
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>Test case for jQuery ticket #11470</title>
 <script src="../../jquery.js"></script>
+<script src="../iframeTest.js"></script>
 <script type="text/javascript">
 jQuery.when( jQuery.ready ).done(function() {
        jQuery("body").append("<div>modifying DOM</div>");
-       window.parent.iframeCallback( $("div").text() === "modifying DOM" );
+       startIframeTest( $("div").text() === "modifying DOM" );
 });
 </script>
 </head>
index dfa9ac33716d69a9488114ca655db9b6ca0b23e8..61a50e423c47e3169e4303083ae3cd60bf75fe35 100644 (file)
@@ -4,12 +4,13 @@
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>Test case for jQuery ticket #10067</title>
 <script src="../../jquery.js"></script>
+<script src="../iframeTest.js"></script>
 </head>
 <body>
 
 <script type="text/javascript">
 jQuery( document ).ready(function () {
-       window.parent.iframeCallback( jQuery('#container').length === 1 );
+       startIframeTest( jQuery('#container').length === 1 );
 });
 </script>
 
index a7879c77284bc0e814bf0f262fcfd699b83b8290..02be59d48065eae3d41db90e55dc6f1952347057 100644 (file)
@@ -1,6 +1,7 @@
 <!doctype html>
 <html>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
        <script>
                var called = false,
                        error = false;
@@ -12,7 +13,7 @@
                        return "maybe";
                }).on( "load", function( event ) {
                        $( window ).triggerHandler( "beforeunload" );
-                       window.parent.iframeCallback( called && !error );
+                       startIframeTest( called && !error );
                });
        </script>
 </html>
diff --git a/test/data/iframeTest.js b/test/data/iframeTest.js
new file mode 100644 (file)
index 0000000..877e884
--- /dev/null
@@ -0,0 +1,8 @@
+
+window.startIframeTest = function() {
+       var args = Array.prototype.slice.call( arguments );
+
+       // Note: jQuery may be undefined if page did not load it
+       args.unshift( window.jQuery, window, document );
+       window.parent.iframeCallback.apply( null, args );
+};
index 14df26a69be2b8ab6a0a8eddcacd99bea1257c84..e74872ad08a8775a13e6b5fd29aff8ab545600fa 100644 (file)
@@ -7,6 +7,7 @@
        <body>
                <div id="qunit-fixture"></div>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script>
                        var script = document.getElementsByTagName( "script" )[ 0 ],
                                div = document.createElement( "div" ),
@@ -25,7 +26,7 @@
                                        error = e;
                                }
 
-                               window.parent.iframeCallback({
+                               startIframeTest({
                                        status: success,
                                        description: "buildFragment sets the context without throwing an exception" +
                                                ( error ? ": " + error : "" )
index 6958453c5b57e937aec146ce5f7796f51146d77a..1b75e3a0aafaef1ff2b927b2fd023510324e551c 100644 (file)
@@ -7,12 +7,9 @@
        <body>
                <div id="qunit-fixture"></div>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script>
-                       window.parent.iframeCallback(
-                               window,
-                               document.body,
-                               "<script>window.scriptTest = true;<\x2fscript>"
-                       );
+                       startIframeTest();
                </script>
        </body>
 </html>
index 84a9e33de49f854585cdc29dd6eff6a7fe215baa..9d87004652cfd16cd51a24d24bb751c1aa539de2 100644 (file)
@@ -16,6 +16,7 @@
                        #positionTest { position: absolute; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                $(".absolute").click(function() {
@@ -24,7 +25,7 @@
                                        $(this).css({ top: pos.top, left: pos.left });
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index cada87a156a395638b48e0ceda9ca34ccd63d27e..75757d7e605dc2b2327599f85cdb2ed4d8398ea1 100644 (file)
                        #firstElement { width: 50px; height: 50px; background: green; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                $("body").click(function() {
                                        $("marker").css( $(this).offset() );
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index e543895963cfed8c2d4a441925b3b42ac30904fb..48a2c479756956ae77e833cfc1371fd21c9fd8ba 100644 (file)
@@ -13,6 +13,7 @@
                        #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                window.scrollTo(1000,1000);
@@ -20,7 +21,7 @@
                                        $("#marker").css( $(this).offset() );
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index b413e05ee348fd6edd52163a2131091a2d249cd2..288fd4ea3828fe6b24f393db7ebc1adb82564e09 100644 (file)
@@ -12,6 +12,7 @@
                        #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                $(".relative").click(function() {
@@ -20,7 +21,7 @@
                                        $(this).css({ position: 'absolute', top: pos.top, left: pos.left });
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index 49304eee70d0631c31ec58c36449f07886f9df9f..28cade1c377c299848ba3f099306548ff8b308f7 100644 (file)
@@ -15,6 +15,7 @@
                        #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                window.scrollTo(1000,1000);
@@ -24,7 +25,7 @@
                                        $("#marker").css( $(this).offset() );
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index 125ad740f46fc43b1d45b728cf959ae10f5e5be5..1f4c3dc3dc5e3b1d0ad8df0872e70e3a504e8ae6 100644 (file)
@@ -11,6 +11,7 @@
                        #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                $(".static").click(function() {
@@ -19,7 +20,7 @@
                                        $(this).css({ position: 'absolute', top: pos.top, left: pos.left });
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index 1e37957ce49f4c1c48a73d306f6808cffe997ce5..eeac19b77c7e3ef56c73b197eb4019c2a8c5e24a 100644 (file)
                        #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
                </style>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script type="text/javascript" charset="utf-8">
                        jQuery(function($) {
                                $("table, th, td").click(function() {
                                        $("#marker").css( $(this).offset() );
                                        return false;
                                });
-                               window.parent.iframeCallback( jQuery, window, document );
+                               startIframeTest();
                        });
                </script>
        </head>
index bf0e5ba5e1ff2e67a45c082b9679c6e8e89171db..35c583cd0b40f4a3c23dda33e7455d935de63bbb 100644 (file)
@@ -5,7 +5,7 @@
        <title>jQuery selector - attributes</title>
 
        <script src="../../jquery.js"></script>
-
+       <script src="../iframeTest.js"></script>
        <script id="script1"
                        defer
                        async></script>
@@ -16,9 +16,7 @@
                document.createElement('article');
                document.createElement('details');
 
-               jQuery( function() {
-                       window.parent.iframeCallback( jQuery, window, document );
-               } );
+               jQuery( startIframeTest );
        </script>
 </head>
 <body>
index 4320fdcfdb06ba12eaeb92c5dabafdb0d7a8aba7..513390cabbba06e639b88d7b25ea24c7b5195f69 100644 (file)
@@ -5,6 +5,7 @@
        <title>jQuery selector - sizzle cache</title>
 
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
        <script>
                document.write(
                        "<script>var $cached = jQuery.noConflict(true);<\x2Fscript>" +
@@ -18,9 +19,7 @@
                <a href="#" id="collision">Worlds collide</a>
        </div>
        <script>
-               jQuery( function() {
-                       window.parent.iframeCallback( jQuery, window, document );
-               } );
+               jQuery( startIframeTest );
        </script>
 </body>
 </html>
index cac099805b7e0fd3360aba13d2d2799c128c4b75..d95f39d57185a469095bcfce0ef3f07e6fa87c4b 100644 (file)
 <body>
        <div>
                <script src="../../jquery.js"></script>
+               <script src="../iframeTest.js"></script>
                <script src="getComputedSupport.js"></script>
        </div>
        <script>
-               window.parent.iframeCallback( jQuery( "body" ).css( "backgroundColor" ),
+               startIframeTest( jQuery( "body" ).css( "backgroundColor" ),
                                getComputedSupport( jQuery.support ) );
        </script>
 </body>
index 5ebdcea08f57fa8940d1d1593a02217221e36cc2..4d55bdaa1e92a65747a0d2a50803eaeb8103665a 100644 (file)
@@ -1,3 +1,3 @@
 jQuery( function() {
-       parent.iframeCallback( getComputedSupport( jQuery.support ) );
+       startIframeTest( getComputedSupport( jQuery.support ) );
 } );
index 0783e1774b3b4787a4683281a14e1af1e793360f..446000239936ddf9a171c9075fb3187d9793e559 100644 (file)
@@ -9,6 +9,7 @@
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>CSP Test Page</title>
        <script src="../../jquery.js"></script>
+       <script src="../iframeTest.js"></script>
        <script src="csp.js"></script>
        <script src="getComputedSupport.js"></script>
 </head>
index 70c9bbd5a4e75422ec1a458588e412cd632f0435..40ac0211435573748a285689bed925a2ac632c00 100644 (file)
@@ -232,15 +232,15 @@ this.ajaxTest = function( title, expect, options ) {
        } );
 };
 
-this.testIframeWithCallback = function( title, fileName, func ) {
-       QUnit.test( title, 1, function( assert ) {
+this.testIframe = function( title, fileName, func ) {
+       QUnit.test( title, function( assert ) {
                var iframe;
                var done = assert.async();
 
                window.iframeCallback = function() {
                        var args = Array.prototype.slice.call( arguments );
 
-                       args.push( assert );
+                       args.unshift( assert );
 
                        setTimeout( function() {
                                this.iframeCallback = undefined;
@@ -248,7 +248,6 @@ this.testIframeWithCallback = function( title, fileName, func ) {
                                func.apply( this, args );
                                func = function() {};
                                iframe.remove();
-
                                done();
                        } );
                };
index 297f051d9f465f07468a19d9d461b450bd1926c0..1082ce88ef9b0a6e06aec36f990eae9c8cf814d0 100644 (file)
@@ -28,7 +28,7 @@ QUnit.module( "ajax", {
 
 //----------- jQuery.ajax()
 
-       testIframeWithCallback(
+       testIframe(
                "XMLHttpRequest - Attempt to block tests because of dangling XHR requests (IE)",
                "ajax/unreleasedXHR.html",
                function( assert ) {
@@ -1826,10 +1826,10 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
                };
        } );
 
-       testIframeWithCallback(
+       testIframe(
                "#14379 - jQuery.ajax() on unload",
                "ajax/onunload.html",
-               function( status, assert ) {
+               function( assert, jQuery, window, document, status ) {
                        assert.expect( 1 );
                        assert.strictEqual( status, "success", "Request completed" );
                }
index a42346d007e4c314f53b36f0cfdba6d209d6fc1e..57c8dd9e995c2807beff3c718a219fafa8fe884c 100644 (file)
@@ -1648,14 +1648,14 @@ QUnit.test( "jQuery.camelCase()", function( assert ) {
        } );
 } );
 
-testIframeWithCallback(
+testIframe(
        "Conditional compilation compatibility (#13274)",
        "core/cc_on.html",
-       function( cc_on, errors, $, assert ) {
+       function( assert, jQuery, window, document, cc_on, errors ) {
                assert.expect( 3 );
                assert.ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) );
                assert.deepEqual( errors, [], "No errors" );
-               assert.ok( $(), "jQuery executes" );
+               assert.ok( jQuery(), "jQuery executes" );
        }
 );
 
@@ -1663,29 +1663,29 @@ testIframeWithCallback(
 // This makes this test fail but it doesn't seem to cause any real-life problems so blacklisting
 // this test there is preferred to complicating the hard-to-test core/ready code further.
 if ( !/iphone os 7_/i.test( navigator.userAgent ) ) {
-       testIframeWithCallback(
+       testIframe(
                "document ready when jQuery loaded asynchronously (#13655)",
                "core/dynamic_ready.html",
-               function( ready, assert ) {
+               function( assert, jQuery, window, document, ready ) {
                        assert.expect( 1 );
                        assert.equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" );
                }
        );
 }
 
-testIframeWithCallback(
+testIframe(
        "Tolerating alias-masked DOM properties (#14074)",
        "core/aliased.html",
-       function( errors, assert ) {
+       function( assert, jQuery, window, document, errors ) {
                assert.expect( 1 );
                assert.deepEqual( errors, [], "jQuery loaded" );
        }
 );
 
-testIframeWithCallback(
+testIframe(
        "Don't call window.onready (#14802)",
        "core/onready.html",
-       function( error, assert ) {
+       function( assert, jQuery, window, document, error ) {
                assert.expect( 1 );
                assert.equal( error, false, "no call to user-defined onready" );
        }
index e04ad5dea0b86b5dac6aca345f892758ffd94739..38d5ed6d15a5b8eeeff7a84cf92caafaa7ccb98d 100644 (file)
@@ -1139,10 +1139,10 @@ QUnit.test( "css('width') and css('height') should respect box-sizing, see #1100
        assert.equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" );
 } );
 
-testIframeWithCallback(
+testIframe(
        "css('width') should work correctly before document ready (#14084)",
        "css/cssWidthBeforeDocReady.html",
-       function( cssWidthBeforeDocReady, assert ) {
+       function( assert, jQuery, window, document, cssWidthBeforeDocReady ) {
                assert.expect( 1 );
                assert.strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" );
        }
index 19f32504bff51d00eba38abd66ec6c3f83a5e662..9a9371aae3eaf650f58f0c0fe39a2f58d26fed82 100644 (file)
@@ -857,10 +857,10 @@ QUnit.test( "Check proper data removal of non-element descendants nodes (#8335)"
        assert.ok( !text.data( "test" ), "Be sure data is not stored in non-element" );
 } );
 
-testIframeWithCallback(
+testIframe(
        "enumerate data attrs on body (#14894)",
        "data/dataAttrs.html",
-       function( result, assert ) {
+       function( assert, jQuery, window, document, result ) {
                assert.expect( 1 );
                assert.equal( result, "ok", "enumeration of data- attrs on body" );
        }
index 1f8ff5007f025577e1207b484b4dfdc170a52819..8d304c435bdf0dc540d0befe4d14c56053295e08 100644 (file)
@@ -469,10 +469,10 @@ QUnit.test( "setters with and without box-sizing:border-box", function( assert )
        } );
 } );
 
-testIframeWithCallback(
+testIframe(
        "window vs. large document",
        "dimensions/documentLarge.html",
-       function( jQuery, window, document, assert ) {
+       function( assert, jQuery, window, document ) {
                assert.expect( 2 );
 
                assert.ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
index 1c46b4607b74683ce8c935a7a1d2d6b282868de6..5b00c7c3bbc4b98b6187ea4be00aaa8699025ac1 100644 (file)
@@ -2476,10 +2476,10 @@ QUnit.test( "focusin using non-element targets", function( assert ) {
 
 } );
 
-testIframeWithCallback(
+testIframe(
        "focusin from an iframe",
        "event/focusinCrossFrame.html",
-       function( frameDoc, assert ) {
+       function( assert, framejQuery, frameWin, frameDoc ) {
                assert.expect( 1 );
 
                var input = jQuery( frameDoc ).find( "#frame-input" );
@@ -2507,10 +2507,10 @@ testIframeWithCallback(
        }
 );
 
-testIframeWithCallback(
+testIframe(
        "jQuery.ready promise",
        "event/promiseReady.html",
-       function( isOk, assert ) {
+       function( assert, jQuery, window, document, isOk ) {
                assert.expect( 1 );
                assert.ok( isOk, "$.when( $.ready ) works" );
        }
@@ -2518,29 +2518,29 @@ testIframeWithCallback(
 
 // need PHP here to make the incepted IFRAME hang
 if ( hasPHP ) {
-       testIframeWithCallback(
+       testIframe(
                "jQuery.ready uses interactive",
                "event/interactiveReady.html",
-               function( isOk, assert ) {
+       function( assert, jQuery, window, document, isOk ) {
                        assert.expect( 1 );
                        assert.ok( isOk, "jQuery fires ready when the DOM can truly be interacted with" );
                }
        );
 }
 
-testIframeWithCallback(
+testIframe(
        "Focusing iframe element",
        "event/focusElem.html",
-       function( isOk, assert ) {
+       function( assert, jQuery, window, document, isOk ) {
                assert.expect( 1 );
                assert.ok( isOk, "Focused an element in an iframe" );
        }
 );
 
-testIframeWithCallback(
+testIframe(
        "triggerHandler(onbeforeunload)",
        "event/triggerunload.html",
-       function( isOk, assert ) {
+       function( assert, jQuery, window, document, isOk ) {
                assert.expect( 1 );
                assert.ok( isOk, "Triggered onbeforeunload without an error" );
        }
@@ -2548,10 +2548,10 @@ testIframeWithCallback(
 
 // need PHP here to make the incepted IFRAME hang
 if ( hasPHP ) {
-       testIframeWithCallback(
+       testIframe(
                "jQuery.ready synchronous load with long loading subresources",
                "event/syncReady.html",
-               function( isOk, assert ) {
+               function( assert, jQuery, window, document, isOk ) {
                        assert.expect( 1 );
                        assert.ok( isOk, "jQuery loaded synchronously fires ready when the DOM can truly be interacted with" );
                }
index d439ba11c206c64c8ad94ed5094b919fa151e139..8f8d784330294b959d56edebf04d19aa035da90a 100644 (file)
@@ -2237,21 +2237,21 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
        ].join( "\n" ) ).appendTo( "#qunit-fixture" );
 } );
 
-testIframeWithCallback(
+testIframe(
        "domManip tolerates window-valued document[0] in IE9/10 (trac-12266)",
        "manipulation/iframe-denied.html",
-       function( test, assert ) {
+       function( assert, jQuery, window, document, test ) {
                assert.expect( 1 );
                assert.ok( test.status, test.description );
        }
 );
 
-testIframeWithCallback(
+testIframe(
        "domManip executes scripts in iframes in the iframes' context",
        "manipulation/scripts-context.html",
-       function( frameWindow, bodyElement, html, assert ) {
+       function( assert, framejQuery, frameWindow, frameDocument ) {
                assert.expect( 2 );
-               jQuery( bodyElement ).append( html );
+               jQuery( frameDocument.body ).append( "<script>window.scriptTest = true;<\x2fscript>" );
                assert.ok( !window.scriptTest, "script executed in iframe context" );
                assert.ok( frameWindow.scriptTest, "script executed in iframe context" );
        }
index 65483107eb3026e6376df0a4fb10d1a16d91852f..4caf36873e20af91b20af2285183d761aeee2eac 100644 (file)
@@ -68,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)" );
 } );
 
-testIframeWithCallback( "absolute", "offset/absolute.html", function( $, iframe, document, assert ) {
+testIframe( "absolute", "offset/absolute.html", function( assert, $, iframe ) {
        assert.expect( 4 );
 
        var doc = iframe.document,
@@ -93,7 +93,7 @@ testIframeWithCallback( "absolute", "offset/absolute.html", function( $, iframe,
        } );
 } );
 
-testIframeWithCallback( "absolute", "offset/absolute.html", function( $, window, document, assert ) {
+testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
        assert.expect( 178 );
 
        var tests, offset;
@@ -178,7 +178,7 @@ testIframeWithCallback( "absolute", "offset/absolute.html", function( $, window,
        } );
 } );
 
-testIframeWithCallback( "relative", "offset/relative.html", function( $, window, document, assert ) {
+testIframe( "relative", "offset/relative.html", function( assert, $ ) {
        assert.expect( 64 );
 
        // get offset
@@ -236,7 +236,7 @@ testIframeWithCallback( "relative", "offset/relative.html", function( $, window,
        } );
 } );
 
-testIframeWithCallback( "static", "offset/static.html", function( $, window, document, assert ) {
+testIframe( "static", "offset/static.html", function( assert, $ ) {
        assert.expect( 80 );
 
        // get offset
@@ -298,7 +298,7 @@ testIframeWithCallback( "static", "offset/static.html", function( $, window, doc
        } );
 } );
 
-testIframeWithCallback( "fixed", "offset/fixed.html", function( $, window, document, assert ) {
+testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
        assert.expect( 34 );
 
        var tests, $noTopLeft;
@@ -388,7 +388,7 @@ testIframeWithCallback( "fixed", "offset/fixed.html", function( $, window, docum
        }
 } );
 
-testIframeWithCallback( "table", "offset/table.html", function( $, window, document, assert ) {
+testIframe( "table", "offset/table.html", function( assert, $ ) {
        assert.expect( 4 );
 
        assert.equal( $( "#table-1" ).offset().top, 6, "jQuery('#table-1').offset().top" );
@@ -398,7 +398,7 @@ testIframeWithCallback( "table", "offset/table.html", function( $, window, docum
        assert.equal( $( "#th-1" ).offset().left, 10, "jQuery('#th-1').offset().left" );
 } );
 
-testIframeWithCallback( "scroll", "offset/scroll.html", function( $, win, doc, assert ) {
+testIframe( "scroll", "offset/scroll.html", function( assert, $, win ) {
        assert.expect( 26 );
 
        assert.equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" );
@@ -457,7 +457,7 @@ testIframeWithCallback( "scroll", "offset/scroll.html", function( $, win, doc, a
        assert.strictEqual( $().scrollLeft(), undefined, "jQuery().scrollLeft() testing getter on empty jquery object" );
 } );
 
-testIframeWithCallback( "body", "offset/body.html", function( $, window, document, assert ) {
+testIframe( "body", "offset/body.html", function( assert, $ ) {
        assert.expect( 4 );
 
        assert.equal( $( "body" ).offset().top, 1, "jQuery('#body').offset().top" );
index 1b5de13174ca939114cba8bc9125a7f85c11b700..4c24494254f331612014f25187c7a99a0035d7a8 100644 (file)
@@ -289,10 +289,10 @@ QUnit[ jQuery.find.compile ? "test" : "skip" ]( "disconnected nodes", function(
        assert.equal( $opt.is( ":selected" ), true, "selected option" );
 } );
 
-testIframeWithCallback(
+testIframe(
        "attributes - jQuery.attr",
        "selector/html5_selector.html",
-       function( jQuery, window, document, assert ) {
+       function( assert, jQuery, window, document ) {
                assert.expect( 38 );
 
                /**
@@ -489,10 +489,10 @@ QUnit.test( "jQuery.uniqueSort", function( assert ) {
        assert.strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" );
 } );
 
-testIframeWithCallback(
+testIframe(
        "Sizzle cache collides with multiple Sizzles on a page",
        "selector/sizzle_cache.html",
-       function( jQuery, window, document, assert ) {
+       function( assert, jQuery, window, document ) {
                var $cached = window[ "$cached" ];
 
                assert.expect( 4 );
index 3e6af1ae7daa85ba8acbffc0c5162c2ce533020e..ff5d66f870d09fac3a659b77e5657372d460ea72 100644 (file)
@@ -18,10 +18,10 @@ function getComputedSupport( support ) {
 }
 
 if ( jQuery.css ) {
-       testIframeWithCallback(
+       testIframe(
                "body background is not lost if set prior to loading jQuery (#9239)",
                "support/bodyBackground.html",
-               function( color, support, assert ) {
+               function( assert, jQuery, window, document, color, support ) {
                        assert.expect( 2 );
                        var okValue = {
                                "#000000": true,
@@ -37,10 +37,10 @@ if ( jQuery.css ) {
 
 // This test checks CSP only for browsers with "Content-Security-Policy" header support
 // i.e. no old WebKit or old Firefox
-testIframeWithCallback(
+testIframe(
        "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
        "support/csp.php",
-       function( support, assert ) {
+       function( assert, jQuery, window, document, support ) {
                var done = assert.async();
 
                assert.expect( 2 );