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 #20168 from justindarc/bug1015412
Browse files Browse the repository at this point in the history
Bug 1015412 - [FMRadio] Implement new startup loading events
  • Loading branch information
justindarc committed Jun 12, 2014
2 parents a73d0a6 + ac3f203 commit 04f6d08
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
33 changes: 30 additions & 3 deletions apps/fm/js/fm.js
Expand Up @@ -167,7 +167,6 @@ function updatePowerUI() {
var enabled = mozFMRadio.enabled;
if (enabled) {
PerformanceTestingHelper.dispatch('fm-radio-enabled');
PerformanceTestingHelper.dispatch('startup-path-done');
}
console.log('Power status: ' + (enabled ? 'on' : 'off'));
var powerSwitch = $('power-switch');
Expand Down Expand Up @@ -706,8 +705,6 @@ var favoritesList = {
};

function init() {
PerformanceTestingHelper.dispatch('start');

frequencyDialer.init();

var seeking = false;
Expand Down Expand Up @@ -805,6 +802,7 @@ function init() {
updateAirplaneModeUI();
});

// Load the fav list and enable the FM radio if an antenna is available.
historyList.init(function hl_ready() {
if (mozFMRadio.antennaAvailable) {
// Enable FM immediately
Expand All @@ -823,17 +821,46 @@ function init() {
favoritesList.init();
}
updatePowerUI();

// PERFORMANCE EVENT (5): moz-app-loaded
// Designates that the app is *completely* loaded and all relevant
// "below-the-fold" content exists in the DOM, is marked visible,
// has its events bound and is ready for user interaction. All
// required startup background processing should be complete.
window.dispatchEvent(new CustomEvent('moz-app-loaded'));
});
}

window.addEventListener('load', function(e) {
AirplaneModeHelper.ready(function() {
airplaneModeEnabled = AirplaneModeHelper.getStatus() == 'enabled';
init();

// PERFORMANCE EVENT (2): moz-chrome-interactive
// Designates that the app's *core* chrome or navigation interface
// has its events bound and is ready for user interaction.
window.dispatchEvent(new CustomEvent('moz-chrome-interactive'));

// PERFORMANCE EVENT (3): moz-app-visually-complete
// Designates that the app is visually loaded (e.g.: all of the
// "above-the-fold" content exists in the DOM and is marked as
// ready to be displayed).
window.dispatchEvent(new CustomEvent('moz-app-visually-complete'));

// PERFORMANCE EVENT (4): moz-content-interactive
// Designates that the app has its events bound for the minimum
// set of functionality to allow the user to interact with the
// "above-the-fold" content.
window.dispatchEvent(new CustomEvent('moz-content-interactive'));
});
}, false);

// Turn off radio immediately when window is unloaded.
window.addEventListener('unload', function(e) {
mozFMRadio.disable();
}, false);

// PERFORMANCE EVENT (1): moz-chrome-dom-loaded
// Designates that the app's *core* chrome or navigation interface
// exists in the DOM and is marked as ready to be displayed.
window.dispatchEvent(new CustomEvent('moz-chrome-dom-loaded'));
5 changes: 3 additions & 2 deletions tests/performance/startup_events_test.js
Expand Up @@ -19,8 +19,9 @@ var whitelistedApps = [
];

var whitelistedUnifiedApps = [
'settings',
'communications/dialer'
'communications/dialer',
'fm',
'settings'
];

function contains(haystack, needle) {
Expand Down

0 comments on commit 04f6d08

Please sign in to comment.