You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2009/01/04 08:22:22 UTC

svn commit: r731187 - /couchdb/trunk/share/www/script/couch_tests.js

Author: jchris
Date: Sat Jan  3 23:22:22 2009
New Revision: 731187

URL: http://svn.apache.org/viewvc?rev=731187&view=rev
Log:
better E4X escaping in tests, dropped JS heredoc

Modified:
    couchdb/trunk/share/www/script/couch_tests.js

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=731187&r1=731186&r2=731187&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Sat Jan  3 23:22:22 2009
@@ -2059,15 +2059,14 @@
              json : req
            }
          }),
-         "xml-type" : [
-           'function(doc, req) {                     ',
-           '  return {                               ',
-           '    "headers" : {                        ',
-           '      "Content-Type" : "application/xml" ',
-           '    },                                   ',
-           '    "body" : <xml><node foo="bar"/></xml>',
-           '  }                                      ',
-           '}'].join('\n'),
+         "xml-type" : stringFun(function(doc, req) {
+            return {
+              "headers" : {
+                "Content-Type" : "application/xml"
+              },
+              "body" : new XML('<xml><node foo="bar"/></xml>')
+            }
+          }),
          "no-set-etag" : stringFun(function(doc, req) {
            return {
              headers : {
@@ -2104,29 +2103,35 @@
              };
            }
          }),
-         "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: <xml><node foo={doc.word}/></xml>              ',
-           '      };                                                     ',
-           '    },                                                       ',
-           '    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('<xml><node/></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 @@
        }
      });
      T(xhr.getResponseHeader("Content-Type") == "application/xml");
+     T(xhr.responseText.match(/node/));
      T(xhr.responseText.match(/plankton/));
      
      // registering types works