Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(tests): Make IE10/IE11 pass all the mocha tests.
Browse files Browse the repository at this point in the history
* IE10 passes with no additional work.
* IE11 requires mouse interaction for the tests to complete correctly.

issue #1334
  • Loading branch information
Shane Tomlinson committed Jul 3, 2014
1 parent 6554d0f commit 074c724
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 22 deletions.
29 changes: 16 additions & 13 deletions app/scripts/lib/assertion.js
Expand Up @@ -10,24 +10,27 @@ define([
'lib/fxa-client'
],
function (P, jwcrypto, FxaClient) {

var client = new FxaClient();
var CERT_DURATION_MS = 1000 * 60 * 60 * 6; // 6hrs
var ASSERTION_DURATION_MS = 1000 * 60 * 5; // 5mins

function keyPair() {
var d = P.defer();
// for DSA-128 reasons, see http://goo.gl/uAjE41
jwcrypto.generateKeypair({
algorithm: 'DS',
keysize: 128
}, function (err, keypair) {
if (err) {
return d.reject(err);
}
d.resolve(keypair);
});
return d.promise;
return client.getRandomBytes()
.then(function(bytes) {
jwcrypto.addEntropy(bytes);
var d = P.defer();
// for DSA-128 reasons, see http://goo.gl/uAjE41
jwcrypto.generateKeypair({
algorithm: 'DS',
keysize: 128
}, function (err, keypair) {
if (err) {
return d.reject(err);
}
d.resolve(keypair);
});
return d.promise;
});
}

function certificate(audience) {
Expand Down
7 changes: 7 additions & 0 deletions app/scripts/lib/fxa-client.js
Expand Up @@ -91,6 +91,13 @@ function (FxaClient, $, p, Session, AuthErrors, Constants) {
return defer.promise;
},

getRandomBytes: function () {
return this._getClientAsync()
.then(function (client) {
return client.getRandomBytes();
});
},

/**
* Check the user's current password without affecting session state.
*/
Expand Down
2 changes: 1 addition & 1 deletion app/tests/spec/lib/assertion.js
Expand Up @@ -24,7 +24,7 @@ function (chai, $, P,
/*global beforeEach, afterEach, describe, it*/
var assert = chai.assert;
var AUDIENCE = 'http://123done.org';
var ISSUER = 'http://127.0.0.1:9000';
var ISSUER = 'http://' + document.location.hostname + ':9000';
var email;
var password = 'password';
var client;
Expand Down
9 changes: 9 additions & 0 deletions app/tests/spec/lib/fxa-client.js
Expand Up @@ -510,6 +510,15 @@ function (chai, $, p, ChannelMock, testHelpers,
});
});

describe('getRandomBytes', function () {
it('snags some entropy from somewhere', function () {
return client.getRandomBytes()
.then(function (bytes) {
assert.ok(bytes);
});
});
});

});
});

29 changes: 21 additions & 8 deletions app/tests/spec/views/base.js
Expand Up @@ -141,7 +141,7 @@ function (chai, jQuery, BaseView, Translator, EphemeralMessages, Metrics,
jQuery('html').removeClass('no-touch');
});

it('focuses descendent element containing `autofocus` if html has `no-touch` class', function () {
it('focuses descendent element containing `autofocus` if html has `no-touch` class', function (done) {
requiresFocus(function () {
jQuery('html').addClass('no-touch');
// wekbit fails unless focusing another element first.
Expand All @@ -151,22 +151,35 @@ function (chai, jQuery, BaseView, Translator, EphemeralMessages, Metrics,
jQuery('#focusMe').on('focus', function () {
handlerCalled = true;
});
view.afterVisible();

assert.isTrue(handlerCalled);
});
// IE focuses the elements asynchronously.
// Add a bit of delay to give the browser time to do its thing.
setTimeout(function () {
assert.isTrue(handlerCalled);
done();
}, 200);

view.afterVisible();
}, done);
});

it('does not focus descendent element containing `autofocus` if html does not have `no-touch` class', function () {
it('does not focus descendent element containing `autofocus` if html does not have `no-touch` class', function (done) {
requiresFocus(function () {
var handlerCalled = false;
jQuery('#focusMe').on('focus', function () {
handlerCalled = true;
});
view.afterVisible();

assert.isFalse(handlerCalled);
});
// IE focuses the elements asynchronously.
// Add a bit of delay to give the browser time to focus
// the element, if it erroneously does so.
setTimeout(function () {
assert.isFalse(handlerCalled);
done();
}, 200);

view.afterVisible();
}, done);
});
});

Expand Down

0 comments on commit 074c724

Please sign in to comment.