1 // Use the right jQuery source on the test page (and iframes)
3 var dynamicImportSource, config, src,
4 parentUrl = window.location.protocol + "//" + window.location.host,
7 function getQUnitConfig() {
8 var config = Object.create( null );
10 // Default to unminified jQuery for directly-opened iframes
15 // QUnit.config is populated from QUnit.urlParams but only at the beginning
16 // of the test run. We need to read both.
17 QUnit.config.urlConfig.forEach( function( entry ) {
18 config[ entry.id ] = QUnit.config[ entry.id ] != null ?
19 QUnit.config[ entry.id ] :
20 QUnit.urlParams[ entry.id ];
27 // Define configuration parameters controlling how jQuery is loaded
29 QUnit.config.urlConfig.push( {
31 label: "Load as modules",
32 tooltip: "Load the jQuery module file (and its dependencies)"
35 label: "Load unminified",
36 tooltip: "Load the development (unminified) jQuery file"
40 config = getQUnitConfig();
46 // Honor ES modules loading on the main window (detected by seeing QUnit on it).
47 // This doesn't apply to iframes because they synchronously expect jQuery to be there.
48 if ( config.esmodules && QUnit ) {
51 // IE doesn't support the dynamic import syntax so it would crash
52 // with a SyntaxError here.
53 dynamicImportSource = "" +
54 "import( `${ parentUrl }/src/jquery.js` )\n" +
55 " .then( ( { jQuery } ) => {\n" +
56 " window.jQuery = jQuery;\n" +
57 " if ( typeof loadTests === \"function\" ) {\n" +
58 " // Include tests if specified\n" +
62 " .catch( error => {\n" +
63 " console.error( error );\n" +
67 eval( dynamicImportSource );
69 // Otherwise, load synchronously
71 document.write( "<script id='jquery-js' nonce='jquery+hardcoded+nonce' src='" + parentUrl + "/" + src + "'><\x2Fscript>" );