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:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,64 @@
'use strict';
var assert = require('assert');
marionette('App', function() {
var subject;
var client = marionette.client();
marionette.plugin('mozApps', require('../lib/apps'));
suite('#launch', function() {
var context;
var CALENDAR_URL = 'app://calendar.gaiamobile.org';
setup(function(done) {
client.mozApps.mgmt.getAll(function(err, result) {
if (err) {
return done(err);
}
for (var i = 0; i < result.length; i++) {
var app = result[i];
if (app.origin === CALENDAR_URL) {
subject = app;
context = client.context;
subject.launch();
done();
}
}
});
});
test('should launch the appropriate app', function(done) {
/**
* @param {string} app src for app.
*/
function checkForApp(app) {
var selector = 'iframe[src="' + app + '"]';
if (client.isSync) {
client.setSearchTimeout(10000);
var result = client.findElement(selector);
assert.notEqual(result.id, undefined);
done();
} else {
client
.setSearchTimeout(10000)
.findElement(selector, function(err, result) {
assert.notEqual(result.id, undefined);
done();
});
}
}
if (client.context !== 'content') {
client.setContext('content');
}
checkForApp(CALENDAR_URL + '/index.html');
});
test('should not change client context', function() {
assert.strictEqual(client.context, context);
});
});
});

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Activity Callee App</title>
<script defer src="/js/index.js"></script>
</head>
<body>
<div>I am Test Activity Callee App</div>
<button id="close-activity" type="button">Close Activity</button>
</body>
</html>

View file

@ -0,0 +1,14 @@
(function(window) {
'use strict';
window.navigator.mozSetMessageHandler('activity', function(activity) {
var closeActivityButton = document.getElementById('close-activity');
closeActivityButton.addEventListener('click', function() {
activity.postResult({
type: 'x-type/blob',
blob: new Blob()
});
});
});
})(window);

View file

@ -0,0 +1,16 @@
{
"name": "Test Activity Callee App",
"description": "Test Activity Callee App",
"type": "certified",
"launch_path": "/index.html",
"activities": {
"pick": {
"filters": {
"type": ["x-type/*"]
},
"disposition": "inline",
"returnValue": true,
"href": "/index.html#x-activity"
}
}
}

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Activity Caller App</title>
<script defer src="/js/index.js"></script>
</head>
<body>
<div>Test Activity Caller App</div>
<button id="open-activity">Open Activity</button>
</body>
</html>

View file

@ -0,0 +1,21 @@
/* global MozActivity */
(function(window) {
'use strict';
window.addEventListener('DOMContentLoaded', function() {
var openActivityButton = document.getElementById('open-activity');
openActivityButton.addEventListener('click', function() {
var activity = new MozActivity({
name: 'pick',
data: {
type: 'x-type/*'
}
});
activity.onerror = function() {
console.warn('Pick activity error %s', activity.error.name);
};
});
});
})(window);

View file

@ -0,0 +1,6 @@
{
"name": "Test Activity Caller App",
"description": "Test Activity Caller App",
"type": "certified",
"launch_path": "/index.html"
}

View file

@ -0,0 +1,32 @@
'use strict';
/* global marionette */
var Apps = require('../lib/apps');
var App = require('../lib/app');
var assert = require('assert');
marionette('Apps', function() {
var client = marionette.client();
marionette.plugin('mozApps', require('../lib/apps'));
suite('#setup', function() {
test('should return an App with a _client', function() {
assert.ok(client.mozApps instanceof Apps);
assert.strictEqual(client.mozApps._client, client);
});
});
suite('#getSelf', function() {
test('should return a current app', function(done) {
client.mozApps.getSelf(function(err, app) {
if (err) {
return done(err);
}
assert.ok(app instanceof App, 'app instanceof App');
done();
});
});
});
});

View file

