From 787562247b680717e2a465c85acbe4358766e085 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Mon, 5 May 2014 15:45:57 +0200 Subject: [PATCH] Ajax, Manipulation: don't test cross-document manip in Android 2.3 --- test/unit/ajax.js | 6 ++++++ test/unit/manipulation.js | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 25397e85e..a332c929c 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1470,6 +1470,12 @@ module( "ajax", { var parsedXML = jQuery( jQuery.parseXML("blibli") ).find("tab"); ajaxXML = jQuery( ajaxXML ); try { + // Android 2.3 doesn't automatically adopt nodes from foreign documents. + // (see the comment in test/manipulation.js) + // Support: Android 2.3 + if ( /android 2\.3/i.test( navigator.userAgent ) ) { + parsedXML = jQuery( ajaxXML[ 0 ].adoptNode( parsedXML[ 0 ] ) ); + } ajaxXML.find("infowindowtab").append( parsedXML ); } catch( e ) { strictEqual( e, undefined, "error" ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index ac99654b9..057ddd56d 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -409,7 +409,7 @@ test( "XML DOM manipulation (#9960)", function() { expect( 5 ); - var + var scxml1Adopted, xmlDoc1 = jQuery.parseXML(""), xmlDoc2 = jQuery.parseXML(""), xml1 = jQuery( xmlDoc1 ), @@ -418,6 +418,15 @@ test( "XML DOM manipulation (#9960)", function() { scxml2 = jQuery( "scxml", xml2 ), state = scxml2.find("state"); + // Android 2.3 doesn't automatically adopt nodes from foreign documents. + // Although technically this is compliant behavior, no other browser + // (including newer Android Browsers) behave in this way so do the adopting + // just for Android 2.3. + // Support: Android 2.3 + if ( /android 2\.3/i.test( navigator.userAgent ) ) { + state = jQuery( xmlDoc1.adoptNode( state[ 0 ] ) ); + } + scxml1.append( state ); strictEqual( scxml1[0].lastChild, state[0], "append" ); @@ -430,7 +439,13 @@ test( "XML DOM manipulation (#9960)", function() { scxml1.find("#provisioning").before( state ); strictEqual( scxml1[0].firstChild, state[0], "before" ); - scxml2.replaceWith( scxml1 ); + // Support: Android 2.3 + if ( /android 2\.3/i.test( navigator.userAgent ) ) { + scxml1Adopted = jQuery( xmlDoc2.adoptNode( scxml1[ 0 ] ) ); + scxml2.replaceWith( scxml1Adopted ); + } else { + scxml2.replaceWith( scxml1 ); + } deepEqual( jQuery( "state", xml2 ).get(), scxml1.find("state").get(), "replaceWith" ); }); -- 2.39.5