aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2016-04-10 15:42:44 -0400
committerDave Methvin <dave.methvin@gmail.com>2016-04-11 13:32:51 -0400
commite5ffcb0838c894e26f4ff32dfec162cf624d8d7d (patch)
tree1a57c3a0cbf026dcd98d1f821dc9ed6f848f46d3 /README.md
parent08d73d7f9c7eec2f0abd14d00bf903625728ef17 (diff)
downloadjquery-e5ffcb0838c894e26f4ff32dfec162cf624d8d7d.tar.gz
jquery-e5ffcb0838c894e26f4ff32dfec162cf624d8d7d.zip
Tests: Refactor testIframe() to make it DRYer and more consistent
Ref gh-3040 Closes gh-3049
Diffstat (limited to 'README.md')
-rw-r--r--README.md30
1 files changed, 19 insertions, 11 deletions
diff --git a/README.md b/README.md
index 5c1a90c04..9e5b130c4 100644
--- 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?