@@ -2080,7 +2080,7 @@ test( "jQuery.cleanData eliminates all private data (gh-2127)", function() {
2080
2080
div . remove ( ) ;
2081
2081
} ) ;
2082
2082
2083
- test ( "jQuery.buildFragment - no plain-text caching (Bug # 6779)" , function ( ) {
2083
+ test ( "domManip plain-text caching (trac- 6779)" , function ( ) {
2084
2084
2085
2085
expect ( 1 ) ;
2086
2086
@@ -2099,42 +2099,43 @@ test( "jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
2099
2099
$f . remove ( ) ;
2100
2100
} ) ;
2101
2101
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 ( ) {
2103
2103
2104
2104
expect ( 3 ) ;
2105
2105
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
+ ) ;
2138
2139
2139
2140
test ( "jQuery.clone - no exceptions for object elements #9587" , function ( ) {
2140
2141
@@ -2296,12 +2297,6 @@ test( "manipulate mixed jQuery and text (#12384, #12346)", function() {
2296
2297
equal ( div . find ( "*" ) . length , 3 , "added 2 paragraphs after inner div" ) ;
2297
2298
} ) ;
2298
2299
2299
- testIframeWithCallback ( "buildFragment works even if document[0] is iframe's window object in IE9/10 (#12266)" , "manipulation/iframe-denied.html" , function ( test ) {
2300
- expect ( 1 ) ;
2301
-
2302
- ok ( test . status , test . description ) ;
2303
- } ) ;
2304
-
2305
2300
test ( "script evaluation (#11795)" , function ( ) {
2306
2301
2307
2302
expect ( 13 ) ;
@@ -2385,6 +2380,46 @@ test( "jQuery._evalUrl (#12838)", function() {
2385
2380
jQuery . _evalUrl = evalUrl ;
2386
2381
} ) ;
2387
2382
2383
+ test ( "jQuery.htmlPrefilter (gh-1747)" , function ( assert ) {
2384
+
2385
+ assert . expect ( 5 ) ;
2386
+
2387
+ var expectedArgument ,
2388
+ invocations = 0 ,
2389
+ htmlPrefilter = jQuery . htmlPrefilter ,
2390
+ fixture = jQuery ( "<div/>" ) . appendTo ( "#qunit-fixture" ) ,
2391
+ poison = "<script>jQuery.htmlPrefilter.assert.ok( false, 'script not executed' );</script>" ,
2392
+ done = assert . async ( ) ;
2393
+
2394
+ jQuery . htmlPrefilter = function ( html ) {
2395
+ invocations ++ ;
2396
+ assert . equal ( html , expectedArgument , "Expected input" ) ;
2397
+
2398
+ // Remove <script> and <del> elements
2399
+ return htmlPrefilter . apply ( this , arguments )
2400
+ . replace ( / < ( s c r i p t | d e l ) (? = [ \s > ] ) [ \w \W ] * ?< \/ \1\s * > / ig, "" ) ;
2401
+ } ;
2402
+ jQuery . htmlPrefilter . assert = assert ;
2403
+
2404
+ expectedArgument = "A-" + poison + "B-" + poison + poison + "C-" ;
2405
+ fixture . html ( expectedArgument ) ;
2406
+
2407
+ expectedArgument = "D-" + poison + "E-" + "<del/><div>" + poison + poison + "</div>" + "F-" ;
2408
+ fixture . append ( expectedArgument ) ;
2409
+
2410
+ expectedArgument = poison ;
2411
+ fixture . find ( "div" ) . replaceWith ( expectedArgument ) ;
2412
+
2413
+ assert . equal ( invocations , 3 , "htmlPrefilter invoked for all DOM manipulations" ) ;
2414
+ assert . equal ( fixture . html ( ) , "A-B-C-D-E-F-" , "htmlPrefilter modified HTML" ) ;
2415
+
2416
+ // Allow asynchronous script execution to generate assertions
2417
+ setTimeout ( function ( ) {
2418
+ jQuery . htmlPrefilter = htmlPrefilter ;
2419
+ done ( ) ;
2420
+ } , 100 ) ;
2421
+ } ) ;
2422
+
2388
2423
test ( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)" , function ( ) {
2389
2424
2390
2425
expect ( 10 ) ;
0 commit comments