@ -0,0 +1,68 @@
'use strict';
var assert = require('assert');
marionette('close', function() {
// requires
var Apps = require('../lib/apps'),
close = require('../lib/close').close,
launch = require('../lib/launch').launch,
client = marionette.client();
marionette.plugin('mozApps', Apps);
suite('close app', function() {
var origin = 'app://calendar.gaiamobile.org';
setup(function(done) {
launch(client.mozApps, origin, done);
});
setup(function(done) {
close(client.mozApps, origin, done);
});
test('iframe is gone', function(done) {
client.setSearchTimeout(100);
client.findElement('iframe[src*="' + origin + '"]', function(err, el) {
assert.ok(err, 'has error');
assert.equal(err.type, 'NoSuchElement', 'element is missing');
done();
});
});
});
suite('close entrypoint app', function() {
var origin = 'app://communications.gaiamobile.org';
// launch some other entrypoint
setup(function(done) {
launch(client.mozApps, origin, 'dialer', done);
});
// launch contacts (which we will close later)
var contacts;
setup(function(done) {
launch(client.mozApps, origin, 'contacts', function(err, app) {
contacts = app;
done(err);
});
});
setup(function(done) {
close(client.mozApps, origin, 'contacts', done);
});
test('closes right app', function(done) {
var source = origin + '/' + contacts.entrypoint.details.launch_path;
client.setSearchTimeout(100);
client.findElement('iframe[src*="' + source + '"]', function(err, el) {
assert.ok(err, 'has error');
assert.equal(err.type, 'NoSuchElement', 'element is missing');
done();
});
});
});
});

View file

@ -0,0 +1,97 @@
'use strict';
var assert = require('assert');
marionette('getapp', function() {
var getApp = require('../lib/getapp').getApp;
var sourceForEntrypoint = require('../lib/getapp').sourceForEntrypoint;
marionette.plugin('mozApps', require('../lib/apps'));
var client = marionette.client();
var calendarOrigin = 'app://calendar.gaiamobile.org';
test('success origin', function(done) {
getApp(client.mozApps, calendarOrigin, function(err, app) {
assert.equal(app.origin, calendarOrigin, 'origin');
assert.equal(app.source, calendarOrigin, 'source');
done();
});
});
test('missing origin', function(done) {
var origin = 'xfoobarbaz';
getApp(client.mozApps, origin, function(err) {
assert.ok(err, 'has error');
assert.ok(err.message.match(origin, 'has correct type of error'));
done();
});
});
test('sourceForEntrypoint does not escape hash', function(done) {
var source = sourceForEntrypoint({
origin: 'http://mozilla.org',
entrypoint: {
details: {
launch_path: 'omfg#bbq'
}
}
});
assert.equal(source, 'http://mozilla.org/omfg#bbq');
var origin = 'app://communications.gaiamobile.org';
var entryPoint = 'dialer';
getApp(client.mozApps, origin, entryPoint, function(err, app) {
assert.notEqual(app.source.indexOf('#'), -1, 'source');
done();
});
});
suite('entrypoint apps', function() {
var origin = 'app://communications.gaiamobile.org';
var app;
// get the app without the entrypoint
setup(function(done) {
app = getApp(client.mozApps, origin, function(err, _app) {
app = _app;
done(err);
});
});
test('success', function(done) {
getApp(client.mozApps, origin, 'contacts', function(err, contacts) {
assert.deepEqual(
contacts.entrypoint,
{
name: 'contacts',
details: app.manifest.entry_points.contacts
},
'entrypoint'
);
var launchPath = contacts.entrypoint.details.launch_path;
assert.ok(contacts.source.indexOf(origin) !== -1, 'has origin');
assert.ok(
contacts.source.indexOf(launchPath) !== -1,
'has launchPath'
);
done();
});
});
test('failure', function(done) {
var entrypoint = 'epicfail';
getApp(client.mozApps, origin, entrypoint, function(err) {
assert.ok(err, 'has error');
assert.ok(
err.message.match(entrypoint),
'error message contains: ' + entrypoint
);
done();
});
});
});
});

View file

