Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
68
gaia/apps/email/test/marionette/lib/email_data.js
Executable file
68
gaia/apps/email/test/marionette/lib/email_data.js
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
/*jshint node: true, browser: true */
|
||||
/*global marionetteScriptFinished */
|
||||
|
||||
/**
|
||||
* Manipulates email's data APIs in the app.
|
||||
*/
|
||||
function EmailData(client) {
|
||||
this.client = client;
|
||||
}
|
||||
module.exports = EmailData;
|
||||
|
||||
EmailData.prototype = {
|
||||
/**
|
||||
* Gets the current account for the given account ID. Just returns the
|
||||
* _wireRep as that will survive the serialization hops.
|
||||
* @param {String} accountId
|
||||
* @return {Object} the account._wireRep object, or undefined if not found.
|
||||
*/
|
||||
getCurrentAccount: function() {
|
||||
var client = this.client;
|
||||
return client.executeAsyncScript(function() {
|
||||
var model = window.wrappedJSObject.require('model_create').defaultModel;
|
||||
model.latest('account', function(account) {
|
||||
marionetteScriptFinished(account._wireRep);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current account for the given account ID. Just returns the
|
||||
* _wireRep as that will survive the serialization hops.
|
||||
* @param {String} accountId
|
||||
* @return {Object} the account._wireRep object, or undefined if not found.
|
||||
*/
|
||||
waitForCurrentAccountUpdate: function(key, value) {
|
||||
var client = this.client;
|
||||
return client.executeAsyncScript(function(key, value) {
|
||||
|
||||
var account,
|
||||
model = window.wrappedJSObject.require('model_create').defaultModel,
|
||||
acctsSlice = model.api.viewAccounts(false);
|
||||
|
||||
function checkDone() {
|
||||
if (account[key] === value) {
|
||||
acctsSlice.die();
|
||||
marionetteScriptFinished(true);
|
||||
}
|
||||
}
|
||||
|
||||
acctsSlice.oncomplete = function() {
|
||||
account = acctsSlice.defaultAccount;
|
||||
checkDone();
|
||||
};
|
||||
|
||||
acctsSlice.onchange = function(item) {
|
||||
if (account) {
|
||||
if (account.id === item.id) {
|
||||
checkDone();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}, [key, value]);
|
||||
}
|
||||
};
|
||||
|
||||
require('./debug')('email_data', EmailData.prototype);
|
||||
Loading…
Reference in a new issue