This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21472 from mikehenrty/bug-994079-integration-test
Bug 994079 - integration tests for mozApps.getSelf
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); |