summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorNoah Slater <nslater@apache.org>2009-07-06 00:33:50 +0000
committerNoah Slater <nslater@apache.org>2009-07-06 00:33:50 +0000
commit282b96ddd9a84b740788c2358ec0f5fedafb7cc6 (patch)
treefb48e605ceb8079d0195d3b1ec0eca7110fa7ef2 /share/www/script
parentb5cc085d3bc6316063f14adedf20632ee904875d (diff)
trimmed trailing whitespace
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791350 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/couch.js52
-rw-r--r--share/www/script/couch_test_runner.js2
-rw-r--r--share/www/script/futon.browse.js14
-rw-r--r--share/www/script/jquery.couch.js4
-rw-r--r--share/www/script/jquery.form.js52
-rw-r--r--share/www/script/jquery.js148
-rw-r--r--share/www/script/test/all_docs.js18
-rw-r--r--share/www/script/test/attachment_names.js54
-rw-r--r--share/www/script/test/attachment_paths.js12
-rw-r--r--share/www/script/test/attachment_views.js2
-rw-r--r--share/www/script/test/attachments.js30
-rw-r--r--share/www/script/test/basics.js16
-rw-r--r--share/www/script/test/batch_save.js14
-rw-r--r--share/www/script/test/bulk_docs.js8
-rw-r--r--share/www/script/test/changes.js62
-rw-r--r--share/www/script/test/compact.js4
-rw-r--r--share/www/script/test/conflicts.js2
-rw-r--r--share/www/script/test/delayed_commits.js58
-rw-r--r--share/www/script/test/design_docs.js12
-rw-r--r--share/www/script/test/design_options.js4
-rw-r--r--share/www/script/test/design_paths.js2
-rw-r--r--share/www/script/test/etags_views.js10
-rw-r--r--share/www/script/test/invalid_docids.js2
-rw-r--r--share/www/script/test/list_views.js32
-rw-r--r--share/www/script/test/purge.js26
-rw-r--r--share/www/script/test/reduce.js6
-rw-r--r--share/www/script/test/reduce_builtin.js12
-rw-r--r--share/www/script/test/reduce_false.js2
-rw-r--r--share/www/script/test/replication.js58
-rw-r--r--share/www/script/test/rev_stemming.js36
-rw-r--r--share/www/script/test/security_validation.js54
-rw-r--r--share/www/script/test/show_documents.js32
-rw-r--r--share/www/script/test/stats.js29
-rw-r--r--share/www/script/test/uuids.js12
-rw-r--r--share/www/script/test/view_collation.js10
-rw-r--r--share/www/script/test/view_errors.js32
-rw-r--r--share/www/script/test/view_multi_key_design.js2
-rw-r--r--share/www/script/test/view_multi_key_temp.js2
-rw-r--r--share/www/script/test/view_offsets.js10
-rw-r--r--share/www/script/test/view_pagination.js4
40 files changed, 470 insertions, 471 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index c4c1ae9f..1f6a7444 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -16,11 +16,11 @@
function CouchDB(name, httpHeaders) {
this.name = name;
this.uri = "/" + encodeURIComponent(name) + "/";
-
+
// The XMLHttpRequest object from the most recent request. Callers can
// use this to check result http status and headers.
this.last_req = null;
-
+
this.request = function(method, uri, requestOptions) {
requestOptions = requestOptions || {}
requestOptions.headers = combine(requestOptions.headers, httpHeaders)
@@ -48,7 +48,7 @@ function CouchDB(name, httpHeaders) {
if (doc._id == undefined)
doc._id = CouchDB.newUuids(1)[0];
- this.last_req = this.request("PUT", this.uri +
+ this.last_req = this.request("PUT", this.uri +
encodeURIComponent(doc._id) + encodeOptions(options),
{body: JSON.stringify(doc)});
CouchDB.maybeThrowError(this.last_req);
@@ -84,7 +84,7 @@ function CouchDB(name, httpHeaders) {
doc._rev = result.rev; //record rev in input document
return result;
}
-
+
this.bulkSave = function(docs, options) {
// first prepoulate the UUIDs for new documents
var newCount = 0
@@ -119,7 +119,7 @@ function CouchDB(name, httpHeaders) {
return results;
}
}
-
+
this.ensureFullCommit = function() {
this.last_req = this.request("POST", this.uri + "_ensure_full_commit");
CouchDB.maybeThrowError(this.last_req);
@@ -130,7 +130,7 @@ function CouchDB(name, httpHeaders) {
this.query = function(mapFun, reduceFun, options, keys) {
var body = {language: "javascript"};
if(keys) {
- body.keys = keys ;
+ body.keys = keys ;
}
if (typeof(mapFun) != "string")
mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
@@ -154,15 +154,15 @@ function CouchDB(name, httpHeaders) {
this.view = function(viewname, options, keys) {
var viewParts = viewname.split('/');
- var viewPath = this.uri + "_design/" + viewParts[0] + "/_view/"
+ var viewPath = this.uri + "_design/" + viewParts[0] + "/_view/"
+ viewParts[1] + encodeOptions(options);
if(!keys) {
- this.last_req = this.request("GET", viewPath);
+ this.last_req = this.request("GET", viewPath);
} else {
this.last_req = this.request("POST", viewPath, {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
- });
+ });
}
if (this.last_req.status == 404)
return null;
@@ -183,7 +183,7 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.viewCleanup = function() {
this.last_req = this.request("POST", this.uri + "_view_cleanup");
CouchDB.maybeThrowError(this.last_req);
@@ -192,17 +192,17 @@ function CouchDB(name, httpHeaders) {
this.allDocs = function(options,keys) {
if(!keys) {
- this.last_req = this.request("GET", this.uri + "_all_docs" + encodeOptions(options));
+ this.last_req = this.request("GET", this.uri + "_all_docs" + encodeOptions(options));
} else {
this.last_req = this.request("POST", this.uri + "_all_docs" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
- });
+ });
}
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.designDocs = function() {
return this.allDocs({startkey:"_design", endkey:"_design0"});
};
@@ -210,12 +210,12 @@ function CouchDB(name, httpHeaders) {
this.allDocsBySeq = function(options,keys) {
var req = null;
if(!keys) {
- req = this.request("GET", this.uri + "_all_docs_by_seq" + encodeOptions(options));
+ req = this.request("GET", this.uri + "_all_docs_by_seq" + encodeOptions(options));
} else {
req = this.request("POST", this.uri + "_all_docs_by_seq" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
- });
+ });
}
CouchDB.maybeThrowError(req);
return JSON.parse(req.responseText);
@@ -226,7 +226,7 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.setDbProperty = function(propId, propValue) {
this.last_req = this.request("PUT", this.uri + propId,{
body:JSON.stringify(propValue)
@@ -234,13 +234,13 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.getDbProperty = function(propId) {
this.last_req = this.request("GET", this.uri + propId);
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.setAdmins = function(adminsArray) {
this.last_req = this.request("PUT", this.uri + "_admins",{
body:JSON.stringify(adminsArray)
@@ -248,13 +248,13 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
this.getAdmins = function() {
this.last_req = this.request("GET", this.uri + "_admins");
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
-
+
// Convert a options object to an url query string.
// ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"'
function encodeOptions(options) {
@@ -278,26 +278,26 @@ function CouchDB(name, httpHeaders) {
function toJSON(obj) {
return obj !== null ? JSON.stringify(obj) : null;
}
-
+
function combine(object1, object2) {
if (!object2)
return object1;
if (!object1)
return object2;
-
+
for (var name in object2)
object1[name] = object2[name];
-
+
return object1;
}
-
-
+
+
}
// this is the XMLHttpRequest object from last request made by the following
// CouchDB.* functions (except for calls to request itself).
// Use this from callers to check HTTP status or header values of requests.
-CouchDB.last_req = null;
+CouchDB.last_req = null;
CouchDB.allDbs = function() {
diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js
index c396cd16..ef7d42aa 100644
--- a/share/www/script/couch_test_runner.js
+++ b/share/www/script/couch_test_runner.js
@@ -12,7 +12,7 @@
// *********************** Test Framework of Sorts ************************* //
-function loadScript(url) {
+function loadScript(url) {
if (typeof document != "undefined") document.write('<script src="'+url+'"></script>');
};
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index e518c9ab..37afe1d4 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -49,7 +49,7 @@
var dbsOnPage = dbs.slice(offset, offset + maxPerPage);
$.each(dbsOnPage, function(idx, dbName) {
- $("#databases tbody.content").append("<tr>" +
+ $("#databases tbody.content").append("<tr>" +
"<th><a href='database.html?" + encodeURIComponent(dbName) + "'>" +
dbName + "</a></th>" +
"<td class='size'></td><td class='count'></td>" +
@@ -504,7 +504,7 @@
resp.rows = resp.rows.reverse();
}
var has_reduce_prev = resp.total_rows === undefined && (descending_reverse ? resp.rows.length > per_page : options.startkey !== undefined);
- if (resp.rows !== null && (has_reduce_prev || (descending_reverse ?
+ if (resp.rows !== null && (has_reduce_prev || (descending_reverse ?
(resp.total_rows - resp.offset > per_page) :
(resp.offset > 0)))) {
$("#paging a.prev").attr("href", "#" + (resp.offset - per_page)).click(function() {
@@ -527,8 +527,8 @@
$("#paging a.prev").removeAttr("href");
}
var has_reduce_next = resp.total_rows === undefined && (descending_reverse ? options.startkey !== undefined : resp.rows.length > per_page);
- if (resp.rows !== null && (has_reduce_next || (descending_reverse ?
- (resp.offset - resp.total_rows < per_page) :
+ if (resp.rows !== null && (has_reduce_next || (descending_reverse ?
+ (resp.offset - resp.total_rows < per_page) :
(resp.total_rows - resp.offset > per_page)))) {
$("#paging a.next").attr("href", "#" + (resp.offset + per_page)).click(function() {
var opt = {
@@ -967,16 +967,16 @@
}
function _renderAttachmentItem(name, attachment) {
- var attachmentHref = db.uri + encodeDocId(docId)
+ var attachmentHref = db.uri + encodeDocId(docId)
+ "/" + encodeAttachment(name);
var li = $("<li></li>");
$("<a href='' title='Download file' target='_top'></a>").text(name)
.attr("href", attachmentHref)
.wrapInner("<tt></tt>").appendTo(li);
- $("<span>()</span>").text("" + $.futon.formatSize(attachment.length) +
+ $("<span>()</span>").text("" + $.futon.formatSize(attachment.length) +
", " + attachment.content_type).addClass("info").appendTo(li);
if (name == "tests.js") {
- li.find('span.info').append(', <a href="/_utils/couch_tests.html?'
+ li.find('span.info').append(', <a href="/_utils/couch_tests.html?'
+ attachmentHref + '">open in test runner</a>');
}
_initAttachmentItem(name, attachment, li);
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index 559fafd4..3c629e1d 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -92,7 +92,7 @@
$.ajax({
type: "POST", url: this.uri + "_compact",
contentType: "application/json",
- dataType: "json", data: "", processData: false,
+ dataType: "json", data: "", processData: false,
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 202) {
@@ -200,7 +200,7 @@
});
});
}
- });
+ });
} else {
alert("please provide an eachApp function for allApps()");
}
diff --git a/share/www/script/jquery.form.js b/share/www/script/jquery.form.js
index 91eb688d..e35ef0ef 100644
--- a/share/www/script/jquery.form.js
+++ b/share/www/script/jquery.form.js
@@ -13,7 +13,7 @@
;(function($) {
/*
- Usage Note:
+ Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are intended to be exclusive. Use ajaxSubmit if you want
@@ -36,13 +36,13 @@
target: '#output'
});
});
-
+
When using ajaxForm, the ajaxSubmit function will be invoked for you
- at the appropriate time.
+ at the appropriate time.
*/
/**
- * ajaxSubmit() provides a mechanism for immediately submitting
+ * ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
@@ -73,8 +73,8 @@ $.fn.ajaxSubmit = function(options) {
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
- }
-
+ }
+
var a = this.formToArray(options.semantic);
if (options.data) {
options.extraData = options.data;
@@ -82,7 +82,7 @@ $.fn.ajaxSubmit = function(options) {
if(options.data[n] instanceof Array) {
for (var k in options.data[n])
a.push( { name: n, value: options.data[n][k] } )
- }
+ }
else
a.push( { name: n, value: options.data[n] } );
}
@@ -92,14 +92,14 @@ $.fn.ajaxSubmit = function(options) {
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
- }
+ }
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
- }
+ }
var q = $.param(a);
@@ -137,7 +137,7 @@ $.fn.ajaxSubmit = function(options) {
found = true;
// options.iframe allows user to force iframe mode
- if (options.iframe || found) {
+ if (options.iframe || found) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if ($.browser.safari && options.closeKeepAlive)
@@ -156,12 +156,12 @@ $.fn.ajaxSubmit = function(options) {
// private function for handling file uploads (hat tip to YAHOO!)
function fileUpload() {
var form = $form[0];
-
+
if ($(':input[name=submit]', form).length) {
alert('Error: Form elements must not be named "submit".');
return;
}
-
+
var opts = $.extend({}, $.ajaxSettings, options);
var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
@@ -169,7 +169,7 @@ $.fn.ajaxSubmit = function(options) {
var $io = $('<iframe id="' + id + '" name="' + id + '" />');
var io = $io[0];
- if ($.browser.msie || $.browser.opera)
+ if ($.browser.msie || $.browser.opera)
io.src = 'javascript:false;document.write("");';
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
@@ -182,8 +182,8 @@ $.fn.ajaxSubmit = function(options) {
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
- abort: function() {
- this.aborted = 1;
+ abort: function() {
+ this.aborted = 1;
$io.attr('src','about:blank'); // abort op in progress
}
};
@@ -199,7 +199,7 @@ $.fn.ajaxSubmit = function(options) {
}
if (xhr.aborted)
return;
-
+
var cbInvoked = 0;
var timedOut = 0;
@@ -226,7 +226,7 @@ $.fn.ajaxSubmit = function(options) {
method: 'POST',
action: opts.url
});
-
+
// ie borks in some cases when setting encoding
if (! options.skipEncodingOverride) {
$form.attr({
@@ -247,7 +247,7 @@ $.fn.ajaxSubmit = function(options) {
extraInputs.push(
$('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
.appendTo(form)[0]);
-
+
// add iframe to doc and submit the form
$io.appendTo('body');
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
@@ -263,7 +263,7 @@ $.fn.ajaxSubmit = function(options) {
function cb() {
if (cbInvoked++) return;
-
+
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
var operaHack = 0;
@@ -274,7 +274,7 @@ $.fn.ajaxSubmit = function(options) {
var data, doc;
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
-
+
if (doc.body == null && !operaHack && $.browser.opera) {
// In Opera 9.2.x the iframe DOM is not always traversable when
// the onload callback fires so we give Opera 100ms to right itself
@@ -283,7 +283,7 @@ $.fn.ajaxSubmit = function(options) {
setTimeout(cb, 100);
return;
}
-
+
xhr.responseText = doc.body ? doc.body.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
@@ -348,7 +348,7 @@ $.fn.ajaxSubmit = function(options) {
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
- */
+ */
$.fn.ajaxForm = function(options) {
return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
$(this).ajaxSubmit(options);
@@ -594,10 +594,10 @@ $.fn.resetForm = function() {
/**
* Enables or disables any matching elements.
*/
-$.fn.enable = function(b) {
+$.fn.enable = function(b) {
if (b == undefined) b = true;
- return this.each(function() {
- this.disabled = !b
+ return this.each(function() {
+ this.disabled = !b
});
};
@@ -607,7 +607,7 @@ $.fn.enable = function(b) {
*/
$.fn.selected = function(select) {
if (select == undefined) select = true;
- return this.each(function() {
+ return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio')
this.checked = select;
diff --git a/share/www/script/jquery.js b/share/www/script/jquery.js
index 3a4badd0..9ee8702c 100644
--- a/share/www/script/jquery.js
+++ b/share/www/script/jquery.js
@@ -11,7 +11,7 @@
*/
(function(){
-var
+var
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
@@ -399,13 +399,13 @@ jQuery.fn = jQuery.prototype = {
},
val: function( value ) {
- if ( value === undefined ) {
+ if ( value === undefined ) {
var elem = this[0];
if ( elem ) {
if( jQuery.nodeName( elem, 'option' ) )
return (elem.attributes.value || {}).specified ? elem.value : elem.text;
-
+
// We need to handle select boxes special
if ( jQuery.nodeName( elem, "select" ) ) {
var index = elem.selectedIndex,
@@ -434,7 +434,7 @@ jQuery.fn = jQuery.prototype = {
}
}
- return values;
+ return values;
}
// Everything else, we just grab the value
@@ -513,13 +513,13 @@ jQuery.fn = jQuery.prototype = {
if ( first )
for ( var i = 0, l = this.length; i < l; i++ )
callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );
-
+
if ( scripts )
jQuery.each( scripts, evalScript );
}
return this;
-
+
function root( elem, cur ) {
return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
(elem.getElementsByTagName("tbody")[0] ||
@@ -586,7 +586,7 @@ jQuery.extend = jQuery.fn.extend = function() {
// Recurse if we're merging object values
if ( deep && copy && typeof copy === "object" && !copy.nodeType )
- target[ name ] = jQuery.extend( deep,
+ target[ name ] = jQuery.extend( deep,
// Never move original objects, clone them
src || ( copy.length != null ? [ ] : { } )
, copy );
@@ -923,7 +923,7 @@ jQuery.extend({
// IE completely kills leading whitespace when innerHTML is used
if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
-
+
elem = jQuery.makeArray( div.childNodes );
}
@@ -944,7 +944,7 @@ jQuery.extend({
fragment.appendChild( ret[i] );
}
}
-
+
return scripts;
}
@@ -1322,16 +1322,16 @@ jQuery.extend({
},
queue: function( elem, type, data ) {
if ( elem ){
-
+
type = (type || "fx") + "queue";
-
+
var q = jQuery.data( elem, type );
-
+
if ( !q || jQuery.isArray(data) )
q = jQuery.data( elem, type, jQuery.makeArray(data) );
else if( data )
q.push( data );
-
+
}
return q;
},
@@ -1339,10 +1339,10 @@ jQuery.extend({
dequeue: function( elem, type ){
var queue = jQuery.queue( elem, type ),
fn = queue.shift();
-
+
if( !type || type === "fx" )
fn = queue[0];
-
+
if( fn !== undefined )
fn.call(elem);
}
@@ -1384,7 +1384,7 @@ jQuery.fn.extend({
return this.each(function(){
var queue = jQuery.queue( this, type, data );
-
+
if( type == "fx" && queue.length == 1 )
queue[0].call(this);
});
@@ -1412,19 +1412,19 @@ var Sizzle = function(selector, context, results, seed) {
if ( context.nodeType !== 1 && context.nodeType !== 9 )
return [];
-
+
if ( !selector || typeof selector !== "string" ) {
return results;
}
var parts = [], m, set, checkSet, check, mode, extra, prune = true;
-
+
// Reset the position of the chunker regexp (start from head)
chunker.lastIndex = 0;
-
+
while ( (m = chunker.exec(selector)) !== null ) {
parts.push( m[1] );
-
+
if ( m[2] ) {
extra = RegExp.rightContext;
break;
@@ -1525,7 +1525,7 @@ Sizzle.find = function(expr, context, isXML){
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var type = Expr.order[i], match;
-
+
if ( (match = Expr.match[ type ].exec( expr )) ) {
var left = RegExp.leftContext;
@@ -1770,7 +1770,7 @@ var Expr = Sizzle.selectors = {
},
ATTR: function(match){
var name = match[1].replace(/\\/g, "");
-
+
if ( Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
@@ -1796,7 +1796,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) ) {
return true;
}
-
+
return match;
},
POS: function(match){
@@ -1894,7 +1894,7 @@ var Expr = Sizzle.selectors = {
var type = match[1], parent = elem.parentNode;
var doneName = match[0];
-
+
if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
var count = 1;
@@ -2004,7 +2004,7 @@ var makeArray = function(array, results) {
results.push.apply( results, array );
return results;
}
-
+
return array;
};
@@ -2115,7 +2115,7 @@ if ( document.querySelectorAll ) (function(){
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return;
}
-
+
Sizzle = function(query, context, extra, seed){
context = context || document;
@@ -2126,7 +2126,7 @@ if ( document.querySelectorAll ) (function(){
return makeArray( context.querySelectorAll(query), extra );
} catch(e){}
}
-
+
return oldSizzle(query, context, extra, seed);
};
@@ -2368,7 +2368,7 @@ jQuery.event = {
// Get the current list of functions bound to this event
var handlers = events[type];
-
+
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
@@ -2441,7 +2441,7 @@ jQuery.event = {
// Handle the removal of namespaced events
if ( namespace.test(events[type][handle].type) )
delete events[type][handle];
-
+
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].teardown.call(elem, namespaces);
@@ -2508,11 +2508,11 @@ jQuery.event = {
// don't do events on text and comment nodes
if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
return undefined;
-
+
// Clean up in case it is reused
event.result = undefined;
event.target = elem;
-
+
// Clone the incoming data, if any
data = jQuery.makeArray(data);
data.unshift( event );
@@ -2559,7 +2559,7 @@ jQuery.event = {
// Cache this now, all = true means, any handler
all = !namespaces.length && !event.exclusive;
-
+
var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
handlers = ( jQuery.data(this, "events") || {} )[event.type];
@@ -2657,7 +2657,7 @@ jQuery.event = {
teardown: function() {}
}
},
-
+
specialAll: {
live: {
setup: function( selector, namespaces ){
@@ -2666,12 +2666,12 @@ jQuery.event = {
teardown: function( namespaces ){
if ( namespaces.length ) {
var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
-
+
jQuery.each( (jQuery.data(this, "events").live || {}), function(){
if ( name.test(this.type) )
remove++;
});
-
+
if ( remove < 1 )
jQuery.event.remove( this, namespaces[0], liveHandler );
}
@@ -2684,7 +2684,7 @@ jQuery.Event = function( src ){
// Allow instantiation without the 'new' keyword
if( !this.preventDefault )
return new jQuery.Event(src);
-
+
// Event object
if( src && src.type ){
this.originalEvent = src;
@@ -2696,7 +2696,7 @@ jQuery.Event = function( src ){
// timeStamp is buggy for some events on Firefox(#3843)
// So we won't rely on the native value
this.timeStamp = now();
-
+
// Mark it as fixed
this[expando] = true;
};
@@ -2752,7 +2752,7 @@ var withinElement = function(event) {
while ( parent && parent != this )
try { parent = parent.parentNode; }
catch(e) { parent = this; }
-
+
if( parent != this ){
// set the correct event type
event.type = event.data;
@@ -2760,9 +2760,9 @@ var withinElement = function(event) {
jQuery.event.handle.apply( this, arguments );
}
};
-
-jQuery.each({
- mouseover: 'mouseenter',
+
+jQuery.each({
+ mouseover: 'mouseenter',
mouseout: 'mouseleave'
}, function( orig, fix ){
jQuery.event.special[ fix ] = {
@@ -2772,7 +2772,7 @@ jQuery.each({
teardown: function(){
jQuery.event.remove( this, orig, withinElement );
}
- };
+ };
});
jQuery.fn.extend({
@@ -2811,7 +2811,7 @@ jQuery.fn.extend({
event.stopPropagation();
jQuery.event.trigger( event, data, this[0] );
return event.result;
- }
+ }
},
toggle: function( fn ) {
@@ -2854,7 +2854,7 @@ jQuery.fn.extend({
return this;
},
-
+
live: function( type, fn ){
var proxy = jQuery.event.proxy( fn );
proxy.guid += this.selector + type;
@@ -2863,7 +2863,7 @@ jQuery.fn.extend({
return this;
},
-
+
die: function( type, fn ){
jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
return this;
@@ -2983,12 +2983,12 @@ jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
-jQuery( window ).bind( 'unload', function(){
+jQuery( window ).bind( 'unload', function(){
for ( var id in jQuery.cache )
// Skip the window
if ( id != 1 && jQuery.cache[ id ].handle )
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
-});
+});
(function(){
jQuery.support = {};
@@ -3012,32 +3012,32 @@ jQuery( window ).bind( 'unload', function(){
jQuery.support = {
// IE strips leading whitespace when .innerHTML is used
leadingWhitespace: div.firstChild.nodeType == 3,
-
+
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
tbody: !div.getElementsByTagName("tbody").length,
-
+
// Make sure that you can get all elements in an <object> element
// IE 7 always returns no results
objectAll: !!div.getElementsByTagName("object")[0]
.getElementsByTagName("*").length,
-
+
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
htmlSerialize: !!div.getElementsByTagName("link").length,
-
+
// Get the style information from getAttribute
// (IE uses .cssText insted)
style: /red/.test( a.getAttribute("style") ),
-
+
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
hrefNormalized: a.getAttribute("href") === "/a",
-
+
// Make sure that element opacity exists
// (IE uses filter instead)
opacity: a.style.opacity === "0.5",
-
+
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
cssFloat: !!a.style.cssFloat,
@@ -3047,14 +3047,14 @@ jQuery( window ).bind( 'unload', function(){
noCloneEvent: true,
boxModel: null
};
-
+
script.type = "text/javascript";
try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
} catch(e){}
root.insertBefore( script, root.firstChild );
-
+
// Make sure that the execution of code works by injecting a script
// tag with appendChild/createTextNode
// (IE doesn't support this, fails, and uses .text instead)
@@ -3199,7 +3199,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp
var jsc = now();
jQuery.extend({
-
+
get: function( url, data, callback, type ) {
// shift arguments if data argument was ommited
if ( jQuery.isFunction( data ) ) {
@@ -3585,7 +3585,7 @@ jQuery.extend({
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
-
+
// Allow a pre-filtering function to sanitize the response
// s != null is checked to keep backwards compatibility
if( s && s.dataFilter )
@@ -3602,7 +3602,7 @@ jQuery.extend({
if ( type == "json" )
data = window["eval"]("(" + data + ")");
}
-
+
return data;
},
@@ -3666,30 +3666,30 @@ jQuery.fn.extend({
} else {
for ( var i = 0, l = this.length; i < l; i++ ){
var old = jQuery.data(this[i], "olddisplay");
-
+
this[i].style.display = old || "";
-
+
if ( jQuery.css(this[i], "display") === "none" ) {
var tagName = this[i].tagName, display;
-
+
if ( elemdisplay[ tagName ] ) {
display = elemdisplay[ tagName ];
} else {
var elem = jQuery("<" + tagName + " />").appendTo("body");
-
+
display = elem.css("display");
if ( display === "none" )
display = "block";
-
+
elem.remove();
-
+
elemdisplay[ tagName ] = display;
}
-
+
this[i].style.display = jQuery.data(this[i], "olddisplay", display);
}
}
-
+
return this;
}
},
@@ -3732,11 +3732,11 @@ jQuery.fn.extend({
var optall = jQuery.speed(speed, easing, callback);
return this[ optall.queue === false ? "each" : "queue" ](function(){
-
+
var opt = jQuery.extend({}, optall), p,
hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
self = this;
-
+
for ( p in prop ) {
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
return opt.complete.call(this);
@@ -3990,7 +3990,7 @@ jQuery.fx.prototype = {
if ( this.options.hide || this.options.show )
for ( var p in this.options.curAnim )
jQuery.attr(this.elem.style, p, this.options.orig[p]);
-
+
// Execute the complete function
this.options.complete.call( this.elem );
}
@@ -4044,7 +4044,7 @@ if ( document.documentElement["getBoundingClientRect"] )
left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
return { top: top, left: left };
};
-else
+else
jQuery.fn.offset = function() {
if ( !this[0] ) return { top: 0, left: 0 };
if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
@@ -4134,7 +4134,7 @@ jQuery.fn.extend({
parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
// Subtract element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
+ // note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset.top -= num( this, 'marginTop' );
offset.left -= num( this, 'marginLeft' );
@@ -4165,7 +4165,7 @@ jQuery.fn.extend({
// Create scrollLeft and scrollTop methods
jQuery.each( ['Left', 'Top'], function(i, name) {
var method = 'scroll' + name;
-
+
jQuery.fn[ method ] = function(val) {
if (!this[0]) return null;
@@ -4210,7 +4210,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
(margin ?
num(this, "margin" + tl) + num(this, "margin" + br) : 0);
};
-
+
var type = name.toLowerCase();
jQuery.fn[ type ] = function( size ) {
diff --git a/share/www/script/test/all_docs.js b/share/www/script/test/all_docs.js
index 3dd3aa53..fcec3b43 100644
--- a/share/www/script/test/all_docs.js
+++ b/share/www/script/test/all_docs.js
@@ -15,7 +15,7 @@ couchTests.all_docs = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
// Create some more documents.
// Notice the use of the ok member on the return result.
T(db.save({_id:"0",a:1,b:1}).ok);
@@ -32,7 +32,7 @@ couchTests.all_docs = function(debug) {
for(var i=0; i < rows.length; i++) {
T(rows[i].id >= "0" && rows[i].id <= "4");
}
-
+
// Check _all_docs with descending=true
var desc = db.allDocs({descending:true});
T(desc.total_rows == desc.rows.length);
@@ -40,7 +40,7 @@ couchTests.all_docs = function(debug) {
// Check _all_docs offset
var all = db.allDocs({startkey:"2"});
T(all.offset == 2);
-
+
// check that the docs show up in the seq view in the order they were created
var all_seq = db.allDocsBySeq();
var ids = ["0","3","1","2"];
@@ -48,7 +48,7 @@ couchTests.all_docs = function(debug) {
var row = all_seq.rows[i];
T(row.id == ids[i]);
};
-
+
// it should work in reverse as well
all_seq = db.allDocsBySeq({descending:true});
ids = ["2","1","3","0"];
@@ -56,13 +56,13 @@ couchTests.all_docs = function(debug) {
var row = all_seq.rows[i];
T(row.id == ids[i]);
};
-
+
// check that deletions also show up right
var doc1 = db.open("1");
var deleted = db.deleteDoc(doc1);
T(deleted.ok);
all_seq = db.allDocsBySeq();
-
+
// the deletion should make doc id 1 have the last seq num
T(all_seq.rows.length == 4);
T(all_seq.rows[3].id == "1");
@@ -70,13 +70,13 @@ couchTests.all_docs = function(debug) {
// is this a bug?
// T(all_seq.rows.length == all_seq.total_rows);
-
+
// do an update
var doc2 = db.open("3");
doc2.updated = "totally";
db.save(doc2);
all_seq = db.allDocsBySeq();
-
+
// the update should make doc id 3 have the last seq num
T(all_seq.rows.length == 4);
T(all_seq.rows[3].id == "3");
@@ -90,7 +90,7 @@ couchTests.all_docs = function(debug) {
// and on the deleted one, no doc
T(all_seq.rows[2].value.deleted);
T(!all_seq.rows[2].doc);
-
+
// test the all docs collates sanely
db.save({_id: "Z", foo: "Z"});
db.save({_id: "a", foo: "a"});
diff --git a/share/www/script/test/attachment_names.js b/share/www/script/test/attachment_names.js
index 3c694dd0..f9c846eb 100644
--- a/share/www/script/test/attachment_names.js
+++ b/share/www/script/test/attachment_names.js
@@ -10,21 +10,21 @@
// License for the specific language governing permissions and limitations under
// the License.
-couchTests.attachment_names = function(debug) {
- var db = new CouchDB("test_suite_db");
- db.deleteDb();
- db.createDb();
- if (debug) debugger;
-
- var binAttDoc = {
- _id: "bin_doc",
- _attachments:{
- "foo\x80txt": {
- content_type:"text/plain",
- data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
- }
- }
- }
+couchTests.attachment_names = function(debug) {
+ var db = new CouchDB("test_suite_db");
+ db.deleteDb();
+ db.createDb();
+ if (debug) debugger;
+
+ var binAttDoc = {
+ _id: "bin_doc",
+ _attachments:{
+ "foo\x80txt": {
+ content_type:"text/plain",
+ data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+ }
+ }
+ }
// inline attachments
try {
@@ -38,7 +38,7 @@ couchTests.attachment_names = function(debug) {
// standalone docs
var bin_data = "JHAPDO*AU£PN ){(3u[d 93DQ9¡€])} ææøo'∂ƒæ≤çæππ•¥∫¶®#†π¶®¥π€ª®˙π8np";
-
+
var xhr = (CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment\x80txt", {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:bin_data
@@ -64,15 +64,15 @@ couchTests.attachment_names = function(debug) {
// leading underscores
- var binAttDoc = {
- _id: "bin_doc2",
- _attachments:{
- "_foo.txt": {
- content_type:"text/plain",
- data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
- }
- }
- }
+ var binAttDoc = {
+ _id: "bin_doc2",
+ _attachments:{
+ "_foo.txt": {
+ content_type:"text/plain",
+ data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+ }
+ }
+ }
try {
db.save(binAttDoc);
@@ -80,8 +80,8 @@ couchTests.attachment_names = function(debug) {
} catch (e) {
TEquals("bad_request", e.error, "attachment_name: leading underscore");
TEquals("Attachment name can't start with '_'", e.reason, "attachment_name: leading underscore");
- }
-
+ }
+
// todo: form uploads, waiting for cmlenz' test case for form uploads
};
diff --git a/share/www/script/test/attachment_paths.js b/share/www/script/test/attachment_paths.js
index ef9fa869..245d2949 100644
--- a/share/www/script/test/attachment_paths.js
+++ b/share/www/script/test/attachment_paths.js
@@ -44,14 +44,14 @@ couchTests.attachment_paths = function(debug) {
// lets try it with an escaped attachment id...
// weird that it's at two urls
var xhr = CouchDB.request("GET", "/"+dbName+"/bin_doc/foo%2Fbar.txt");
- T(xhr.status == 200);
+ T(xhr.status == 200);
// xhr.responseText == "This is a base64 encoded text"
var xhr = CouchDB.request("GET", "/"+dbName+"/bin_doc/foo/baz.txt");
T(xhr.status == 404);
var xhr = CouchDB.request("GET", "/"+dbName+"/bin_doc/foo%252Fbaz.txt");
- T(xhr.status == 200);
+ T(xhr.status == 200);
T(xhr.responseText == "We like percent two F.");
// require a _rev to PUT
@@ -59,7 +59,7 @@ couchTests.attachment_paths = function(debug) {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:"Just some text"
});
- T(xhr.status == 409);
+ T(xhr.status == 409);
var xhr = CouchDB.request("PUT", "/"+dbName+"/bin_doc/foo/bar2.txt?rev=" + binAttDoc._rev, {
body:"This is no base64 encoded text",
@@ -77,7 +77,7 @@ couchTests.attachment_paths = function(debug) {
T(binAttDoc._attachments["foo/bar2.txt"].length == 30);
//// now repeat the while thing with a design doc
-
+
// first just save a regular doc with an attachment that has a slash in the url.
// (also gonna run an encoding check case)
var binAttDoc = {
@@ -120,7 +120,7 @@ couchTests.attachment_paths = function(debug) {
T(xhr.status == 404);
var xhr = CouchDB.request("GET", "/"+dbName+"/_design%2Fbin_doc/foo%252Fbaz.txt");
- T(xhr.status == 200);
+ T(xhr.status == 200);
T(xhr.responseText == "We like percent two F.");
// require a _rev to PUT
@@ -128,7 +128,7 @@ couchTests.attachment_paths = function(debug) {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:"Just some text"
});
- T(xhr.status == 409);
+ T(xhr.status == 409);
var xhr = CouchDB.request("PUT", "/"+dbName+"/_design%2Fbin_doc/foo/bar2.txt?rev=" + binAttDoc._rev, {
body:"This is no base64 encoded text",
diff --git a/share/www/script/test/attachment_views.js b/share/www/script/test/attachment_views.js
index b97a4130..903fbc4c 100644
--- a/share/www/script/test/attachment_views.js
+++ b/share/www/script/test/attachment_views.js
@@ -73,7 +73,7 @@ couchTests.attachment_views= function(debug) {
var reduceFunction = function(key, values) {
return sum(values);
}
-
+
var result = db.query(mapFunction, reduceFunction);
T(result.rows.length == 1);
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js
index e68cd444..6af6ae8f 100644
--- a/share/www/script/test/attachments.js
+++ b/share/www/script/test/attachments.js
@@ -33,7 +33,7 @@ couchTests.attachments= function(debug) {
T(xhr.responseText == "This is a base64 encoded text");
T(xhr.getResponseHeader("Content-Type") == "text/plain");
T(xhr.getResponseHeader("Etag") == '"' + save_response.rev + '"');
-
+
// empty attachment
var binAttDoc2 = {
_id: "bin_doc2",
@@ -70,7 +70,7 @@ couchTests.attachments= function(debug) {
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc2/foo2.txt");
T(xhr.responseText == "This is no base64 encoded text");
T(xhr.getResponseHeader("Content-Type") == "text/plain;charset=utf-8");
-
+
// test without rev, should fail
var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt");
T(xhr.status == 409);
@@ -78,8 +78,8 @@ couchTests.attachments= function(debug) {
// test with rev, should not fail
var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt?rev=" + rev);
T(xhr.status == 200);
-
-
+
+
// test binary data
var bin_data = "JHAPDO*AU£PN ){(3u[d 93DQ9¡€])} ææøo'∂ƒæ≤çæππ•¥∫¶®#†π¶®¥π€ª®˙π8np";
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt", {
@@ -88,11 +88,11 @@ couchTests.attachments= function(debug) {
});
T(xhr.status == 201);
var rev = JSON.parse(xhr.responseText).rev;
-
+
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt");
T(xhr.responseText == bin_data);
T(xhr.getResponseHeader("Content-Type") == "text/plain;charset=utf-8");
-
+
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt", {
headers:{"Content-Type":"text/plain;charset=utf-8"},
body:bin_data
@@ -116,7 +116,7 @@ couchTests.attachments= function(debug) {
var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev);
T(xhr.status == 200);
-
+
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt");
T(xhr.status == 404);
@@ -137,7 +137,7 @@ couchTests.attachments= function(debug) {
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
T(xhr.status == 200);
T(xhr.responseText.length == 0);
-
+
// overwrite previsously empty attachment
var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt?rev=" + rev, {
headers:{"Content-Type":"text/plain;charset=utf-8"},
@@ -148,8 +148,8 @@ couchTests.attachments= function(debug) {
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
T(xhr.status == 200);
T(xhr.responseText == "This is a string");
-
-
+
+
// Attachment sparseness COUCHDB-220
var docs = []
@@ -167,7 +167,7 @@ couchTests.attachments= function(debug) {
}
db.bulkSave(docs);
-
+
var before = db.info().disk_size;
// Compact it.
@@ -175,14 +175,14 @@ couchTests.attachments= function(debug) {
T(db.last_req.status == 202);
// compaction isn't instantaneous, loop until done
while (db.info().compact_running) {};
-
+
var after = db.info().disk_size;
-
+
// Compaction should reduce the database slightly, but not
// orders of magnitude (unless attachments introduce sparseness)
T(after > before * 0.1, "before: " + before + " after: " + after);
-
-
+
+
// test large attachments - COUCHDB-366
var lorem = CouchDB.request("GET", "/_utils/script/test/lorem.txt").responseText;
diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js
index 47e94d2c..62ac2df9 100644
--- a/share/www/script/test/basics.js
+++ b/share/www/script/test/basics.js
@@ -13,7 +13,7 @@
// Do some basic tests.
couchTests.basics = function(debug) {
var result = JSON.parse(CouchDB.request("GET", "/").responseText);
- T(result.couchdb == "Welcome");
+ T(result.couchdb == "Welcome");
var db = new CouchDB("test_suite_db");
db.deleteDb();
@@ -31,11 +31,11 @@ couchTests.basics = function(debug) {
// creating a new DB should return Location header
xhr = CouchDB.request("DELETE", "/test_suite_db");
xhr = CouchDB.request("PUT", "/test_suite_db");
- TEquals("/test_suite_db",
+ TEquals("/test_suite_db",
xhr.getResponseHeader("Location").substr(-14),
"should return Location header to newly created document");
- TEquals("http://",
+ TEquals("http://",
xhr.getResponseHeader("Location").substr(0, 7),
"should return absolute Location header to newly created document");
@@ -66,7 +66,7 @@ couchTests.basics = function(debug) {
// make sure you can do a seq=true option
var doc = db.open(id, {local_seq:true});
T(doc._local_seq == 1);
-
+
// Create some more documents.
// Notice the use of the ok member on the return result.
@@ -161,11 +161,11 @@ couchTests.basics = function(debug) {
var xhr = CouchDB.request("PUT", "/test_suite_db/newdoc", {
body: JSON.stringify({"a":1})
});
- TEquals("/test_suite_db/newdoc",
+ TEquals("/test_suite_db/newdoc",
xhr.getResponseHeader("Location").substr(-21),
"should return Location header to newly created document");
- TEquals("http://",
+ TEquals("http://",
xhr.getResponseHeader("Location").substr(0, 7),
"should return absolute Location header to newly created document");
@@ -182,12 +182,12 @@ couchTests.basics = function(debug) {
]
var test_doc = function(info) {
var data = JSON.stringify(info[1]);
-
+
xhr = CouchDB.request("PUT", "/test_suite_db/" + info[0], {body: data});
T(xhr.status == 500);
result = JSON.parse(xhr.responseText);
T(result.error == "doc_validation");
-
+
xhr = CouchDB.request("POST", "/test_suite_db/", {body: data});
T(xhr.status == 500);
result = JSON.parse(xhr.responseText);
diff --git a/share/www/script/test/batch_save.js b/share/www/script/test/batch_save.js
index 77aa6635..d2721901 100644
--- a/share/www/script/test/batch_save.js
+++ b/share/www/script/test/batch_save.js
@@ -19,32 +19,32 @@ couchTests.batch_save = function(debug) {
// commit should work fine with no batches
T(db.ensureFullCommit().ok);
-
+
// PUT a doc with ?batch=ok
T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);
// test that response is 200 Accepted
T(db.last_req.status == 202);
T(db.last_req.statusText == "Accepted");
-
+
T(db.allDocs().total_rows == 0);
restartServer();
-
+
// lost the updates
T(db.allDocs().total_rows == 0);
-
+
T(db.save({_id:"0",a:1,b:1}, {batch : "ok"}).ok);
T(db.save({_id:"1",a:1,b:1}, {batch : "ok"}).ok);
T(db.save({_id:"2",a:1,b:1}, {batch : "ok"}).ok);
T(db.ensureFullCommit().ok);
T(db.allDocs().total_rows == 3);
-
+
// repeat the tests for POST
var resp = db.request("POST", db.uri + "?batch=ok", {body: JSON.stringify({a:1})});
T(JSON.parse(resp.responseText).ok);
-
+
// test that response is 200 Accepted
T(resp.status == 202);
T(resp.statusText == "Accepted");
@@ -59,5 +59,5 @@ couchTests.batch_save = function(debug) {
T(db.ensureFullCommit().ok);
T(db.allDocs().total_rows == 5);
-
+
};
diff --git a/share/www/script/test/bulk_docs.js b/share/www/script/test/bulk_docs.js
index 8e73ded4..b4c0ef9d 100644
--- a/share/www/script/test/bulk_docs.js
+++ b/share/www/script/test/bulk_docs.js
@@ -34,7 +34,7 @@ couchTests.bulk_docs = function(debug) {
T(results.length == 5);
for (i = 0; i < 5; i++) {
T(results[i].id == i.toString());
-
+
// set the delete flag to delete the docs in the next step
docs[i]._deleted = true;
}
@@ -72,7 +72,7 @@ couchTests.bulk_docs = function(debug) {
// Now save the bulk docs, When we use all_or_nothing, we don't get conflict
// checking, all docs are saved regardless of conflict status, or none are
// saved.
- results = db.bulkSave(docs,{all_or_nothing:true});
+ results = db.bulkSave(docs,{all_or_nothing:true});
T(results.error === undefined);
var doc = db.open("0", {conflicts:true});
@@ -88,8 +88,8 @@ couchTests.bulk_docs = function(debug) {
T(results[0].id != "");
T(results[0].rev != "");
-
-
+
+
// Regression test for failure on update/delete
var newdoc = {"_id": "foobar", "body": "baz"};
T(db.save(newdoc).ok);
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js
index 98f31d6f..6ae035fa 100644
--- a/share/www/script/test/changes.js
+++ b/share/www/script/test/changes.js
@@ -16,98 +16,98 @@ couchTests.changes = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
var req = CouchDB.request("GET", "/test_suite_db/_changes");
var resp = JSON.parse(req.responseText);
-
+
T(resp.results.length == 0 && resp.last_seq==0)
-
+
var docFoo = {_id:"foo", bar:1};
db.save(docFoo);
-
+
req = CouchDB.request("GET", "/test_suite_db/_changes");
var resp = JSON.parse(req.responseText);
-
+
T(resp.results.length == 1 && resp.last_seq==1)
T(resp.results[0].changes[0].rev == docFoo._rev)
-
+
req = CouchDB.request("GET", "/test_suite_db/_changes?continuous=true&timeout=10");
var resp = JSON.parse(req.responseText);
T(resp.results.length == 1 && resp.last_seq==1)
T(resp.results[0].changes[0].rev == docFoo._rev)
-
+
var xhr;
-
+
try {
xhr = CouchDB.newXhr();
- } catch (err) {
+ } catch (err) {
}
-
+
if (xhr) {
// Only test the continuous stuff if we have a real XHR object
// with real async support.
-
+
var sleep = function(msecs) {
// by making a slow sync request, we allow the waiting XHR request data
// to be received.
var req = CouchDB.request("GET", "/_sleep?time=" + msecs);
T(JSON.parse(req.responseText).ok == true);
}
-
+
var parse_changes_line = function(line) {
if (line.charAt(line.length-1) == ",") {
line = line.substring(0, line.length-1);
}
return JSON.parse(line);
}
-
-
+
+
xhr.open("GET", "/test_suite_db/_changes?continuous=true", true);
xhr.send("");
-
+
var docBar = {_id:"bar", bar:1};
db.save(docBar);
-
+
sleep(100);
var lines = xhr.responseText.split("\n");
-
+
T(lines[0]='{"results":[');
-
+
var change = parse_changes_line(lines[1]);
-
+
T(change.seq == 1)
T(change.id == "foo")
-
+
change = parse_changes_line(lines[2]);
-
+
T(change.seq == 2)
T(change.id == "bar")
T(change.changes[0].rev == docBar._rev)
-
+
var docBaz = {_id:"baz", baz:1};
db.save(docBaz);
-
+
sleep(100);
var lines = xhr.responseText.split("\n");
-
+
change = parse_changes_line(lines[3]);
-
+
T(change.seq == 3);
T(change.id == "baz");
T(change.changes[0].rev == docBaz._rev);
-
-
+
+
xhr = CouchDB.newXhr();
-
+
//verify the hearbeat newlines are sent
xhr.open("GET", "/test_suite_db/_changes?continuous=true&heartbeat=10", true);
xhr.send("");
-
+
sleep(100);
-
+
var str = xhr.responseText;
-
+
T(str.charAt(str.length - 1) == "\n")
T(str.charAt(str.length - 2) == "\n")
}
diff --git a/share/www/script/test/compact.js b/share/www/script/test/compact.js
index a3b55d85..2add707e 100644
--- a/share/www/script/test/compact.js
+++ b/share/www/script/test/compact.js
@@ -43,7 +43,7 @@ couchTests.compact = function(debug) {
T(db.last_req.status == 202);
// compaction isn't instantaneous, loop until done
while (db.info().compact_running) {};
-
+
T(db.ensureFullCommit().ok);
restartServer();
var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
@@ -51,5 +51,5 @@ couchTests.compact = function(debug) {
T(xhr.getResponseHeader("Content-Type") == "text/plain")
T(db.info().doc_count == 1);
T(db.info().disk_size < deletesize);
-
+
};
diff --git a/share/www/script/test/conflicts.js b/share/www/script/test/conflicts.js
index dfd7e8b6..d556acd7 100644
--- a/share/www/script/test/conflicts.js
+++ b/share/www/script/test/conflicts.js
@@ -41,7 +41,7 @@ couchTests.conflicts = function(debug) {
} catch (e) {
T(e.error == "conflict");
}
-
+
var bySeq = db.allDocsBySeq();
T( bySeq.rows.length == 1)
diff --git a/share/www/script/test/delayed_commits.js b/share/www/script/test/delayed_commits.js
index 0ead2d84..1cc0b339 100644
--- a/share/www/script/test/delayed_commits.js
+++ b/share/www/script/test/delayed_commits.js
@@ -15,43 +15,43 @@ couchTests.delayed_commits = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
// By default, couchdb doesn't fully commit documents to disk right away,
- // it waits about a second to batch the full commit flush along with any
+ // it waits about a second to batch the full commit flush along with any
// other updates. If it crashes or is restarted you may lose the most
// recent commits.
-
+
T(db.save({_id:"1",a:2,b:4}).ok);
T(db.open("1") != null);
-
+
restartServer();
-
+
T(db.open("1") == null); // lost the update.
// note if we waited > 1 sec before the restart, the doc would likely
// commit.
-
-
+
+
// Retry the same thing but with full commits on.
-
+
var db2 = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"true"});
-
+
T(db2.save({_id:"1",a:2,b:4}).ok);
T(db2.open("1") != null);
-
+
restartServer();
-
+
T(db2.open("1") != null);
-
+
// You can update but without committing immediately, and then ensure
// everything is commited in the last step.
-
+
T(db.save({_id:"2",a:2,b:4}).ok);
T(db.open("2") != null);
T(db.ensureFullCommit().ok);
restartServer();
-
+
T(db.open("2") != null);
-
+
// However, it's possible even when flushed, that the server crashed between
// the update and the commit, and you don't want to check to make sure
// every doc you updated actually made it to disk. So record the instance
@@ -59,37 +59,37 @@ couchTests.delayed_commits = function(debug) {
// after the flush (the instance start time is returned by the flush
// operation). if they are the same, we know everything was updated
// safely.
-
+
// First try it with a crash.
-
+
var instanceStartTime = db.info().instance_start_time;
-
+
T(db.save({_id:"3",a:2,b:4}).ok);
T(db.open("3") != null);
-
+
restartServer();
-
+
var commitResult = db.ensureFullCommit();
T(commitResult.ok && commitResult.instance_start_time != instanceStartTime);
// start times don't match, meaning the server lost our change
-
+
T(db.open("3") == null); // yup lost it
-
+
// retry with no server restart
-
+
var instanceStartTime = db.info().instance_start_time;
-
+
T(db.save({_id:"4",a:2,b:4}).ok);
T(db.open("4") != null);
-
+
var commitResult = db.ensureFullCommit();
T(commitResult.ok && commitResult.instance_start_time == instanceStartTime);
// Successful commit, start times match!
-
+
restartServer();
-
+
T(db.open("4") != null);
-
+
// Now test that when we exceed the max_dbs_open, pending commits are safely
// written.
T(db.save({_id:"5",foo:"bar"}).ok);
@@ -111,5 +111,5 @@ couchTests.delayed_commits = function(debug) {
dbi.deleteDb();
}
});
-
+
};
diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js
index b1ff8432..403f4e43 100644
--- a/share/www/script/test/design_docs.js
+++ b/share/www/script/test/design_docs.js
@@ -74,16 +74,16 @@ function() {
T(db.ensureFullCommit().ok);
restartServer();
};
-
+
// test when language not specified, Javascript is implied
var designDoc2 = {
_id:"_design/test2",
- // language: "javascript",
+ // language: "javascript",
views: {
single_doc: {map: "function(doc) { if (doc._id == \"1\") { emit(1, null) }}"}
}
};
-
+
T(db.save(designDoc2).ok);
T(db.view("test2/single_doc").total_rows == 1);
@@ -113,14 +113,14 @@ function() {
T(db.deleteDoc(designDoc).ok);
T(db.open(designDoc._id) == null);
T(db.view("test/no_docs") == null);
-
+
T(db.ensureFullCommit().ok);
restartServer();
T(db.open(designDoc._id) == null);
T(db.view("test/no_docs") == null);
-
+
// trigger ddoc cleanup
T(db.viewCleanup().ok);
-
+
});
};
diff --git a/share/www/script/test/design_options.js b/share/www/script/test/design_options.js
index 4d7684c6..952ecc74 100644
--- a/share/www/script/test/design_options.js
+++ b/share/www/script/test/design_options.js
@@ -26,7 +26,7 @@ couchTests.design_options = function(debug) {
language: "javascript",
options: {
include_design: true,
- local_seq: true
+ local_seq: true
},
views: {
data: {"map": map},
@@ -63,7 +63,7 @@ couchTests.design_options = function(debug) {
T(db.save(designDoc).ok);
rows = db.view("bango/data").rows;
T(rows.length == 0);
-
+
// should also have local_seq in the view
var resp = db.save({});
rows = db.view("fu/with_seq").rows;
diff --git a/share/www/script/test/design_paths.js b/share/www/script/test/design_paths.js
index 7722a188..df47fbf2 100644
--- a/share/www/script/test/design_paths.js
+++ b/share/www/script/test/design_paths.js
@@ -18,7 +18,7 @@ couchTests.design_paths = function(debug) {
var dbName = encodeURIComponent(dbNames[i]);
db.deleteDb();
db.createDb();
-
+
// create a ddoc w bulk_docs
db.bulkSave([{
_id : "_design/test",
diff --git a/share/www/script/test/etags_views.js b/share/www/script/test/etags_views.js
index 018bdc25..1356cdb5 100644
--- a/share/www/script/test/etags_views.js
+++ b/share/www/script/test/etags_views.js
@@ -15,7 +15,7 @@ couchTests.etags_views = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
var designDoc = {
_id:"_design/etags",
language: "javascript",
@@ -43,7 +43,7 @@ couchTests.etags_views = function(debug) {
var xhr;
var docs = makeDocs(0, 10);
db.bulkSave(docs);
-
+
// verify get w/Etag on map view
xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/basicView");
T(xhr.status == 200);
@@ -53,7 +53,7 @@ couchTests.etags_views = function(debug) {
});
T(xhr.status == 304);
// TODO GET with keys (when that is available)
-
+
// reduce view
xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/withReduce");
T(xhr.status == 200);
@@ -62,7 +62,7 @@ couchTests.etags_views = function(debug) {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
-
+
// all docs
xhr = CouchDB.request("GET", "/test_suite_db/_all_docs");
T(xhr.status == 200);
@@ -79,7 +79,7 @@ couchTests.etags_views = function(debug) {
xhr = CouchDB.request("GET", "/test_suite_db/_all_docs_by_seq", {
headers: {"if-none-match": etag}
});
- T(xhr.status == 304);
+ T(xhr.status == 304);
// list etag
// in the list test for now
diff --git a/share/www/script/test/invalid_docids.js b/share/www/script/test/invalid_docids.js
index 4fc4bbf5..a9de0e83 100644
--- a/share/www/script/test/invalid_docids.js
+++ b/share/www/script/test/invalid_docids.js
@@ -19,7 +19,7 @@ couchTests.invalid_docids = function(debug) {
// Test _local explicitly first.
T(db.save({"_id": "_local/foo"}).ok);
T(db.open("_local/foo")._id == "_local/foo");
-
+
//Test non-string
try {
db.save({"_id": 1});
diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js
index bbe0814c..f9268479 100644
--- a/share/www/script/test/list_views.js
+++ b/share/www/script/test/list_views.js
@@ -15,7 +15,7 @@ couchTests.list_views = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
var designDoc = {
_id:"_design/lists",
language: "javascript",
@@ -44,12 +44,12 @@ couchTests.list_views = function(debug) {
var row;
while(row = getRow()) {
log("row: "+toJSON(row));
- send(row.key);
+ send(row.key);
};
return "tail";
}),
basicJSON : stringFun(function(head, req) {
- start({"headers":{"Content-Type" : "application/json"}});
+ start({"headers":{"Content-Type" : "application/json"}});
send('{"head":'+toJSON(head)+', ');
send('"req":'+toJSON(req)+', ');
send('"rows":[');
@@ -144,7 +144,7 @@ couchTests.list_views = function(debug) {
send("head");
var row;
while(row = getRow()) {
- send(row.key);
+ send(row.key);
};
getRow();
getRow();
@@ -165,13 +165,13 @@ couchTests.list_views = function(debug) {
};
T(db.save(designDoc).ok);
-
+
var docs = makeDocs(0, 10);
db.bulkSave(docs);
-
+
var view = db.view('lists/basicView');
T(view.total_rows == 10);
-
+
// standard get
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/basicBasic/basicView");
T(xhr.status == 200, "standard get should be 200");
@@ -214,7 +214,7 @@ couchTests.list_views = function(debug) {
T(!(/Key: 1/.test(xhr.responseText)));
T(/FirstKey: 3/.test(xhr.responseText));
T(/LastKey: 9/.test(xhr.responseText));
-
+
// with 0 rows
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/basicView?startkey=30");
T(xhr.status == 200, "0 rows");
@@ -231,19 +231,19 @@ couchTests.list_views = function(debug) {
T(xhr.status == 200, "reduce 0 rows");
T(/Total Rows/.test(xhr.responseText));
T(/LastKey: undefined/.test(xhr.responseText));
-
+
// when there is a reduce present, but not used
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?reduce=false");
T(xhr.status == 200, "reduce false");
T(/Total Rows/.test(xhr.responseText));
T(/Key: 1/.test(xhr.responseText));
-
+
// when there is a reduce present, and used
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true");
T(xhr.status == 200, "group reduce");
T(/Key: 1/.test(xhr.responseText));
-
+
// there should be etags on reduce as well
var etag = xhr.getResponseHeader("etag");
T(etag, "Etags should be served with reduce lists");
@@ -251,11 +251,11 @@ couchTests.list_views = function(debug) {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
-
+
// verify the etags expire correctly
var docs = makeDocs(11, 12);
db.bulkSave(docs);
-
+
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true", {
headers: {"if-none-match": etag}
});
@@ -284,7 +284,7 @@ couchTests.list_views = function(debug) {
});
T(xhr.status == 400);
T(/query_parse_error/.test(xhr.responseText));
-
+
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/rowError/basicView");
T(/ReferenceError/.test(xhr.responseText));
@@ -292,7 +292,7 @@ couchTests.list_views = function(debug) {
// now with extra qs params
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/qsParams/basicView?foo=blam");
T(xhr.responseText.match(/blam/));
-
+
var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter/basicView");
// T(xhr.getResponseHeader("Content-Type") == "text/plain");
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "basic stop");
@@ -305,7 +305,7 @@ couchTests.list_views = function(debug) {
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop");
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/stopIter2/withReduce?group=true");
T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop 2");
-
+
// with accept headers for HTML
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/acceptSwitch/basicView", {
headers: {
diff --git a/share/www/script/test/purge.js b/share/www/script/test/purge.js
index 0b47c0d0..0951bb7a 100644
--- a/share/www/script/test/purge.js
+++ b/share/www/script/test/purge.js
@@ -15,7 +15,7 @@ couchTests.purge = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
/*
purge is not to be confused with a document deletion. It removes the
document and all edit history from the local instance of the database.
@@ -31,7 +31,7 @@ couchTests.purge = function(debug) {
single_doc: {map: "function(doc) { if (doc._id == \"1\") { emit(1, null) }}"}
}
}
-
+
T(db.save(designDoc).ok);
db.bulkSave(makeDocs(1, numDocs + 1));
@@ -43,11 +43,11 @@ couchTests.purge = function(debug) {
T(rows[(2*i)+1].key == i+1);
}
T(db.view("test/single_doc").total_rows == 1);
-
+
var info = db.info();
var doc1 = db.open("1");
var doc2 = db.open("2");
-
+
// purge the documents
var xhr = CouchDB.request("POST", "/test_suite_db/_purge", {
body: JSON.stringify({"1":[doc1._rev], "2":[doc2._rev]}),
@@ -63,35 +63,35 @@ couchTests.purge = function(debug) {
var result = JSON.parse(xhr.responseText);
T(result.purged["1"][0] == doc1._rev);
T(result.purged["2"][0] == doc2._rev);
-
+
T(db.open("1") == null);
T(db.open("2") == null);
-
+
var rows = db.view("test/all_docs_twice").rows;
for (var i = 2; i < numDocs; i++) {
T(rows[2*(i-2)].key == i+1);
T(rows[(2*(i-2))+1].key == i+1);
}
T(db.view("test/single_doc").total_rows == 0);
-
+
// purge documents twice in a row without loading views
// (causes full view rebuilds)
-
+
var doc3 = db.open("3");
var doc4 = db.open("4");
-
+
xhr = CouchDB.request("POST", "/test_suite_db/_purge", {
body: JSON.stringify({"3":[doc3._rev]}),
});
-
+
T(xhr.status == 200);
-
+
xhr = CouchDB.request("POST", "/test_suite_db/_purge", {
body: JSON.stringify({"4":[doc4._rev]}),
});
-
+
T(xhr.status == 200);
-
+
var rows = db.view("test/all_docs_twice").rows;
for (var i = 4; i < numDocs; i++) {
T(rows[2*(i-4)].key == i+1);
diff --git a/share/www/script/test/reduce.js b/share/www/script/test/reduce.js
index c8bdcd92..84230998 100644
--- a/share/www/script/test/reduce.js
+++ b/share/www/script/test/reduce.js
@@ -159,11 +159,11 @@ couchTests.reduce = function(debug) {
docs.push({val:100});
db.bulkSave(docs);
}
-
+
var results = db.query(map, reduceCombine);
-
+
var difference = results.rows[0].value.stdDeviation - 28.722813232690143;
// account for floating point rounding error
T(Math.abs(difference) < 0.0000000001);
-
+
};
diff --git a/share/www/script/test/reduce_builtin.js b/share/www/script/test/reduce_builtin.js
index c3d00339..3dc26862 100644
--- a/share/www/script/test/reduce_builtin.js
+++ b/share/www/script/test/reduce_builtin.js
@@ -15,11 +15,11 @@ couchTests.reduce_builtin = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
var numDocs = 500
var docs = makeDocs(1,numDocs + 1);
db.bulkSave(docs);
-
+
var summate = function(N) {return (N+1)*N/2;};
// this is the same test as the reduce.js test
@@ -42,7 +42,7 @@ couchTests.reduce_builtin = function(debug) {
T(result.rows[0].value == 18);
result = db.query(map, "_count", {startkey: 4, endkey: 5});
T(result.rows[0].value == 4);
-
+
result = db.query(map, "_sum", {startkey: 4, endkey: 6});
T(result.rows[0].value == 30);
result = db.query(map, "_count", {startkey: 4, endkey: 6});
@@ -57,7 +57,7 @@ couchTests.reduce_builtin = function(debug) {
result = db.query(map, "_sum", {startkey: i, endkey: numDocs - i});
T(result.rows[0].value == 2*(summate(numDocs-i) - summate(i-1)));
}
-
+
db.deleteDb();
db.createDb();
@@ -88,7 +88,7 @@ couchTests.reduce_builtin = function(debug) {
for (var b=0; b < builtins.length; b++) {
var fun = builtins[b];
var results = db.query(map, fun, {group:true});
-
+
//group by exact key match
T(equals(results.rows[0], {key:["a"],value:20*i}));
T(equals(results.rows[1], {key:["a","b"],value:20*i}));
@@ -114,6 +114,6 @@ couchTests.reduce_builtin = function(debug) {
T(equals(results.rows[4], {key:["d","a"],value:10*i}));
T(equals(results.rows[5], {key:["d","b"],value:10*i}));
T(equals(results.rows[6], {key:["d","c"],value:10*i}));
- };
+ };
}
} \ No newline at end of file
diff --git a/share/www/script/test/reduce_false.js b/share/www/script/test/reduce_false.js
index 22ef2e8b..e4928cc4 100644
--- a/share/www/script/test/reduce_false.js
+++ b/share/www/script/test/reduce_false.js
@@ -34,7 +34,7 @@ couchTests.reduce_false = function(debug) {
// Test that the reduce works
var res = db.view('test/summate');
T(res.rows.length == 1 && res.rows[0].value == summate(5));
-
+
//Test that we get our docs back
res = db.view('test/summate', {reduce: false});
T(res.rows.length == 5);
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 405b0b1d..c9caa5ee 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -35,7 +35,7 @@ couchTests.replication = function(debug) {
dbA.createDb();
dbB.deleteDb();
dbB.createDb();
-
+
var repTests = {
// copy and paste and put your code in. delete unused steps.
test_template: new function () {
@@ -49,20 +49,20 @@ couchTests.replication = function(debug) {
// called after replicating src=B tgt=A first time.
};
this.afterAB2 = function(dbA, dbB) {
- // called after replicating src=A tgt=B second time.
+ // called after replicating src=A tgt=B second time.
};
this.afterBA2 = function(dbA, dbB) {
// etc...
};
},
-
+
simple_test: new function () {
this.init = function(dbA, dbB) {
var docs = makeDocs(0, numDocs);
dbA.bulkSave(docs);
};
-
- this.afterAB1 = function(dbA, dbB) {
+
+ this.afterAB1 = function(dbA, dbB) {
for (var j = 0; j < numDocs; j++) {
var docA = dbA.open("" + j);
var docB = dbB.open("" + j);
@@ -70,13 +70,13 @@ couchTests.replication = function(debug) {
}
};
},
-
+
deletes_test: new function () {
// make sure deletes are replicated
this.init = function(dbA, dbB) {
T(dbA.save({_id:"foo1",value:"a"}).ok);
};
-
+
this.afterAB1 = function(dbA, dbB) {
var docA = dbA.open("foo1");
var docB = dbB.open("foo1");
@@ -84,13 +84,13 @@ couchTests.replication = function(debug) {
dbA.deleteDoc(docA);
};
-
+
this.afterAB2 = function(dbA, dbB) {
T(dbA.open("foo1") == null);
T(dbB.open("foo1") == null);
};
},
-
+
deleted_test : new function() {
// docs created and deleted on a single node are also replicated
this.init = function(dbA, dbB) {
@@ -98,7 +98,7 @@ couchTests.replication = function(debug) {
var docA = dbA.open("del1");
dbA.deleteDoc(docA);
};
-
+
this.afterAB1 = function(dbA, dbB) {
var rows = dbB.allDocsBySeq().rows;
var rowCnt = 0;
@@ -111,13 +111,13 @@ couchTests.replication = function(debug) {
T(rowCnt == 1);
};
},
-
+
slashes_in_ids_test: new function () {
// make sure docs with slashes in id replicate properly
this.init = function(dbA, dbB) {
dbA.save({ _id:"abc/def", val:"one" });
};
-
+
this.afterAB1 = function(dbA, dbB) {
var docA = dbA.open("abc/def");
var docB = dbB.open("abc/def");
@@ -137,7 +137,7 @@ couchTests.replication = function(debug) {
T(docA._rev == docB._rev);
};
},
-
+
attachments_test: new function () {
// Test attachments
this.init = function(dbA, dbB) {
@@ -161,34 +161,34 @@ couchTests.replication = function(debug) {
}
});
};
-
+
this.afterAB1 = function(dbA, dbB) {
- var xhr = CouchDB.request("GET",
+ var xhr = CouchDB.request("GET",
"/test_suite_db_a/bin_doc/foo%2Bbar.txt");
T(xhr.responseText == "This is a base64 encoded text")
- xhr = CouchDB.request("GET",
+ xhr = CouchDB.request("GET",
"/test_suite_db_b/bin_doc/foo%2Bbar.txt");
T(xhr.responseText == "This is a base64 encoded text")
// and the design-doc
- xhr = CouchDB.request("GET",
+ xhr = CouchDB.request("GET",
"/test_suite_db_a/_design/with_bin/foo%2Bbar.txt");
T(xhr.responseText == "This is a base64 encoded text")
- xhr = CouchDB.request("GET",
+ xhr = CouchDB.request("GET",
"/test_suite_db_b/_design/with_bin/foo%2Bbar.txt");
T(xhr.responseText == "This is a base64 encoded text")
};
},
-
+
conflicts_test: new function () {
// test conflicts
this.init = function(dbA, dbB) {
dbA.save({_id:"foo",value:"a"});
dbB.save({_id:"foo",value:"b"});
};
-
+
this.afterBA1 = function(dbA, dbB) {
var docA = dbA.open("foo", {conflicts: true});
var docB = dbB.open("foo", {conflicts: true});
@@ -202,7 +202,7 @@ couchTests.replication = function(debug) {
// delete a conflict.
dbA.deleteDoc({_id:"foo", _rev:docA._conflicts[0]});
};
-
+
this.afterBA2 = function(dbA, dbB) {
// open documents and include the conflict meta data
var docA = dbA.open("foo", {conflicts: true});
@@ -223,7 +223,7 @@ couchTests.replication = function(debug) {
}
var result = CouchDB.replicate(A, B);
-
+
var seqA = result.source_last_seq;
T(0 == result.history[0].start_last_seq);
T(result.history[1] === undefined)
@@ -233,7 +233,7 @@ couchTests.replication = function(debug) {
}
result = CouchDB.replicate(B, A);
-
+
var seqB = result.source_last_seq;
T(0 == result.history[0].start_last_seq);
T(result.history[1] === undefined)
@@ -243,14 +243,14 @@ couchTests.replication = function(debug) {
}
var result2 = CouchDB.replicate(A, B);
-
+
// each successful replication produces a new session id
T(result2.session_id != result.session_id);
-
+
T(seqA < result2.source_last_seq);
T(seqA == result2.history[0].start_last_seq);
T(result2.history[1].end_last_seq == seqA)
-
+
seqA = result2.source_last_seq;
for(test in repTests) {
@@ -258,17 +258,17 @@ couchTests.replication = function(debug) {
}
result = CouchDB.replicate(B, A)
-
+
T(seqB < result.source_last_seq);
T(seqB == result.history[0].start_last_seq);
T(result.history[1].end_last_seq == seqB)
-
+
seqB = result.source_last_seq;
for(test in repTests) {
if(repTests[test].afterBA2) repTests[test].afterBA2(dbA, dbB);
}
-
+
// do an replication where nothing has changed
result2 = CouchDB.replicate(B, A);
T(result2.no_changes == true);
diff --git a/share/www/script/test/rev_stemming.js b/share/www/script/test/rev_stemming.js
index 3832b520..6dc94f70 100644
--- a/share/www/script/test/rev_stemming.js
+++ b/share/www/script/test/rev_stemming.js
@@ -18,11 +18,11 @@ couchTests.rev_stemming = function(debug) {
dbB.deleteDb();
dbB.createDb();
if (debug) debugger;
-
+
var newLimit = 5;
-
+
T(db.getDbProperty("_revs_limit") == 1000);
-
+
var doc = {_id:"foo",foo:0}
for( var i=0; i < newLimit + 1; i++) {
doc.foo++;
@@ -30,30 +30,30 @@ couchTests.rev_stemming = function(debug) {
}
var doc0 = db.open("foo", {revs:true});
T(doc0._revisions.ids.length == newLimit + 1);
-
+
var docBar = {_id:"bar",foo:0}
for( var i=0; i < newLimit + 1; i++) {
docBar.foo++;
T(db.save(docBar).ok);
}
T(db.open("bar", {revs:true})._revisions.ids.length == newLimit + 1);
-
+
T(db.setDbProperty("_revs_limit", newLimit).ok);
-
+
for( var i=0; i < newLimit + 1; i++) {
doc.foo++;
T(db.save(doc).ok);
}
doc0 = db.open("foo", {revs:true});
T(doc0._revisions.ids.length == newLimit);
-
-
+
+
// If you replicate after you make more edits than the limit, you'll
// cause a spurious edit conflict.
CouchDB.replicate("test_suite_db_a", "test_suite_db_b");
var docB1 = dbB.open("foo",{conflicts:true})
T(docB1._conflicts == null);
-
+
for( var i=0; i < newLimit - 1; i++) {
doc.foo++;
T(db.save(doc).ok);
@@ -69,30 +69,30 @@ couchTests.rev_stemming = function(debug) {
doc.foo++;
T(db.save(doc).ok);
}
-
+
CouchDB.replicate("test_suite_db_a", "test_suite_db_b");
-
+
var docB2 = dbB.open("foo",{conflicts:true});
-
+
// we have a conflict, but the previous replicated rev is always the losing
// conflict
T(docB2._conflicts[0] == docB1._rev)
-
+
// We having already updated bar before setting the limit, so it's still got
// a long rev history. compact to stem the revs.
-
+
T(db.open("bar", {revs:true})._revisions.ids.length == newLimit + 1);
-
+
T(db.compact().ok);
-
+
// compaction isn't instantaneous, loop until done
while (db.info().compact_running) {};
-
+
// force reload because ETags don't honour compaction
var req = db.request("GET", "/test_suite_db_a/bar?revs=true", {
headers:{"if-none-match":"pommes"}
});
-
+
var finalDoc = JSON.parse(req.responseText);
TEquals(newLimit, finalDoc._revisions.ids.length,
"should return a truncated revision list");
diff --git a/share/www/script/test/security_validation.js b/share/www/script/test/security_validation.js
index 1c185c01..05dff613 100644
--- a/share/www/script/test/security_validation.js
+++ b/share/www/script/test/security_validation.js
@@ -16,7 +16,7 @@ couchTests.security_validation = function(debug) {
// specifically for this testing. It is a WWWW-Authenticate scheme named
// X-Couch-Test-Auth, and the user names and passwords are hard coded
// on the server-side.
- //
+ //
// We could have used Basic authentication, however the XMLHttpRequest
// implementation for Firefox and Safari, and probably other browsers are
// broken (Firefox always prompts the user on 401 failures, Safari gives
@@ -45,7 +45,7 @@ couchTests.security_validation = function(debug) {
{section:"httpd",
key: "WWW-Authenticate",
value: "X-Couch-Test-Auth"}],
-
+
function () {
// try saving document usin the wrong credentials
var wrongPasswordDb = new CouchDB("test_suite_db",
@@ -60,8 +60,8 @@ couchTests.security_validation = function(debug) {
T(wrongPasswordDb.last_req.status == 401);
}
- // test force_login=true.
- var resp = wrongPasswordDb.request("GET", "/_whoami?force_login=true");
+ // test force_login=true.
+ var resp = wrongPasswordDb.request("GET", "/_whoami?force_login=true");
var err = JSON.parse(resp.responseText);
T(err.error == "unauthorized");
T(resp.status == 401);
@@ -110,7 +110,7 @@ couchTests.security_validation = function(debug) {
T(user.name == "Damien Katz");
// test that the roles are listed properly
TEquals(user.roles, []);
-
+
// update the document
var doc = userDb.open("testdoc");
@@ -126,7 +126,7 @@ couchTests.security_validation = function(debug) {
T(userDb.last_req.status == 403);
}
- // Now attempt to update the document as a different user, Jan
+ // Now attempt to update the document as a different user, Jan
var user2Db = new CouchDB("test_suite_db",
{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
);
@@ -161,7 +161,7 @@ couchTests.security_validation = function(debug) {
}
// Now delete document
- T(user2Db.deleteDoc(doc).ok);
+ T(user2Db.deleteDoc(doc).ok);
// now test bulk docs
var docs = [{_id:"bahbah",author:"Damien Katz",foo:"bar"},{_id:"fahfah",foo:"baz"}];
@@ -173,11 +173,11 @@ couchTests.security_validation = function(debug) {
T(results[0].error == undefined)
T(results[1].rev === undefined)
T(results[1].error == "forbidden")
-
+
T(db.open("bahbah"));
T(db.open("fahfah") == null);
-
-
+
+
// now all or nothing with a failure
var docs = [{_id:"booboo",author:"Damien Katz",foo:"bar"},{_id:"foofoo",foo:"baz"}];
@@ -188,23 +188,23 @@ couchTests.security_validation = function(debug) {
T(results.errors[0].error == "forbidden");
T(db.open("booboo") == null);
T(db.open("foofoo") == null);
-
-
+
+
// Now test replication
var AuthHeaders = {"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"};
var host = CouchDB.host;
var dbPairs = [
{source:"test_suite_db_a",
target:"test_suite_db_b"},
-
+
{source:"test_suite_db_a",
target:{url: "http://" + host + "/test_suite_db_b",
headers: AuthHeaders}},
-
+
{source:{url:"http://" + host + "/test_suite_db_a",
headers: AuthHeaders},
target:"test_suite_db_b"},
-
+
{source:{url:"http://" + host + "/test_suite_db_a",
headers: AuthHeaders},
target:{url:"http://" + host + "/test_suite_db_b",
@@ -225,7 +225,7 @@ couchTests.security_validation = function(debug) {
adminDbA.createDb();
adminDbB.deleteDb();
adminDbB.createDb();
-
+
// save and replicate a documents that will and will not pass our design
// doc validation function.
dbA.save({_id:"foo1",value:"a",author:"Noah Slater"});
@@ -239,44 +239,44 @@ couchTests.security_validation = function(debug) {
T(dbB.open("foo1"));
T(dbA.open("foo2"));
T(dbB.open("foo2"));
-
+
// save the design doc to dbA
delete designDoc._rev; // clear rev from previous saves
adminDbA.save(designDoc);
// no affect on already saved docs
T(dbA.open("bad1"));
-
+
// Update some docs on dbB. Since the design hasn't replicated, anything
// is allowed.
-
+
// this edit will fail validation on replication to dbA (no author)
T(dbB.save({_id:"bad2",value:"a"}).ok);
-
+
// this edit will fail security on replication to dbA (wrong author
// replicating the change)
var foo1 = dbB.open("foo1");
foo1.value = "b";
dbB.save(foo1);
-
+
// this is a legal edit
var foo2 = dbB.open("foo2");
foo2.value = "b";
dbB.save(foo2);
-
+
var results = CouchDB.replicate(B, A, {headers:AuthHeaders});
-
+
T(results.ok);
-
+
T(results.history[0].docs_written == 1);
T(results.history[0].doc_write_failures == 2);
-
+
// bad2 should not be on dbA
T(dbA.open("bad2") == null);
-
+
// The edit to foo1 should not have replicated.
T(dbA.open("foo1").value == "a");
-
+
// The edit to foo2 should have replicated.
T(dbA.open("foo2").value == "b");
}
diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js
index 64a6788f..7201ae81 100644
--- a/share/www/script/test/show_documents.js
+++ b/share/www/script/test/show_documents.js
@@ -16,12 +16,12 @@ couchTests.show_documents = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
var designDoc = {
_id:"_design/template",
language: "javascript",
shows: {
- "hello" : stringFun(function(doc, req) {
+ "hello" : stringFun(function(doc, req) {
if (doc) {
return "Hello World";
} else {
@@ -77,7 +77,7 @@ couchTests.show_documents = function(debug) {
if (req.headers["Accept"].match(/image/)) {
return {
// a 16x16 px version of the CouchDB logo
- "base64" :
+ "base64" :
["iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAsV",
"BMVEUAAAD////////////////////////5ur3rEBn////////////////wDBL/",
"AADuBAe9EB3IEBz/7+//X1/qBQn2AgP/f3/ilpzsDxfpChDtDhXeCA76AQH/v7",
@@ -129,7 +129,7 @@ couchTests.show_documents = function(debug) {
}
};
T(db.save(designDoc).ok);
-
+
var doc = {"word":"plankton", "name":"Rusty"}
var resp = db.save(doc);
T(resp.ok);
@@ -139,7 +139,7 @@ couchTests.show_documents = function(debug) {
var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/");
T(xhr.status == 404, 'Should be missing');
T(JSON.parse(xhr.responseText).reason == "Invalid path.");
-
+
// hello template world
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/"+docid);
T(xhr.responseText == "Hello World");
@@ -151,7 +151,7 @@ couchTests.show_documents = function(debug) {
// // error stacktraces
// xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/render-error/"+docid);
// T(JSON.parse(xhr.responseText).error == "render_error");
-
+
// hello template world (no docid)
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello");
T(xhr.responseText == "Empty World");
@@ -159,21 +159,21 @@ couchTests.show_documents = function(debug) {
// // hello template world (non-existing docid)
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/nonExistingDoc");
T(xhr.responseText == "New World");
-
+
// show with doc
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/"+docid);
T(xhr.responseText == "Just Rusty");
-
+
// show with missing doc
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/missingdoc");
T(xhr.status == 404, 'Doc should be missing');
T(xhr.responseText == "No such doc");
-
+
// show with missing func
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/missing/"+docid);
T(xhr.status == 404, "function is missing");
-
+
// missing design doc
xhr = CouchDB.request("GET", "/test_suite_db/_design/missingddoc/_show/just-name/"+docid);
T(xhr.status == 404);
@@ -200,7 +200,7 @@ couchTests.show_documents = function(debug) {
T("Accept" == xhr.getResponseHeader("Vary"));
// accept header switching
- // different mime has different etag
+ // different mime has different etag
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/accept-switch/"+docid, {
headers: {"Accept": "text/html;text/plain;*/*"}
});
@@ -227,7 +227,7 @@ couchTests.show_documents = function(debug) {
headers: {"if-none-match": etag}
});
// should be 304
- T(xhr.status == 304);
+ T(xhr.status == 304);
// update the doc
doc.name = "Crusty";
@@ -237,7 +237,7 @@ couchTests.show_documents = function(debug) {
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/"+docid, {
headers: {"if-none-match": etag}
});
- // status is 200
+ // status is 200
T(xhr.status == 200);
// get new etag and request again
@@ -251,7 +251,7 @@ couchTests.show_documents = function(debug) {
// update design doc (but not function)
designDoc.isChanged = true;
T(db.save(designDoc).ok);
-
+
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/"+docid, {
headers: {"if-none-match": etag}
});
@@ -269,7 +269,7 @@ couchTests.show_documents = function(debug) {
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/"+docid, {
headers: {"if-none-match": etag}
});
- // status is 200
+ // status is 200
T(xhr.status == 200);
@@ -287,7 +287,7 @@ couchTests.show_documents = function(debug) {
});
var ct = xhr.getResponseHeader("Content-Type");
T(/charset=utf-8/.test(ct))
- T(/text\/html/.test(ct))
+ T(/text\/html/.test(ct))
T(xhr.responseText == "Ha ha, you said \"plankton\".");
// now with xml
diff --git a/share/www/script/test/stats.js b/share/www/script/test/stats.js
index 8a21dd88..7c9b5da3 100644
--- a/share/www/script/test/stats.js
+++ b/share/www/script/test/stats.js
@@ -76,7 +76,7 @@ couchTests.stats = function(debug) {
})
},
};
-
+
var request_count_tests = {
'should increase the request count for every request': function(name) {
var requests = requestStatsTest("httpd", "requests").current + 1;
@@ -88,7 +88,7 @@ couchTests.stats = function(debug) {
TEquals(requests + 1, new_requests, name);
}
};
-
+
var database_read_count_tests = {
'should increase database reads counter when a document is read': function(name) {
var db = new CouchDB("test_suite_db");
@@ -186,7 +186,7 @@ couchTests.stats = function(debug) {
TEquals(reads + 1 , new_reads, name);
}
};
-
+
var http_requests_by_method_tests = {
'should count GET requests': function(name) {
var requests = requestStatsTest("httpd_request_methods", "GET").current;
@@ -199,7 +199,7 @@ couchTests.stats = function(debug) {
CouchDB.request("POST", "/");
var new_requests = requestStatsTest("httpd_request_methods", "GET").current;
- TEquals(requests + 1, new_requests, name);
+ TEquals(requests + 1, new_requests, name);
},
'should count POST requests': function(name) {
var requests = requestStatsTest("httpd_request_methods", "POST").current;
@@ -229,7 +229,7 @@ couchTests.stats = function(debug) {
var doc = {"_id":"test"};
db.save(doc);
-
+
var updates = requestStatsTest("couchdb", "database_writes").current;
db.save(doc);
var new_updates = requestStatsTest("couchdb", "database_writes").current;
@@ -243,7 +243,7 @@ couchTests.stats = function(debug) {
var doc = {"_id":"test"};
db.save(doc);
-
+
var deletes = requestStatsTest("couchdb", "database_writes").current;
db.deleteDoc(doc);
var new_deletes = requestStatsTest("couchdb", "database_writes").current;
@@ -275,7 +275,7 @@ couchTests.stats = function(debug) {
var docs = makeDocs(5);
db.bulkSave(docs);
-
+
var new_bulks = requestStatsTest("httpd", "bulk_requests").current;
TEquals(bulks + 1, new_bulks, name);
@@ -378,7 +378,7 @@ couchTests.stats = function(debug) {
var options = {};
options.headers = {"Accept": "application/json"};
var summary = JSON.parse(CouchDB.request("GET", "/_stats", options).responseText);
- var aggregates = ["mean", "min", "max", "stddev",
+ var aggregates = ["mean", "min", "max", "stddev",
"current"];
for(var i in aggregates) {
@@ -386,12 +386,12 @@ couchTests.stats = function(debug) {
}
}
};
-
+
var tests = [
open_databases_tests,
- request_count_tests,
- database_read_count_tests,
- view_read_count_tests,
+ request_count_tests,
+ database_read_count_tests,
+ view_read_count_tests,
http_requests_by_method_tests,
document_write_count_tests,
response_codes_tests,
@@ -404,7 +404,7 @@ couchTests.stats = function(debug) {
tests[testGroup][test](test);
}
};
-
+
function createAndRequestView(db) {
var designDoc = {
_id:"_design/test", // turn off couch.js id escaping?
@@ -414,7 +414,7 @@ couchTests.stats = function(debug) {
}
};
db.save(designDoc);
-
+
db.view("test/all_docs_twice");
}
@@ -422,4 +422,3 @@ couchTests.stats = function(debug) {
return CouchDB.requestStats(module, key, true);
}
}
- \ No newline at end of file
diff --git a/share/www/script/test/uuids.js b/share/www/script/test/uuids.js
index 6f701884..f4b95898 100644
--- a/share/www/script/test/uuids.js
+++ b/share/www/script/test/uuids.js
@@ -14,20 +14,20 @@ couchTests.uuids = function(debug) {
var testHashBustingHeaders = function(xhr) {
T(xhr.getResponseHeader("Cache-Control").match(/no-cache/));
T(xhr.getResponseHeader("Pragma") == "no-cache");
-
+
var currentTime = new Date();
var expiresHeader = Date.parse(xhr.getResponseHeader("Expires"));
- var dateHeader = Date.parse(xhr.getResponseHeader("Date"));
-
+ var dateHeader = Date.parse(xhr.getResponseHeader("Date"));
+
T(expiresHeader < currentTime);
T(currentTime - dateHeader < 3000);
};
-
+
var db = new CouchDB("test_suite_db");
db.deleteDb();
db.createDb();
if (debug) debugger;
-
+
// a single UUID without an explicit count
var xhr = CouchDB.request("GET", "/_uuids");
T(xhr.status == 200);
@@ -55,7 +55,7 @@ couchTests.uuids = function(debug) {
T(seen[id] === undefined);
seen[id] = 1;
}
-
+
// ensure we return a 405 on POST
xhr = CouchDB.request("POST", "/_uuids?count=1000");
T(xhr.status == 405);
diff --git a/share/www/script/test/view_collation.js b/share/www/script/test/view_collation.js
index f59204c7..09681cc9 100644
--- a/share/www/script/test/view_collation.js
+++ b/share/www/script/test/view_collation.js
@@ -85,14 +85,14 @@ couchTests.view_collation = function(debug) {
rows = db.query(queryFun, null, queryOptions).rows;
T(rows.length == 1 && equals(rows[0].key, values[i]));
}
-
+
// test inclusive_end=true (the default)
// the inclusive_end=true functionality is limited to endkey currently
// if you need inclusive_start=false for startkey, please do implement. ;)
var rows = db.query(queryFun, null, {endkey : "b", inclusive_end:true}).rows;
T(rows[rows.length-1].key == "b")
// descending=true
- var rows = db.query(queryFun, null, {endkey : "b",
+ var rows = db.query(queryFun, null, {endkey : "b",
descending:true, inclusive_end:true}).rows;
T(rows[rows.length-1].key == "b")
@@ -100,13 +100,13 @@ couchTests.view_collation = function(debug) {
var rows = db.query(queryFun, null, {endkey : "b", inclusive_end:false}).rows;
T(rows[rows.length-1].key == "aa")
// descending=true
- var rows = db.query(queryFun, null, {endkey : "b",
+ var rows = db.query(queryFun, null, {endkey : "b",
descending:true, inclusive_end:false}).rows;
T(rows[rows.length-1].key == "B")
-
+
// inclusive_end=false overrides endkey_docid
var rows = db.query(queryFun, null, {
- endkey : "b", endkey_docid: "b",
+ endkey : "b", endkey_docid: "b",
inclusive_end:false}).rows;
T(rows[rows.length-1].key == "aa")
};
diff --git a/share/www/script/test/view_errors.js b/share/www/script/test/view_errors.js
index c9ef6d0c..545115cf 100644
--- a/share/www/script/test/view_errors.js
+++ b/share/www/script/test/view_errors.js
@@ -15,14 +15,14 @@ couchTests.view_errors = function(debug) {
db.deleteDb();
db.createDb();
if (debug) debugger;
-
-
+
+
run_on_modified_server(
[{section: "couchdb",
key: "os_process_timeout",
value: "500"}],
- function() {
+ function() {
var doc = {integer: 1, string: "1", array: [1, 2, 3]};
T(db.save(doc).ok);
@@ -47,37 +47,37 @@ couchTests.view_errors = function(debug) {
emit([doc._id, doc.undef], null);
});
T(results.total_rows == 0);
-
+
// querying a view with invalid params should give a resonable error message
var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view?startkey=foo", {
headers: {"Content-Type": "application/json"},
- body: JSON.stringify({language: "javascript",
+ body: JSON.stringify({language: "javascript",
map : "function(doc){emit(doc.integer)}"
})
});
T(JSON.parse(xhr.responseText).error == "invalid_json");
-
+
// views should ignore Content-Type, like the rest of CouchDB
var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {
headers: {"Content-Type": "application/x-www-form-urlencoded"},
- body: JSON.stringify({language: "javascript",
+ body: JSON.stringify({language: "javascript",
map : "function(doc){}"
})
});
T(xhr.status == 200);
-
+
var map = function (doc) {emit(doc.integer, doc.integer);};
-
+
try {
db.query(map, null, {group: true});
T(0 == 1);
} catch(e) {
T(e.error == "query_parse_error");
}
-
+
// reduce=false on map views doesn't work, so group=true will
// never throw for temp reduce views.
-
+
var designDoc = {
_id:"_design/test",
language: "javascript",
@@ -89,7 +89,7 @@ couchTests.view_errors = function(debug) {
}
};
T(db.save(designDoc).ok);
-
+
var designDoc2 = {
_id:"_design/testbig",
language: "javascript",
@@ -100,14 +100,14 @@ couchTests.view_errors = function(debug) {
}
};
T(db.save(designDoc2).ok);
-
+
try {
db.view("test/no_reduce", {group: true});
T(0 == 1);
} catch(e) {
T(e.error == "query_parse_error");
}
-
+
try {
db.view("test/no_reduce", {reduce: true});
T(0 == 1);
@@ -122,7 +122,7 @@ couchTests.view_errors = function(debug) {
} catch(e) {
T(e.error == "query_parse_error");
}
-
+
var designDoc3 = {
_id:"_design/infinite",
language: "javascript",
@@ -138,7 +138,7 @@ couchTests.view_errors = function(debug) {
} catch(e) {
T(e.error == "os_process_error");
}
-
+
// Check error responses for invalid multi-get bodies.
var path = "/test_suite_db/_design/test/_view/no_reduce";
var xhr = CouchDB.request("POST", path, {body: "[]"});
diff --git a/share/www/script/test/view_multi_key_design.js b/share/www/script/test/view_multi_key_design.js
index c2833910..d0ba7374 100644
--- a/share/www/script/test/view_multi_key_design.js
+++ b/share/www/script/test/view_multi_key_design.js
@@ -53,7 +53,7 @@ couchTests.view_multi_key_design = function(debug) {
T(keys.indexOf(rows[i].key) != -1);
T(rows[i].key == rows[i].value);
}
-
+
var reduce = db.view("test/summate",{group:true},keys).rows;
T(reduce.length == keys.length);
for(var i=0; i<reduce.length; i++) {
diff --git a/share/www/script/test/view_multi_key_temp.js b/share/www/script/test/view_multi_key_temp.js
index 545e2520..0e42ce67 100644
--- a/share/www/script/test/view_multi_key_temp.js
+++ b/share/www/script/test/view_multi_key_temp.js
@@ -28,7 +28,7 @@ couchTests.view_multi_key_temp = function(debug) {
T(keys.indexOf(rows[i].key) != -1);
T(rows[i].key == rows[i].value);
}
-
+
var reduce = db.query(queryFun, reduceFun, {group:true}, keys).rows;
for(var i=0; i<reduce.length; i++) {
T(keys.indexOf(reduce[i].key) != -1);
diff --git a/share/www/script/test/view_offsets.js b/share/www/script/test/view_offsets.js
index e32d070b..31dee8e9 100644
--- a/share/www/script/test/view_offsets.js
+++ b/share/www/script/test/view_offsets.js
@@ -11,12 +11,12 @@
// the License.
couchTests.view_offsets = function(debug) {
- if (debug) debugger;
+ if (debug) debugger;
var db = new CouchDB("test_suite_db");
db.deleteDb();
db.createDb();
-
+
var designDoc = {
_id : "_design/test",
views : {
@@ -26,7 +26,7 @@ couchTests.view_offsets = function(debug) {
}
};
T(db.save(designDoc).ok);
-
+
var docs = [
{_id : "a1", letter : "a", number : 1, foo: "bar"},
{_id : "a2", letter : "a", number : 2, foo: "bar"},
@@ -88,8 +88,8 @@ couchTests.view_offsets = function(debug) {
];
db.bulkSave(docs);
- var res = db.view("test/offset", {
- startkey: ["b",4], startkey_docid: "b4", endkey: ["b"],
+ var res = db.view("test/offset", {
+ startkey: ["b",4], startkey_docid: "b4", endkey: ["b"],
limit: 2, descending: true, skip: 1
})
diff --git a/share/www/script/test/view_pagination.js b/share/www/script/test/view_pagination.js
index 21eab888..f6154d36 100644
--- a/share/www/script/test/view_pagination.js
+++ b/share/www/script/test/view_pagination.js
@@ -71,7 +71,7 @@ couchTests.view_pagination = function(debug) {
T(queryResults.rows[j].key == i + j);
}
}
-
+
// test endkey_docid
var queryResults = db.query(function(doc) { emit(null, null);}, null, {
startkey: null,
@@ -79,7 +79,7 @@ couchTests.view_pagination = function(debug) {
endkey: null,
endkey_docid: 40
});
-
+
T(queryResults.rows.length == 35)
T(queryResults.total_rows == docs.length)
T(queryResults.offset == 1)