@ -0,0 +1,44 @@
'use strict';
/* global marionette, setup */
var assert = require('assert');
marionette('getself', function() {
var getSelf = require('../lib/getself').getSelf;
marionette.plugin('mozApps', require('../lib/apps'));
var client = marionette.client();
var origins = {
system: 'app://system.gaiamobile.org',
calendar: 'app://calendar.gaiamobile.org'
};
function testCurrentApp(origin) {
test('current app self', function(done) {
getSelf(client.mozApps, function(err, app) {
assert.equal(app.origin, origins[origin], origin + ' origin');
done();
});
});
}
testCurrentApp('system');
suite('switch app', function() {
setup(function(done) {
if (client.isSync) {
client.apps.launch(origins.calendar);
client.apps.switchToApp(origins.calendar);
done();
} else {
client.apps.launch(origins.calendar, function() {
client.apps.switchToApp(origins.calendar, done);
});
}
});
testCurrentApp('calendar');
});
});

View file

@ -0,0 +1,165 @@
'use strict';
/* global marionette, setup */
var App = require('../lib/app');
var assert = require('assert');
marionette('public interface', function() {
var client = marionette.client();
marionette.plugin('apps', require('../index'));
suite('#launch', function() {
var appOrigin = 'app://calendar.gaiamobile.org';
var selector = 'iframe[src*="calendar"]';
setup(function(done) {
if (client.isSync) {
client.apps.launch(appOrigin);
done();
} else {
client.apps.launch(appOrigin, done);
}
});
test('should create the appropriate app iframe', function(done) {
function checkElement(err, el) {
assert.ok(!err);
assert.ok(!!el);
done();
}
client.scope({ searchTimeout: 1000 });
if (client.isSync) {
var el = client.findElement(selector);
checkElement(null, el);
} else {
client.findElement(selector, checkElement);
}
});
suite('#switchToApp', function() {
setup(function(done) {
if (client.isSync) {
client.apps.switchToApp(appOrigin);
done();
} else {
client.apps.switchToApp(appOrigin, done);
}
});
test('should put us in the app', function(done) {
function checkLocation(err, href) {
assert.ok(href.indexOf(appOrigin) !== -1);
done();
}
function loc() {
return window.location.href;
}
if (client.isSync) {
var href = client.executeScript(loc);
checkLocation(null, href);
} else {
client.executeScript(loc, checkLocation);
}
});
});
suite('#close', function() {
setup(function(done) {
if (client.isSync) {
client.apps.close(appOrigin);
done();
} else {
client.apps.close(appOrigin, done);
}
});
test('should get rid of app iframe', function(done) {
client.setSearchTimeout(10);
if (client.isSync) {
try {
client.findElement(selector);
} catch (err) {
assert.strictEqual(err.type, 'NoSuchElement');
done();
}
} else {
client.findElement(selector, function(err) {
assert.strictEqual(err.type, 'NoSuchElement');
done();
});
}
});
});
});
suite('#list', function() {
var apps;
setup(function(done) {
if (client.isSync) {
apps = client.apps.list();
done();
} else {
client.apps.list(function(err, _apps) {
apps = _apps;
done();
});
}
});
test('should return many things', function() {
assert.notStrictEqual(apps.length, 0);
});
test('should return things and only things that are apps', function() {
apps.forEach(function(app) {
assert.ok(app instanceof App, app.origin);
});
});
});
suite('#getApp', function() {
var app;
var origin = 'app://calendar.gaiamobile.org';
setup(function(done) {
if (client.isSync) {
app = client.apps.getApp(origin);
done();
} else {
client.apps.getApp(origin, function(err, _app) {
app = _app;
done(err);
});
}
});
test('should return app object', function() {
assert.equal(app.origin, origin);
});
});
suite('#getSelf', function() {
var app;
setup(function(done) {
if (client.isSync) {
app = client.apps.getSelf();
done();
} else {
client.apps.getSelf(function(err, _app) {
app = _app;
done(err);
});
}
});
test('should return a current app object', function() {
assert.ok(app instanceof App, app.origin);
});
});
});

View file

