aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <4timmywil@gmail.com>2018-01-16 15:18:32 -0500
committerTimmy Willison <4timmywil@gmail.com>2018-01-16 15:18:32 -0500
commit625e19cd9be4898939a7c40dbeb2b17e40df9d54 (patch)
tree4f703e9eb6411a3e0380f800a4953639b5a29d24 /test
parentfa793bee203ac14021188e12a126e195e83f1647 (diff)
downloadjquery-625e19cd9be4898939a7c40dbeb2b17e40df9d54.tar.gz
jquery-625e19cd9be4898939a7c40dbeb2b17e40df9d54.zip
Tests: ensure that module assertions run on supported browsers
- Also fixes tests for karma, where the URL for the module is different Ref gh-3871
Diffstat (limited to 'test')
-rw-r--r--test/data/inner_module.js2
-rw-r--r--test/data/testinit.js10
-rw-r--r--test/unit/manipulation.js22
3 files changed, 25 insertions, 9 deletions
diff --git a/test/data/inner_module.js b/test/data/inner_module.js
index a89a39d27..7f359ed95 100644
--- a/test/data/inner_module.js
+++ b/test/data/inner_module.js
@@ -1 +1 @@
-window.ok( true, "evaluated: innert module with src" );
+window.ok( true, "evaluated: inner module with src" );
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 211824a89..a91e59b6a 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -284,7 +284,17 @@ if ( window.__karma__ ) {
QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";
+// Async test for module script type support
+function moduleTypeSupported() {
+ var script = document.createElement( "script" );
+ script.type = "module";
+ script.text = "QUnit.moduleTypeSupported = true";
+ document.head.appendChild( script ).parentNode.removeChild( script );
+}
+moduleTypeSupported();
+
this.loadTests = function() {
+
// Get testSubproject from testrunner first
require( [ "data/testrunner.js" ], function() {
var i = 0,
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index bfe41ed4e..660dad773 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1797,20 +1797,26 @@ QUnit.test( "html(Function)", function( assert ) {
testHtml( manipulationFunctionReturningObj, assert );
} );
-QUnit.test( "html(script type module)", function( assert ) {
- assert.expect( 1 );
- var fixture = jQuery( "#qunit-fixture" ),
- tmp = fixture.html(
+QUnit[ QUnit.moduleTypeSupported ? "test" : "skip" ]( "html(script type module)", function( assert ) {
+ assert.expect( 4 );
+ var done = assert.async(),
+ $fixture = jQuery( "#qunit-fixture" );
+
+ $fixture.html(
[
"<script type='module'>ok( true, 'evaluated: module' );</script>",
- "<script type='module' src='./data/module.js'></script>",
+ "<script type='module' src='" + url( "module.js" ) + "'></script>",
"<div>",
"<script type='module'>ok( true, 'evaluated: inner module' );</script>",
- "<script type='module' src='./data/inner_module.js'></script>",
+ "<script type='module' src='" + url( "inner_module.js" ) + "'></script>",
"</div>"
].join( "" )
- ).find( "script" );
- assert.equal( tmp.length, 4, "All script tags remain." );
+ );
+
+ // Allow asynchronous script execution to generate assertions
+ setTimeout( function() {
+ done();
+ }, 1000 );
} );
QUnit.test( "html(Function) with incoming value -- direct selection", function( assert ) {