diff options
author | Jan Lehnardt <jan@apache.org> | 2009-08-01 13:50:38 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-08-01 13:50:38 +0000 |
commit | a613317745c9b88e2c0d01e9a24f8b5d7b5b242e (patch) | |
tree | 7380e04e579d83e904165bf46e008ab651b20138 /share | |
parent | 2cf4fec22fa7214b11363eb7430c411e0afa6221 (diff) |
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
Diffstat (limited to 'share')
-rw-r--r-- | share/www/script/test/changes.js | 39 |
1 files changed, 36 insertions, 3 deletions
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 |