From e983fa41d34aa619429dbf3f4937b58c31113e53 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Sun, 4 Jan 2009 07:22:22 +0000 Subject: better E4X escaping in tests, dropped JS heredoc git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@731187 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_tests.js | 70 ++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'share/www') diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 16fa51e7..0c1b36ca 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -2059,15 +2059,14 @@ var tests = { json : req } }), - "xml-type" : [ - 'function(doc, req) { ', - ' return { ', - ' "headers" : { ', - ' "Content-Type" : "application/xml" ', - ' }, ', - ' "body" : ', - ' } ', - '}'].join('\n'), + "xml-type" : stringFun(function(doc, req) { + return { + "headers" : { + "Content-Type" : "application/xml" + }, + "body" : new XML('') + } + }), "no-set-etag" : stringFun(function(doc, req) { return { headers : { @@ -2104,29 +2103,35 @@ var tests = { }; } }), - "respondWith" : [ - 'function(doc, req) { ', - ' registerType("foo", "application/foo","application/x-foo");', - ' return respondWith(req, { ', - ' html : function() { ', - ' return { ', - ' body:"Ha ha, you said \\"" + doc.word + "\\"." ', - ' }; ', - ' }, ', - ' xml : function() { ', - ' return { ', - ' body: ', - ' }; ', - ' }, ', - ' foo : function() { ', - ' return { ', - ' body: "foofoo" ', - ' }; ', - ' }, ', - ' fallback : "html" ', - ' }); ', - '}'].join('\n') - } + "respondWith" : stringFun(function(doc, req) { + registerType("foo", "application/foo","application/x-foo"); + return respondWith(req, { + html : function() { + return { + body:"Ha ha, you said \"" + doc.word + "\"." + }; + }, + xml : function() { + var xml = new XML(''); + // becase Safari can't stand to see that dastardly + // E4X outside of a string. + this.eval('xml.node.@foo = doc.word'); + return { + headers : { + "Content-Type" : "application/xml", + }, + body: xml + }; + }, + foo : function() { + return { + body: "foofoo" + }; + }, + fallback : "html" + }); + }) + } }; T(db.save(designDoc).ok); @@ -2277,6 +2282,7 @@ var tests = { } }); T(xhr.getResponseHeader("Content-Type") == "application/xml"); + T(xhr.responseText.match(/node/)); T(xhr.responseText.match(/plankton/)); // registering types works -- cgit v1.2.3