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 #31037 from ferjm/bug1182071.synckeys.2
Browse files Browse the repository at this point in the history
Bug 1182071 - Allow System app to fetch Sync keys. r=kgrandon
  • Loading branch information
ferjm committed Jul 21, 2015
2 parents eaff79a + e33b074 commit 84c3bf6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/system/js/fx_accounts_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ var FxAccountsClient = function FxAccountsClient() {
}, successCb, errorCb);
};

var getKeys = function getKeys(successCb, errorCb) {
sendMessage({
method: 'getKeys'
}, successCb, errorCb);
};

var logout = function logout(successCb, errorCb) {
sendMessage({
method: 'logout'
Expand Down Expand Up @@ -129,6 +135,7 @@ var FxAccountsClient = function FxAccountsClient() {

return {
'getAccounts': getAccounts,
'getKeys': getKeys,
'logout': logout,
'queryAccount': queryAccount,
'resendVerificationEmail': resendVerificationEmail,
Expand Down
43 changes: 42 additions & 1 deletion apps/system/test/unit/fx_accounts_client_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ suite('system/FxAccountsClient >', function() {
suite('Init', function() {
test('Integrity', function() {
assert.isNotNull(FxAccountsClient);
assert.equal(Object.keys(FxAccountsClient).length, 7);
assert.equal(Object.keys(FxAccountsClient).length, 8);
});

test('No event listeners', function() {
Expand Down Expand Up @@ -254,4 +254,45 @@ suite('system/FxAccountsClient >', function() {
});
});

suite('getKeys', function() {
setup(function() {
FxAccountsClient.getKeys(successCb, errorCb);
});

test('Event dispatched to chrome side', function() {
assert.equal(MockDispatchedEvents.length, 1);
assert.ok(MockEventListener.mozFxAccountsChromeEvent);
assert.ok(MockDispatchedEvents[0].detail.id);
assert.ok(MockDispatchedEvents[0].detail.data);
assert.deepEqual(MockDispatchedEvents[0].detail.data, {
method: 'getKeys'
});
});
});

suite('getKeys response', function() {
setup(function() {
MockEventListener.mozFxAccountsChromeEvent({
detail: {
id: MockDispatchedEvents[0].detail.id,
data: expectedData
}
});
});

suiteTeardown(function() {
MockDispatchedEvents = [];
result = null;
error = null;
successCbCalled = false;
errorCbCalled = false;
});

test('On chrome event', function() {
assert.isTrue(successCbCalled);
assert.isFalse(errorCbCalled);
assert.equal(result, expectedData);
});
});

});

0 comments on commit 84c3bf6

Please sign in to comment.