Fixes #5955. Option crossDomain now forces ajax to consider a request as cross-domain...
[jquery.git] / test / unit / manipulation.js
index 52f76ed..e273cf0 100644 (file)
@@ -1,5 +1,8 @@
 module("manipulation");
 
+// Ensure that an extended Array prototype doesn't break jQuery
+Array.prototype.arrayProtoFn = function(arg) { throw("arrayProtoFn should not be called"); };
+
 var bareObj = function(value) { return value; };
 var functionReturningObj = function(value) { return (function() { return value; }); };
 
@@ -924,16 +927,12 @@ test("clone()", function() {
        equals( clone.html(), div.html(), "Element contents cloned" );
        equals( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
 
-       div = jQuery("<div/>").data({
-               a: true, b: true,
-               c: { nesty: ["Block", "Head"] }
-       });
+       div = jQuery("<div/>").data({ a: true });
        var div2 = div.clone(true);
        equals( div2.data("a"), true, "Data cloned." );
-       equals( div2.data("b"), true, "Data cloned." );
-       var c = div2.data("c");
-       c.nesty[0] = "Fish";
-       equals( div.data("c").nesty[0], "Block", "Ensure cloned element data is deep copied (Bug #7717)" );
+       div2.data("a", false);
+       equals( div2.data("a"), false, "Ensure cloned element data object was correctly modified" );
+       equals( div.data("a"), true, "Ensure cloned element data object is copied, not referenced" );
 
        var form = document.createElement("form");
        form.action = "/test/";
@@ -1248,3 +1247,20 @@ test("jQuery.cleanData", function() {
                return div;
        }
 });
+
+test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
+       expect(1);
+
+       // DOM manipulation fails if added text matches an Object method
+       var $f = jQuery( "<div />" ).appendTo( "#main" ),
+               bad = [ "start-", "toString", "hasOwnProperty", "append", "here&there!", "-end" ];
+
+       for ( var i=0; i < bad.length; i++ ) {
+               try {
+                       $f.append( bad[i] );
+               }
+               catch(e) {}
+       }
+    equals($f.text(), bad.join(''), "Cached strings that match Object properties");
+       $f.remove();
+});