From a613317745c9b88e2c0d01e9a24f8b5d7b5b242e Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sat, 1 Aug 2009 13:50:38 +0000 Subject: implement longpolling for _changes, unify _changes-mode parameters, patch by Benoit Chesneau, closes COUCHDB-241 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@799862 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/changes.js | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'share/www/script') diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js index d805d6cd..1800ca82 100644 --- a/share/www/script/test/changes.js +++ b/share/www/script/test/changes.js @@ -44,7 +44,7 @@ couchTests.changes = function(debug) { T(jsonp_flag == 1); - req = CouchDB.request("GET", "/test_suite_db/_changes?continuous=true&timeout=10"); + req = CouchDB.request("GET", "/test_suite_db/_changes?feed=continuous&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) @@ -75,7 +75,7 @@ couchTests.changes = function(debug) { } - xhr.open("GET", "/test_suite_db/_changes?continuous=true", true); + xhr.open("GET", "/test_suite_db/_changes?feed=continuous", true); xhr.send(""); var docBar = {_id:"bar", bar:1}; @@ -113,7 +113,7 @@ couchTests.changes = function(debug) { xhr = CouchDB.newXhr(); //verify the hearbeat newlines are sent - xhr.open("GET", "/test_suite_db/_changes?continuous=true&heartbeat=10", true); + xhr.open("GET", "/test_suite_db/_changes?feed=continuous&heartbeat=10", true); xhr.send(""); sleep(100); @@ -122,6 +122,39 @@ couchTests.changes = function(debug) { T(str.charAt(str.length - 1) == "\n") T(str.charAt(str.length - 2) == "\n") + + + // test longpolling + xhr = CouchDB.newXhr(); + + xhr.open("GET", "/test_suite_db/_changes?feed=longpoll", true); + xhr.send(""); + + sleep(100); + var lines = xhr.responseText.split("\n"); + T(lines[5]=='"last_seq":3}'); + + xhr = CouchDB.newXhr(); + + xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&since=3", true); + xhr.send(""); + + sleep(100); + + var docBarz = {_id:"barz", bar:1}; + db.save(docBarz); + + sleep(100); + + var lines = xhr.responseText.split("\n"); + + change = parse_changes_line(lines[1]); + + T(change.seq == 4); + T(change.id == "barz"); + T(change.changes[0].rev == docBarz._rev); + T(lines[3]=='"last_seq":4}'); + } // test the filtered changes -- cgit v1.2.3