|
2 | 2 | ( function() { |
3 | 3 | /* global loadTests: false */ |
4 | 4 |
|
5 | | - var src, |
6 | | - path = window.location.pathname.split( "test" )[ 0 ], |
| 5 | + var path = window.location.pathname.split( "test" )[ 0 ], |
7 | 6 | QUnit = window.QUnit || parent.QUnit, |
8 | | - require = window.require || parent.require; |
9 | | - |
10 | | - // iFrames won't load AMD (the iframe tests synchronously expect jQuery to be there) |
11 | | - QUnit.config.urlConfig.push( { |
12 | | - id: "amd", |
13 | | - label: "Load with AMD", |
14 | | - tooltip: "Load the AMD jQuery file (and its dependencies)" |
15 | | - } ); |
16 | | - |
17 | | - // If QUnit is on window, this is the main window |
18 | | - // This detection allows AMD tests to be run in an iframe |
19 | | - if ( QUnit.urlParams.amd && window.QUnit ) { |
| 7 | + require = window.require || parent.require, |
| 8 | + |
| 9 | + // Default to unminified jQuery for directly-opened iframes |
| 10 | + urlParams = QUnit ? |
| 11 | + QUnit.urlParams : |
| 12 | + { dev: true }, |
| 13 | + src = urlParams.dev ? |
| 14 | + "dist/jquery.js" : |
| 15 | + "dist/jquery.min.js"; |
| 16 | + |
| 17 | + // Define configuration parameters controlling how jQuery is loaded |
| 18 | + if ( QUnit ) { |
| 19 | + QUnit.config.urlConfig.push( { |
| 20 | + id: "amd", |
| 21 | + label: "Load with AMD", |
| 22 | + tooltip: "Load the AMD jQuery file (and its dependencies)" |
| 23 | + } ); |
| 24 | + QUnit.config.urlConfig.push( { |
| 25 | + id: "dev", |
| 26 | + label: "Load unminified", |
| 27 | + tooltip: "Load the development (unminified) jQuery file" |
| 28 | + } ); |
| 29 | + } |
| 30 | + |
| 31 | + // Honor AMD loading on the main window (detected by seeing QUnit on it). |
| 32 | + // This doesn't apply to iframes because they synchronously expect jQuery to be there. |
| 33 | + if ( urlParams.amd && window.QUnit ) { |
20 | 34 | require.config( { |
21 | 35 | baseUrl: path |
22 | 36 | } ); |
|
28 | 42 | } else { |
29 | 43 | require( [ src ] ); |
30 | 44 | } |
31 | | - return; |
32 | | - } |
33 | 45 |
|
34 | | - // Config parameter to use minified jQuery |
35 | | - QUnit.config.urlConfig.push( { |
36 | | - id: "dev", |
37 | | - label: "Load unminified", |
38 | | - tooltip: "Load the development (unminified) jQuery file" |
39 | | - } ); |
40 | | - if ( QUnit.urlParams.dev ) { |
41 | | - src = "dist/jquery.js"; |
| 46 | + // Otherwise, load synchronously |
42 | 47 | } else { |
43 | | - src = "dist/jquery.min.js"; |
44 | | - } |
45 | | - |
46 | | - // Load jQuery |
47 | | - document.write( "<script id='jquery-js' src='" + path + src + "'><\x2Fscript>" ); |
| 48 | + document.write( "<script id='jquery-js' src='" + path + src + "'><\x2Fscript>" ); |
48 | 49 |
|
49 | | - // Synchronous-only tests |
50 | | - // Other tests are loaded from the test page |
51 | | - if ( typeof loadTests !== "undefined" ) { |
52 | | - document.write( "<script src='" + path + "test/unit/ready.js'><\x2Fscript>" ); |
| 50 | + // Synchronous-only tests (other tests are loaded from the test page) |
| 51 | + if ( typeof loadTests !== "undefined" ) { |
| 52 | + document.write( "<script src='" + path + "test/unit/ready.js'><\x2Fscript>" ); |
| 53 | + } |
53 | 54 | } |
54 | 55 |
|
55 | 56 | } )(); |
0 commit comments