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 #17665 from DouglasSherk/987211-clock-lock-call
Browse files Browse the repository at this point in the history
Bug 987211 - [Dialer][Lockscreen] Fix clock being invisible when receiving a call while screen locked. r=rik
  • Loading branch information
DouglasSherk committed Apr 2, 2014
2 parents 0aee844 + 8251762 commit bc5ccaa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
41 changes: 40 additions & 1 deletion apps/communications/dialer/test/unit/lazy_l10n_test.js
Expand Up @@ -27,6 +27,8 @@ suite('LazyL10n', function() {
teardown(function() {
LazyL10n._inDOM = false;
LazyL10n._loaded = false;
LazyLoader._loaded = {};
LazyLoader._isLoading = {};
});

suite('get', function() {
Expand All @@ -48,6 +50,22 @@ suite('LazyL10n', function() {
return (foundScripts.length == scripts.length);
};

var checkLoadedScripts = function(scripts) {
if (!scripts) {
return true;
}
var numLoaded = 0;
for (var j = 0; j < scripts.length; j++) {
for (var loaded in LazyLoader._loaded) {
if (loaded === scripts[j]) {
numLoaded++;
break;
}
}
}
return numLoaded == scripts.length;
};

test('should call the callback directly if loaded', function(done) {
LazyL10n._loaded = true;

Expand All @@ -58,7 +76,6 @@ suite('LazyL10n', function() {
LazyL10n.get(callback);
});


test('should wait for the localized event if not loaded', function(done) {
LazyL10n._loaded = false;
LazyL10n._inDOM = true;
Expand All @@ -83,9 +100,31 @@ suite('LazyL10n', function() {
assert.isTrue(LazyL10n._inDOM);
assert.isTrue(checkLinkedScripts(['/shared/js/l10n.js',
'/shared/js/l10n_date.js']));
assert.isTrue(checkLoadedScripts(['/shared/js/l10n.js',
'/shared/js/l10n_date.js']));
done();
};

LazyL10n.get(callback);

var evtObject = document.createEvent('Event');
evtObject.initEvent('localized', false, false);
window.dispatchEvent(evtObject);
});

test('subsequent gets should have all dependencies loaded', function(done) {
var headCount = document.head.childNodes.length;

var callback = function() {
assert.isTrue(LazyL10n._inDOM);
assert.isTrue(checkLinkedScripts(['/shared/js/l10n.js',
'/shared/js/l10n_date.js']));
assert.isTrue(checkLoadedScripts(['/shared/js/l10n.js',
'/shared/js/l10n_date.js']));
done();
};

LazyL10n.get(this.sinon.stub());
LazyL10n.get(callback);

var evtObject = document.createEvent('Event');
Expand Down
14 changes: 7 additions & 7 deletions shared/js/lazy_l10n.js
Expand Up @@ -21,25 +21,25 @@
}

if (this._inDOM) {
this._waitForLoad(callback);
this._waitForLoadAndDate(callback);
return;
}

// Add the l10n JS files to the DOM and wait for them to load.
loader.load(['/shared/js/l10n.js']);
this._waitForLoad(function baseLoaded() {
loader.load('/shared/js/l10n_date.js', function cb() {
callback(navigator.mozL10n.get);
});
this._waitForLoadAndDate(function baseLoaded() {
callback(navigator.mozL10n.get);
});
this._inDOM = true;
},

_waitForLoad: function ll10n_waitForLoad(callback) {
_waitForLoadAndDate: function ll10n_waitForLoadAndDate(callback) {
var finalize = this._finalize.bind(this);
window.addEventListener('localized', function onLocalized() {
window.removeEventListener('localized', onLocalized);
finalize(callback);
loader.load('/shared/js/l10n_date.js', function() {
finalize(callback);
});
});
},

Expand Down

0 comments on commit bc5ccaa

Please sign in to comment.