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
42
gaia/tests/jsmarionette/plugins/marionette-apps/lib/switchtoapp.js
Executable file
42
gaia/tests/jsmarionette/plugins/marionette-apps/lib/switchtoapp.js
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
var getApp = require('./getapp').getApp;
|
||||
var waitForApp = require('./waitforapp').waitForApp;
|
||||
|
||||
/**
|
||||
* Switch focus to a given app based on the origin.
|
||||
* @param {Apps} apps to manage state.
|
||||
* @param {String} origin of the application.
|
||||
* @param {String} [entrypoint] of the application.
|
||||
* @param {Function} callback [Error err].
|
||||
*/
|
||||
function switchToApp(apps, origin, entrypoint, callback) {
|
||||
if (typeof entrypoint === 'function') {
|
||||
callback = entrypoint;
|
||||
entrypoint = null;
|
||||
}
|
||||
|
||||
var client = apps._client;
|
||||
callback = callback || client.defaultCallback;
|
||||
|
||||
// Always go back to root (system) application.
|
||||
client.switchToFrame();
|
||||
|
||||
return getApp(apps, origin, entrypoint, function(err, app) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return waitForApp(apps, app.source, function(err, iframe) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
// By default, should set focus to the frame.
|
||||
return client.switchToFrame(iframe, {focus: true}, function(err) {
|
||||
return callback(err, iframe, app);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.switchToApp = switchToApp;
|
||||
Loading…
Reference in a new issue