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 #21472 from mikehenrty/bug-994079-integration-test
Browse files Browse the repository at this point in the history
Bug 994079 - integration tests for mozApps.getSelf
  • Loading branch information
mikehenrty committed Jul 9, 2014
2 parents bc59445 + 5f429ed commit 4233e61
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions apps/system/test/marionette/apps_test.js
@@ -0,0 +1,50 @@
'use strict';

var assert = require('chai').assert;

marionette('mozApps', function() {

var client = marionette.client({
settings: {
'ftu.manifestURL': null
}
});

suite('getSelf', function() {
test('multiple calls should all return', function() {
var error = client.executeAsyncScript(function() {

// helper object to ensure we get expected number of callbacks
function CallbackHelper(callback) {
this.waitingFor = 0;
this.calledCount = 0;
this.callback = callback;
}
CallbackHelper.prototype = {
expectCallback: function() {
++this.waitingFor;
return function() {
if (++this.calledCount === this.waitingFor) {
this.callback();
}
}.bind(this);
}
};

var helper = new CallbackHelper(marionetteScriptFinished);

var req1 = navigator.mozApps.getSelf();
req1.onsuccess = helper.expectCallback();
req1.onerror = marionetteScriptFinished.bind(null,
'first getSelf() request failed');

var req2 = navigator.mozApps.getSelf();
req2.onsuccess = helper.expectCallback();
req2.onerror = marionetteScriptFinished.bind(null,
'second getSelf() request failed');
});

assert.isNull(error, 'Error: ' + error);
});
});
});

0 comments on commit 4233e61

Please sign in to comment.