Skip to content

Commit 08d73d7

Browse files
committed
Tests: Make iframe tests wait after checking isReady
Ref gh-3040
1 parent 755e7cc commit 08d73d7

File tree

15 files changed

+48
-72
lines changed

15 files changed

+48
-72
lines changed

README.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -340,32 +340,25 @@ url("data/test.php?foo=bar");
340340
```
341341

342342

343-
### Load tests in an iframe ###
344-
345-
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
346-
and fires the given callback on jQuery ready (using the jQuery loading from that page)
347-
and passes the iFrame's jQuery to the callback.
348-
349-
```js
350-
testIframe( fileName, testName, callback );
351-
```
352-
353-
Callback arguments:
343+
### Load tests in an iframe (window.iframeCallback) ###
354344

355345
```js
356-
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument );
346+
testIframeWithCallback( testName, fileName,
347+
function callback( arg1, arg2, ... assert ) {
348+
...
349+
} );
357350
```
358351

359-
### Load tests in an iframe (window.iframeCallback) ###
360-
361352
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
362-
The given callback is fired when window.iframeCallback is called by the page.
363-
The arguments passed to the callback are the same as the
364-
arguments passed to window.iframeCallback, whatever that may be.
353+
The iframe page is responsible for determining when `window.parent.iframeCallback`
354+
should be called, for example at document ready or window.onload time.
355+
Arguments passed to the callback are the same as the arguments passed
356+
to `window.parent.iframeCallback` by the iframe, plus the QUnit `assert`
357+
object from the `QUnit.test()` that this wrapper sets up for you.
358+
The iframe should send any objects needed by the unit test via arguments, for example
359+
its `jQuery`, `window`, and `document` objects from the iframe.
360+
365361

366-
```js
367-
testIframeWithCallback( testName, fileName, callback );
368-
```
369362

370363
Questions?
371364
----------

test/data/dimensions/documentLarge.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
<body>
1313
<div>
1414
<script src="../../jquery.js"></script>
15+
<script>
16+
jQuery( function() {
17+
window.parent.iframeCallback( jQuery, window, document );
18+
} );
19+
</script>
1520
</div>
1621
</body>
1722
</html>

test/data/offset/absolute.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$(this).css({ top: pos.top, left: pos.left });
2525
return false;
2626
});
27+
window.parent.iframeCallback( jQuery, window, document );
2728
});
2829
</script>
2930
</head>

test/data/offset/body.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
$("marker").css( $(this).offset() );
1717
return false;
1818
});
19+
window.parent.iframeCallback( jQuery, window, document );
1920
});
2021
</script>
2122
</head>

test/data/offset/fixed.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$("#marker").css( $(this).offset() );
2121
return false;
2222
});
23+
window.parent.iframeCallback( jQuery, window, document );
2324
});
2425
</script>
2526
</head>

test/data/offset/relative.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$(this).css({ position: 'absolute', top: pos.top, left: pos.left });
2121
return false;
2222
});
23+
window.parent.iframeCallback( jQuery, window, document );
2324
});
2425
</script>
2526
</head>

test/data/offset/scroll.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$("#marker").css( $(this).offset() );
2525
return false;
2626
});
27+
window.parent.iframeCallback( jQuery, window, document );
2728
});
2829
</script>
2930
</head>

test/data/offset/static.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$(this).css({ position: 'absolute', top: pos.top, left: pos.left });
2020
return false;
2121
});
22+
window.parent.iframeCallback( jQuery, window, document );
2223
});
2324
</script>
2425
</head>

test/data/offset/table.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$("#marker").css( $(this).offset() );
1818
return false;
1919
});
20+
window.parent.iframeCallback( jQuery, window, document );
2021
});
2122
</script>
2223
</head>

test/data/selector/html5_selector.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
document.createElement('audio');
1616
document.createElement('article');
1717
document.createElement('details');
18+
19+
jQuery( function() {
20+
window.parent.iframeCallback( jQuery, window, document );
21+
} );
1822
</script>
1923
</head>
2024
<body>

0 commit comments

Comments
 (0)