Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #268 from mcav/pop3-trash-connection
Browse files Browse the repository at this point in the history
Bug 945669 - [email/POP3] Make FolderStorage.sliceOpenMostRecent not trigger connection establishment for POP3 folders other than the inbox; clean up tests. r=asuth
  • Loading branch information
mcav committed Dec 4, 2013
2 parents dc77768 + b8332ae commit 511b0df
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/lib/mailapi/pop3/sync.js
Expand Up @@ -41,6 +41,13 @@ function lazyWithConnection(getNew, cbIndex, fn) {
var args = Array.slice(arguments);
require([], function () {
var next = function() {
// Only the inbox actually needs a connection. Using the
// connection in a non-inbox folder is an error.
if (!this.isInbox) {
fn.apply(this, [null].concat(args));
return;
}

this.account.withConnection(function (err, conn, done) {
var callback = args[cbIndex];
if (err) {
Expand Down
4 changes: 4 additions & 0 deletions test/test-files.json
Expand Up @@ -99,6 +99,10 @@
"variants": ["pop3:fake"]
},

"test_pop3_connection_use.js": {
"variants": ["pop3:fake"]
},

"test_activesync_recreate.js": {
"variants": ["activesync:fake"]
},
Expand Down
56 changes: 56 additions & 0 deletions test/unit/test_pop3_connection_use.js
@@ -0,0 +1,56 @@
/**
* Make sure POP3 only opens a connection for the inbox.
**/

define(['rdcommon/testcontext', './resources/th_main',
'wbxml', 'activesync/codepages',
'exports'],
function($tc, $th_main, $wbxml, $ascp, exports) {

var TD = exports.TD = $tc.defineTestsFor(
{ id: 'test_pop3_connection_use' }, null,
[$th_main.TESTHELPER], ['app']);

TD.commonCase('connection use', function(T, RT) {
T.group('setup');
var testUniverse = T.actor('testUniverse', 'U');
var testAccount = T.actor('testAccount', 'A', { universe: testUniverse });
var eSync = T.lazyLogger('sync');

var trashFolder = testAccount.do_useExistingFolderWithType('trash', '');
var inboxFolder = testAccount.do_useExistingFolderWithType('inbox', '');

T.action('close existing connection', function() {
testAccount.folderAccount._conn.disconnect();
});

// Trash must not create a connection.
testAccount.do_openFolderView(
'opens', trashFolder,
{ count: 0, full: 0 },
{ top: true, bottom: true, grow: false, newCount: null },
{
expectFunc: function() {
RT.reportActiveActorThisStep(testAccount.eFolderAccount);
testAccount.eFolderAccount.ignore_saveAccountState();
}
});

// Inbox must create a connection.
testAccount.do_openFolderView(
'opens', inboxFolder,
{ count: 0, full: 0 },
{ top: true, bottom: true, grow: false, newCount: null },
{ syncedToDawnOfTime: true,
expectFunc: function() {
RT.reportActiveActorThisStep(testAccount.eFolderAccount);
testAccount.eFolderAccount.expect_createConnection();
testAccount.eFolderAccount.ignore_saveAccountState();
}
});


T.group('cleanup');
});

}); // end define

0 comments on commit 511b0df

Please sign in to comment.