From 625e19cd9be4898939a7c40dbeb2b17e40df9d54 Mon Sep 17 00:00:00 2001 From: Timmy Willison <4timmywil@gmail.com> Date: Tue, 16 Jan 2018 15:18:32 -0500 Subject: [PATCH] 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 --- test/data/inner_module.js | 2 +- test/data/testinit.js | 10 ++++++++++ test/unit/manipulation.js | 22 ++++++++++++++-------- 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( [ "", - "", + "", "