@@ -1444,32 +1444,37 @@ describe('jqLite', function() {
14441444 expect ( contents [ 1 ] . data ) . toEqual ( 'before-' ) ;
14451445 } ) ;
14461446
1447- // IE8 does not like this test, although the functionality may still work there.
1448- if ( ! msie || msie > 8 ) {
1449- it ( 'should select all types iframe contents' , function ( ) {
1450- var iframe_ = document . createElement ( 'iframe' ) , tested ,
1451- iframe = jqLite ( iframe_ ) ;
1452- function test ( ) {
1453- var contents = iframe . contents ( ) ;
1454- expect ( contents [ 0 ] ) . toBeTruthy ( ) ;
1455- expect ( contents . length ) . toBe ( 1 ) ;
1456- expect ( contents . prop ( 'nodeType' ) ) . toBe ( 9 ) ;
1457- expect ( contents [ 0 ] . body ) . toBeTruthy ( ) ;
1458- expect ( jqLite ( contents [ 0 ] . body ) . contents ( ) . length ) . toBe ( 3 ) ;
1459- iframe . remove ( ) ;
1460- tested = true ;
1461- }
1462- iframe_ . onload = iframe_ . onreadystatechange = function ( ) {
1463- if ( iframe_ . contentDocument ) test ( ) ;
1464- } ;
1465- iframe_ . src = "/base/test/fixtures/iframe.html" ;
1466- jqLite ( document ) . find ( 'body' ) . append ( iframe ) ;
1447+ it ( 'should select all types iframe contents' , function ( ) {
1448+ // IE8 does not like this test, although the functionality may still work there.
1449+ if ( msie < 9 ) return ;
1450+ var iframe_ = document . createElement ( 'iframe' ) ;
1451+ var tested = false ;
1452+ var iframe = jqLite ( iframe_ ) ;
1453+ function test ( ) {
1454+ var doc = iframe_ . contentDocument || iframe_ . contentWindow . document ;
1455+ doc . body . innerHTML = '\n<span>Text</span>\n' ;
1456+
1457+ var contents = iframe . contents ( ) ;
1458+ expect ( contents [ 0 ] ) . toBeTruthy ( ) ;
1459+ expect ( contents . length ) . toBe ( 1 ) ;
1460+ expect ( contents . prop ( 'nodeType' ) ) . toBe ( 9 ) ;
1461+ expect ( contents [ 0 ] . body ) . toBeTruthy ( ) ;
1462+ expect ( jqLite ( contents [ 0 ] . body ) . contents ( ) . length ) . toBe ( 3 ) ;
1463+ iframe . remove ( ) ;
1464+ doc = null ;
1465+ tested = true ;
1466+ }
1467+ iframe_ . onload = iframe_ . onreadystatechange = function ( ) {
1468+ if ( iframe_ . contentDocument ) test ( ) ;
1469+ } ;
1470+ /* jshint scripturl:true */
1471+ iframe_ . src = 'javascript:false' ;
1472+ jqLite ( document ) . find ( 'body' ) . append ( iframe ) ;
14671473
1468- // This test is potentially flaky on CI cloud instances, so there is a generous
1469- // wait period...
1470- waitsFor ( function ( ) { return tested ; } , 'iframe to load' , 5000 ) ;
1471- } ) ;
1472- }
1474+ // This test is potentially flaky on CI cloud instances, so there is a generous
1475+ // wait period...
1476+ waitsFor ( function ( ) { return tested ; } , 'iframe to load' , 5000 ) ;
1477+ } ) ;
14731478 } ) ;
14741479
14751480
0 commit comments