couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <>
Subject Futon test suite on Chrome
Date Sat, 07 Aug 2010 12:36:29 GMT

I spent a few hours this morning trying to get the full test suite
running on Chrome. I failed for interesting reasons that I think are
worth sharing.

Exactly two tests fail, attachments.js and replication.js

attachments.js fails because of an unidentified Chrome parsing bug. If
you remove this part of the test (right at the end), the test passes
on Chrome;

  bin_doc6._attachments["foo.txt"] = { stub: true, revpos: 10};
  try {
      T( == true);
      T(false && "Shouldn't get here!");
  } catch (e) {
      T(e.error == "missing_stub")

It is *not* sufficient to merely comment it out, the test still hangs.
Interestingly, the presence of this stanza prevents even the first
line of the test from executing. I confirmed this by building another
test class and copying attachments.js over incrementally. The oddness
of this bug was confirmed by doppler on #couchdb.

replication.js fails because Chrome has another bug around the common
defaulting idiom we use. In couch.js we default options and
options.headers to empty objects if either are undefined, which should
make the reference to options.headers['Content-Type'] completely safe.
Not so in Chrome. I added if (!options.headers) alert('oops'); after
both defaulting lines and it fires on Chrome.  The following patch
fixes it but I don't think we should apply it;

diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index b7e0e51..7d18939 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -397,8 +397,8 @@ CouchDB.newXhr = function() {

 CouchDB.request = function(method, uri, options) {
-  options = options || {};
-  options.headers = options.headers || {};
+  options = typeof(options) == 'object' ? options : {};
+  options.headers = typeof(options.headers) == 'object' ? options.headers : {};
   options.headers["Content-Type"] = options.headers["Content-Type"]
|| options.he
   options.headers["Accept"] = options.headers["Accept"] ||
   var req = CouchDB.newXhr();


View raw message