@@ -2080,7 +2080,7 @@ test( "jQuery.cleanData eliminates all private data (gh-2127)", function() {
20802080 div . remove ( ) ;
20812081} ) ;
20822082
2083- test ( "jQuery.buildFragment - no plain-text caching (Bug # 6779)" , function ( ) {
2083+ test ( "domManip plain-text caching (trac- 6779)" , function ( ) {
20842084
20852085 expect ( 1 ) ;
20862086
@@ -2099,42 +2099,43 @@ test( "jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
20992099 $f . remove ( ) ;
21002100} ) ;
21012101
2102- test ( "jQuery.html - execute scripts escaped with html comment or CDATA (# 9221)" , function ( ) {
2102+ test ( "domManip executes scripts containing html comments or CDATA (trac- 9221)" , function ( ) {
21032103
21042104 expect ( 3 ) ;
21052105
2106- jQuery ( [
2107- "<script type='text/javascript'>" ,
2108- "<!--" ,
2109- "ok( true, '<!-- handled' );" ,
2110- "//-->" ,
2111- "</script>"
2112- ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2113- jQuery ( [
2114- "<script type='text/javascript'>" ,
2115- "<![CDATA[" ,
2116- "ok( true, '<![CDATA[ handled' );" ,
2117- "//]]>" ,
2118- "</script>"
2119- ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2120- jQuery ( [
2121- "<script type='text/javascript'>" ,
2122- "<!--//--><![CDATA[//><!--" ,
2123- "ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );" ,
2124- "//--><!]]>" ,
2125- "</script>"
2126- ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2127- } ) ;
2128-
2129- test ( "jQuery.buildFragment - plain objects are not a document #8950" , function ( ) {
2130-
2131- expect ( 1 ) ;
2132-
2133- try {
2134- jQuery ( "<input type='hidden'>" , { } ) ;
2135- ok ( true , "Does not allow attribute object to be treated like a doc object" ) ;
2136- } catch ( e ) { }
2137- } ) ;
2106+ jQuery ( [
2107+ "<script type='text/javascript'>" ,
2108+ "<!--" ,
2109+ "ok( true, '<!-- handled' );" ,
2110+ "//-->" ,
2111+ "</script>"
2112+ ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2113+
2114+ jQuery ( [
2115+ "<script type='text/javascript'>" ,
2116+ "<![CDATA[" ,
2117+ "ok( true, '<![CDATA[ handled' );" ,
2118+ "//]]>" ,
2119+ "</script>"
2120+ ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2121+
2122+ jQuery ( [
2123+ "<script type='text/javascript'>" ,
2124+ "<!--//--><![CDATA[//><!--" ,
2125+ "ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );" ,
2126+ "//--><!]]>" ,
2127+ "</script>"
2128+ ] . join ( "\n" ) ) . appendTo ( "#qunit-fixture" ) ;
2129+ } ) ;
2130+
2131+ testIframeWithCallback (
2132+ "domManip tolerates window-valued document[0] in IE9/10 (trac-12266)" ,
2133+ "manipulation/iframe-denied.html" ,
2134+ function ( test ) {
2135+ expect ( 1 ) ;
2136+ ok ( test . status , test . description ) ;
2137+ }
2138+ ) ;
21382139
21392140test ( "jQuery.clone - no exceptions for object elements #9587" , function ( ) {
21402141
@@ -2292,12 +2293,6 @@ test( "manipulate mixed jQuery and text (#12384, #12346)", function() {
22922293 equal ( div . find ( "*" ) . length , 3 , "added 2 paragraphs after inner div" ) ;
22932294} ) ;
22942295
2295- testIframeWithCallback ( "buildFragment works even if document[0] is iframe's window object in IE9/10 (#12266)" , "manipulation/iframe-denied.html" , function ( test ) {
2296- expect ( 1 ) ;
2297-
2298- ok ( test . status , test . description ) ;
2299- } ) ;
2300-
23012296test ( "script evaluation (#11795)" , function ( ) {
23022297
23032298 expect ( 13 ) ;
@@ -2381,6 +2376,46 @@ test( "jQuery._evalUrl (#12838)", function() {
23812376 jQuery . _evalUrl = evalUrl ;
23822377} ) ;
23832378
2379+ test ( "jQuery.htmlPrefilter (gh-1747)" , function ( assert ) {
2380+
2381+ assert . expect ( 5 ) ;
2382+
2383+ var expectedArgument ,
2384+ invocations = 0 ,
2385+ htmlPrefilter = jQuery . htmlPrefilter ,
2386+ fixture = jQuery ( "<div/>" ) . appendTo ( "#qunit-fixture" ) ,
2387+ poison = "<script>jQuery.htmlPrefilter.assert.ok( false, 'script not executed' );</script>" ,
2388+ done = assert . async ( ) ;
2389+
2390+ jQuery . htmlPrefilter = function ( html ) {
2391+ invocations ++ ;
2392+ assert . equal ( html , expectedArgument , "Expected input" ) ;
2393+
2394+ // Remove <script> and <del> elements
2395+ return htmlPrefilter . apply ( this , arguments )
2396+ . replace ( / < ( s c r i p t | d e l ) (? = [ \s > ] ) [ \w \W ] * ?< \/ \1\s * > / ig, "" ) ;
2397+ } ;
2398+ jQuery . htmlPrefilter . assert = assert ;
2399+
2400+ expectedArgument = "A-" + poison + "B-" + poison + poison + "C-" ;
2401+ fixture . html ( expectedArgument ) ;
2402+
2403+ expectedArgument = "D-" + poison + "E-" + "<del/><div>" + poison + poison + "</div>" + "F-" ;
2404+ fixture . append ( expectedArgument ) ;
2405+
2406+ expectedArgument = poison ;
2407+ fixture . find ( "div" ) . replaceWith ( expectedArgument ) ;
2408+
2409+ assert . equal ( invocations , 3 , "htmlPrefilter invoked for all DOM manipulations" ) ;
2410+ assert . equal ( fixture . html ( ) , "A-B-C-D-E-F-" , "htmlPrefilter modified HTML" ) ;
2411+
2412+ // Allow asynchronous script execution to generate assertions
2413+ setTimeout ( function ( ) {
2414+ jQuery . htmlPrefilter = htmlPrefilter ;
2415+ done ( ) ;
2416+ } , 100 ) ;
2417+ } ) ;
2418+
23842419test ( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)" , function ( ) {
23852420
23862421 expect ( 10 ) ;
0 commit comments