@ -0,0 +1,132 @@
'use strict';
var assert = require('assert');
marionette('launch', function() {
// requires
var launch = require('../lib/launch').launch,
getApp = require('../lib/getapp').getApp;
var client = marionette.client();
marionette.plugin('mozApps', require('../lib/apps'));
suite('launch installed app', function() {
function waitForVisibility(iframe, callback) {
iframe.displayed(function(err, isDisplayed) {
if (err) return callback(err);
if (isDisplayed)
return callback();
setTimeout(waitForVisibility, 250, iframe, callback);
});
}
function getAppFrame(origin, callback) {
client.findElement('iframe[src*="' + origin + '"]', callback);
}
var origin = 'app://calendar.gaiamobile.org';
setup(function(done) {
launch(client.mozApps, origin, done);
});
// find iframe
var iframe;
setup(function(done) {
getAppFrame(origin, function(err, el) {
iframe = el;
done(err);
});
});
test('iframe exists', function() {
assert.ok(iframe, 'iframe exists');
});
test('iframe is visible', function(done) {
this.timeout('10s');
/**
* Wait until iframe is visible.
*/
waitForVisibility(iframe, done);
});
test('double launch does not timeout', function(done) {
client.switchToFrame();
launch(client.mozApps, origin, function() {
getAppFrame(origin, function(err, el) {
if (err) {
return done(err);
}
waitForVisibility(el, done);
});
});
});
});
suite('entrypoints', function() {
var origin = 'app://communications.gaiamobile.org';
var app;
setup(function(done) {
getApp(client.mozApps, origin, function(err, _app) {
app = _app;
done(err);
});
});
test('has entry_points', function() {
assert.ok(app.manifest.entry_points, 'entrypoints are availalbe');
});
function launchApp(entrypoint) {
var state = {};
setup(function(done) {
launch(client.mozApps, origin, entrypoint, function(err, app, el) {
state.error = err;
state.app = app;
state.frame = el;
done();
});
});
return state;
}
suite('success', function() {
// launch another app with this domain first to verify we can actually
// pick the right one.
var dialer = launchApp('dialer');
var contacts = launchApp('contacts');
test('is launched to entrypoint', function(done) {
assert.ok(!dialer.error, 'other app launched');
var entrypoint = app.manifest.entry_points.contacts;
// switch to new iframe
client.switchToFrame(contacts.frame);
// verify we are at the right entrypoint
client.getUrl(function(err, url) {
assert.ok(
url.indexOf(entrypoint.launch_path) !== -1,
url + ' contains ' + entrypoint
);
done();
});
});
});
suite('failure', function() {
var fakeapp = launchApp('nowayappisnamedthis');
test('fails with an error', function() {
assert.ok(fakeapp.error, 'has an error' + fakeapp.error);
assert.ok(fakeapp.error.message.match(/entrypoint/));
});
});
});
});

View file

@ -0,0 +1,80 @@
'use strict';
/* global marionette, setup */
var App = require(__dirname + '/../lib/app');
var assert = require('assert');
marionette('mgmt', function() {
var subject;
var client = marionette.client();
marionette.plugin('mozApps', require('../lib/apps'));
setup(function() {
subject = client.mozApps.mgmt;
});
function checkApp(app) {
assert.ok(app instanceof App, 'app instanceof App');
assert.equal(typeof(app.installOrigin), 'string');
assert.ok(app.installOrigin.length > 0);
assert.equal(typeof(app.installTime), 'number');
assert.ok(app.installTime > 0);
assert.equal(typeof(app.manifestURL), 'string');
assert.ok(app.manifestURL.length > 0);
assert.equal(typeof(app.origin), 'string');
assert.ok(app.origin.length > 0);
assert.equal(typeof app.manifest, 'object');
}
suite('#getAll', function() {
var context;
test('should return an array of app objects', function(done) {
function checkApps(apps) {
assert.ok(apps.length > 0);
apps.forEach(checkApp);
}
subject.getAll(function(err, list) {
if (err) {
return done(err);
}
checkApps(list);
done();
});
});
test('should not change client context', function(done) {
context = client.context;
subject.getAll(function() {
assert.strictEqual(client.context, context);
done();
});
});
});
suite('#getSelf', function() {
var context;
test('should return a current app', function(done) {
subject.getSelf(function(err, app) {
if (err) {
return done(err);
}
checkApp(app);
done();
});
});
test('should not change client context', function(done) {
context = client.context;
subject.getSelf(function() {
assert.strictEqual(client.context, context);
done();
});
});
});
});

