B2G/gecko/dom/tests/mochitest/webapps/head.js
/**
 * DOMApplicationRegistry._isLaunchable() sometimes returns false right after
 * installation on Mac, perhaps because of a race condition between
 * WebappsInstaller and nsIMacWebAppUtils::pathForAppWithIdentifier().
 * That causes methods like mgmt.getAll() to exclude the app from their results,
 * even though the app is registered and installed.
 *
 * To work around this problem, set DOMApplicationRegistry.allAppsLaunchable
 * to true, which makes _isLaunchable() return true for all registered apps.
 */
DOMApplicationRegistry._isLaunchable() sometimes returns false right after
installation on Mac, perhaps because of a race condition between
WebappsInstaller and nsIMacWebAppUtils::pathForAppWithIdentifier().
That causes methods like mgmt.getAll() to exclude the app from their results,
even though the app is registered and installed.

To work around this problem, set DOMApplicationRegistry.allAppsLaunchable
to true, which makes _isLaunchable() return true for all registered apps.
DOMApplicationRegistry . _isLaunchable () sometimes returns false right after installation on Mac perhaps because of a race condition between WebappsInstaller and nsIMacWebAppUtils :: pathForAppWithIdentifier () . That causes methods like mgmt . getAll () to exclude the app from their results even though the app is registered and installed . To work around this problem set DOMApplicationRegistry . allAppsLaunchable to true which makes _isLaunchable () return true for all registered apps .
function makeAllAppsLaunchable() {
  var Webapps = {};
  Components.utils.import("resource://gre/modules/Webapps.jsm", Webapps);
  var originalValue = Webapps.DOMApplicationRegistry.allAppsLaunchable;
  Webapps.DOMApplicationRegistry.allAppsLaunchable = true;
  window.addEventListener("unload", function restoreAllAppsLaunchable(event) {
    if (event.target == window.document) {
      window.removeEventListener("unload", restoreAllAppsLaunchable, false);
      Webapps.DOMApplicationRegistry.allAppsLaunchable = originalValue;
    }
  }, false);
}
function makeAllAppsLaunchable ( ) { var Webapps = { } ; Components . utils . import ( "resource://gre/modules/Webapps.jsm" , Webapps ) ; var originalValue = Webapps . DOMApplicationRegistry . allAppsLaunchable ; Webapps . DOMApplicationRegistry . allAppsLaunchable = true ; window . addEventListener ( "unload" , function restoreAllAppsLaunchable ( event ) { if ( event . target == window . document ) { window . removeEventListener ( "unload" , restoreAllAppsLaunchable , false ) ; Webapps . DOMApplicationRegistry . allAppsLaunchable = originalValue ; } } , false ) ; }
DOMApplicationRegistry._isLaunchable() sometimes returns false right after
 installation on Mac, perhaps because of a race condition between
 WebappsInstaller and nsIMacWebAppUtils::pathForAppWithIdentifier().
DOMApplicationRegistry . _isLaunchable () sometimes returns false right after installation on Mac perhaps because of a race condition between WebappsInstaller and nsIMacWebAppUtils :: pathForAppWithIdentifier () .
// Clean up after ourselves once tests are done so the test page is unloaded.