From 156bdefe5c0f4550a40834e4b0eb31938735d7fb Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Mon, 27 Jan 2014 19:52:11 +0100 Subject: [PATCH] Bug 963475 - Reverse the order of retrieval of message threads. r=gene --- dom/mobilemessage/src/gonk/MobileMessageDB.jsm | 2 +- dom/mobilemessage/tests/marionette/test_getthreads.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dom/mobilemessage/src/gonk/MobileMessageDB.jsm b/dom/mobilemessage/src/gonk/MobileMessageDB.jsm index d9079dcaddf8..ba788732aaba 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDB.jsm +++ b/dom/mobilemessage/src/gonk/MobileMessageDB.jsm @@ -2605,7 +2605,7 @@ MobileMessageDB.prototype = { if (DEBUG) debug("Caught error on transaction ", event.target.errorCode); collector.collect(null, COLLECT_ID_ERROR, COLLECT_TIMESTAMP_UNUSED); }; - let request = threadStore.index("lastTimestamp").openKeyCursor(); + let request = threadStore.index("lastTimestamp").openKeyCursor(null, PREV); request.onsuccess = function(event) { let cursor = event.target.result; if (cursor) { diff --git a/dom/mobilemessage/tests/marionette/test_getthreads.js b/dom/mobilemessage/tests/marionette/test_getthreads.js index fb3de7322ac6..1c80903c65c9 100644 --- a/dom/mobilemessage/tests/marionette/test_getthreads.js +++ b/dom/mobilemessage/tests/marionette/test_getthreads.js @@ -376,6 +376,9 @@ checkFuncs.push(checkThread.bind(null, ["thread 18-1", "thread 18-2"], tasks.push(getAllThreads.bind(null, function(threads) { is(threads.length, checkFuncs.length, "number of threads got"); + // Reverse threads as we iterate over them in reverse order + threads.reverse(); + (function callback() { if (!threads.length) { tasks.next();