View file

@ -0,0 +1,97 @@
'use strict';
var assert = require('assert');
var fs = require('fs');
marionette('ObjectCache', function() {
var ObjectCache, script, window;
setup(function() {
var filename = __dirname + '/../lib/scripts/objectcache.js';
script = fs.readFileSync(filename, 'utf8');
window = {
wrappedJSObject: {}
};
eval(script);
ObjectCache = window.wrappedJSObject.ObjectCache;
});
suite('load', function() {
test('should define ObjectCache', function() {
assert.notEqual(ObjectCache, undefined);
});
test('should make an ObjectCache', function() {
assert.deepEqual(ObjectCache._inst._cache, {});
assert.strictEqual(ObjectCache._inst._nextId, 0);
});
});
suite('#get', function() {
var one, two, three;
setup(function() {
one = { fish: 'blue' };
two = { fish: 'red' };
three = {
dog: 'linus',
human: 'alison',
parrot: 'harvey',
number: 3
};
ObjectCache._inst._cache = {
'1': one,
'2': two,
'3': three
};
});
test('should read things from the internal _cache', function() {
assert.deepEqual(ObjectCache._inst.get('1'), one);
assert.deepEqual(ObjectCache._inst.get('2'), two);
assert.deepEqual(ObjectCache._inst.get('3'), three);
});
});
suite('#set', function() {
var bweop, resultWithKey, resultWithoutKey;
setup(function() {
bweop = { fish: 'blue' };
resultWithKey = ObjectCache._inst.set(bweop, 'bweop');
resultWithoutKey = ObjectCache._inst.set(bweop);
});
test('should write things to the internal _cache', function() {
assert.deepEqual(ObjectCache._inst._cache.bweop, bweop);
assert.deepEqual(ObjectCache._inst._cache['1'], bweop);
});
test('should take key if provided', function() {
assert.deepEqual(resultWithKey, 'bweop');
});
test('should generate a new key when no key is provided', function() {
assert.strictEqual(resultWithoutKey, '1');
});
});
suite('#getNextId', function() {
var result;
setup(function() {
ObjectCache._inst._nextId = 5;
result = ObjectCache._inst.getNextId();
});
test('should return a string equal to previous nextId + 1', function() {
assert.strictEqual(result, '6');
});
test('should update internal count', function() {
assert.strictEqual(ObjectCache._inst._nextId, 6);
});
});
});

View file

@ -0,0 +1,78 @@
'use strict';
var assert = require('assert');
marionette('switchToActivity', function() {
var launch = require('../lib/launch').launch;
var switchToApp = require('../lib/switchtoapp').switchToApp;
var switchToActivity = require('../lib/switchtoactivity').switchToActivity;
var ACTIVITY_CALLER_DOMAIN = 'activity.caller.gaiamobile.org';
var ACTIVITY_CALLEE_DOMAIN = 'activity.callee.gaiamobile.org';
var apps = {};
apps[ACTIVITY_CALLER_DOMAIN] = __dirname + '/apps/activitycaller';
apps[ACTIVITY_CALLEE_DOMAIN] = __dirname + '/apps/activitycallee';
var profile = {
settings: {
'ftu.manifestURL': null,
'lockscreen.enabled': false,
'screen.timeout': 0
},
// Need this so that swithToApp can also focus on the app frame.
prefs: {
'focusmanager.testmode': true
},
apps: apps
};
var client = marionette.client({ profile: profile });
marionette.plugin('mozApps', require('../lib/apps'));
suite('switch to app that is run as inline activity', function() {
var activityCallerOrigin = 'app://' + ACTIVITY_CALLER_DOMAIN;
var activityCalleeOrigin = 'app://' + ACTIVITY_CALLEE_DOMAIN;
var href = '/index.html#x-activity';
setup(function(done) {
launch(client.mozApps, activityCallerOrigin, done);
});
setup(function(done) {
switchToApp(client.mozApps, activityCallerOrigin, function(err) {
if (err) {
return done(err);
}
// Run activity callee as inline activity
client.findElement('#open-activity').tap();
client.switchToFrame();
switchToActivity(client.mozApps, activityCalleeOrigin, href, done);
});
});
test('should be visible', function() {
client.switchToFrame();
var iframe = client.findElement(
'iframe[src*="' + activityCalleeOrigin + '"]'
);
assert.ok(iframe);
assert.ok(iframe.displayed());
});
test('app should be the target of scripts', function() {
var location = client.executeScript(function() {
return window.wrappedJSObject.location.href;
});
assert.ok(location.indexOf(activityCalleeOrigin) === 0);
});
test('app should have the focus', function() {
assert.ok(client.executeScript(function() {
return window.wrappedJSObject.document.hasFocus();
}));
});
});
});

View file

@ -0,0 +1,112 @@
'use strict';
var assert = require('assert');
marionette('launch', function() {
var launch = require('../lib/launch').launch;
var switchToApp = require('../lib/switchtoapp').switchToApp;
var profile = {
settings: {
'ftu.manifestURL': null,
'lockscreen.enabled': false
},
// Need this so that swithToApp can also focus on the app frame.
prefs: {
'focusmanager.testmode': true
}
};
var client = marionette.client({ profile: profile });
var system;
marionette.plugin('mozApps', require('../lib/apps'));
setup(function() {
system = client.loader.getAppClass('system');
system.waitForFullyLoaded();
});
suite('switch to running app', function() {
var domain = 'homescreen.gaiamobile.org';
var origin = 'app://' + domain;
setup(function(done) {
switchToApp(client.mozApps, origin, done);
});
test('should be visible', function(done) {
// switch to root (system app)
client.switchToFrame();
client.findElement('iframe[src*="' + domain + '"]', function(err, el) {
if (err) return done(err);
el.displayed(function(err, isDisplayed) {
assert.ok(isDisplayed);
done();
});
});
});
test('app should be the target of scripts', function(done) {
function remote() {
return window.wrappedJSObject.location.href;
}
client.executeScript(remote, function(err, result) {
assert.ok(result);
done();
});
});
test('app should have the focus', function(done) {
function remote() {
return window.wrappedJSObject.document.hasFocus();
}
client.executeScript(remote, function(err, result) {
assert.ok(result);
done();
});
});
test('should be able to switchToApp from app to app', function(done) {
// already called switchToApp once by now, call it again.
switchToApp(client.mozApps, origin);
function remote() {
return window.wrappedJSObject.document.hasFocus();
}
client.executeScript(remote, function(err, result) {
assert.ok(result);
done();
});
});
});
suite('entrypoint', function() {
var origin = 'app://communications.gaiamobile.org';
var entrypoint = 'contacts';
var app;
setup(function(done) {
launch(client.mozApps, origin, entrypoint, function(err, _app) {
app = _app;
done(err);
});
});
setup(function(done) {
switchToApp(client.mozApps, origin, entrypoint, done);
});
test('context of marionette after switch', function(done) {
client.getUrl(function(err, url) {
assert.ok(
url.indexOf(app.source) !== -1,
'url contains: ' + app.source
);
done(err);
});
});
});
});

View file

@ -0,0 +1,154 @@
'use strict';
var assert = require('assert');
marionette('waitforapp', function() {
// requires
var launch = require('../lib/launch').launch;
var switchToApp = require('../lib/switchtoapp').switchToApp;
var waitForApp = require('../lib/waitforapp').waitForApp;
var waitForActivity = require('../lib/waitforapp').waitForActivity;
var ACTIVITY_CALLER_DOMAIN = 'activity.caller.gaiamobile.org';
var ACTIVITY_CALLEE_DOMAIN = 'activity.callee.gaiamobile.org';
var apps = {};
apps[ACTIVITY_CALLER_DOMAIN] = __dirname + '/apps/activitycaller';
apps[ACTIVITY_CALLEE_DOMAIN] = __dirname + '/apps/activitycallee';
var client = marionette.client({
profile: {
settings: {
'ftu.manifestURL': null,
'lockscreen.enabled': false,
'screen.timeout': 0
},
apps: apps
}
});
marionette.plugin('mozApps', require('../lib/apps'));
function getParentClass(iframeElement) {
return iframeElement.scriptWith(function(el) {
return el.parentNode.getAttribute('class');
});
}
function getTransitionState(iframeElement) {
return iframeElement.scriptWith(function(el) {
return el.parentNode.parentNode.getAttribute('transition-state');
});
}
test(function() {
assert.equal(true, false);
});
suite('waiting for running app', function() {
var domain = 'homescreen.gaiamobile.org';
var element;
setup(function(done) {
this.timeout('20s');
waitForApp(client.mozApps, domain, function(err, el) {
if (err) return done(err);
element = el;
done();
});
});
test('it should return element', function() {
assert.ok(element);
assert.ok(element.getAttribute('src').indexOf(domain) !== -1);
});
test('iframe is with the render class', function() {
var iframe = client.findElement('iframe[src*="' + domain + '"]');
assert.ok(iframe);
assert.ok(getParentClass(iframe).indexOf('render') >= 0);
});
test('the transition-state of the iframe is opened', function() {
var iframe = client.findElement('iframe[src*="' + domain + '"]');
assert.ok(iframe);
assert.equal(getTransitionState(iframe), 'opened');
});
test('iframe is visible', function() {
var iframe = client.findElement('iframe[src*="' + domain + '"]');
assert.ok(iframe);
assert.ok(iframe.displayed());
});
});
suite('correctly works with inline activity apps', function() {
var activityCallerOrigin = 'app://' + ACTIVITY_CALLER_DOMAIN;
var activityCalleeOrigin = 'app://' + ACTIVITY_CALLEE_DOMAIN;
setup(function(done) {
launch(client.mozApps, activityCalleeOrigin, done);
});
setup(function(done) {
launch(client.mozApps, activityCallerOrigin, done);
});
setup(function(done) {
switchToApp(client.mozApps, activityCallerOrigin, function(err) {
if (err) {
return done(err);
}
// Run activity callee as inline activity
client.findElement('#open-activity').tap();
client.switchToFrame();
done();
});
});
test('waitForActivity should return activity iframe', function(done) {
waitForActivity(client.mozApps, ACTIVITY_CALLEE_DOMAIN,
function(err, el) {
if (err) {
return done(err);
}
assert.ok(el);
assert.ok(el.displayed());
assert.ok(el.getAttribute('src').indexOf(activityCalleeOrigin) === 0);
assert.ok(
el.getAttribute('parentapp').indexOf(activityCallerOrigin) === 0
);
assert.ok(getParentClass(el).indexOf('render') >= 0);
assert.equal(getTransitionState(el), 'opened');
done();
});
});
test('waitForApp should return non-activity iframe', function(done) {
// Focus on main instance
launch(client.mozApps, activityCalleeOrigin, function(err) {
if (err) {
return done(err);
}
waitForApp(client.mozApps, ACTIVITY_CALLEE_DOMAIN, function(err, el) {
if (err) {
return done(err);
}
assert.ok(el);
assert.ok(el.displayed());
assert.ok(el.getAttribute('src').indexOf(activityCalleeOrigin) === 0);
assert.equal(el.getAttribute('parentapp'), null);
assert.ok(getParentClass(el).indexOf('render') >= 0);
assert.equal(getTransitionState(el), 'opened');
done();
});
});
});
});
});