зеркало из https://github.com/mozilla/gecko-dev.git
Bug 999653 - Don't manually set allAppsLaunchable but use SpecialPowers.setAllAppsLaunchable. r=fabrice
This commit is contained in:
Родитель
04272068a9
Коммит
dea9c853b9
|
@ -1,35 +1,21 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// Clean up after ourselves once tests are done so the test page is unloaded.
|
||||
window.addEventListener("unload", function restoreAllAppsLaunchable(event) {
|
||||
if (event.target == window.document) {
|
||||
window.removeEventListener("unload", restoreAllAppsLaunchable, false);
|
||||
Webapps.DOMApplicationRegistry.allAppsLaunchable = originalValue;
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
function runAll(steps) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
makeAllAppsLaunchable();
|
||||
/**
|
||||
* On Mac, apps aren't considered launchable right after they've been
|
||||
* installed because the OS takes some time to detect them (so
|
||||
* nsIMacWebAppUtils::pathForAppWithIdentifier() returns null).
|
||||
* That causes methods like mgmt.getAll() to exclude the app from their
|
||||
* results, even though the app is installed and is in the registry.
|
||||
* See the tests under toolkit/webapps for a viable solution.
|
||||
*
|
||||
* To work around this problem, set allAppsLaunchable to true, which makes
|
||||
* all apps considered as launchable.
|
||||
*/
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
|
||||
// Clone the array so we don't modify the original.
|
||||
steps = steps.concat();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
makeAllAppsLaunchable();
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
|
||||
var mmListener = {
|
||||
receiveMessage: function(aMessage) {
|
||||
|
|
|
@ -22,7 +22,7 @@ const Cu = Components.utils;
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
makeAllAppsLaunchable();
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PopupNotifications.jsm");
|
||||
|
|
|
@ -85,6 +85,5 @@ function becomeWebapp(manifestURL, parameters, onBecome) {
|
|||
Services.obs.addObserver(observeInstall, "webapps-ask-install", false);
|
||||
|
||||
// Step 1: Install the app at the URL specified by the manifest.
|
||||
let url = Services.io.newURI(manifestURL, null, null);
|
||||
navigator.mozApps.install(url.spec, parameters);
|
||||
navigator.mozApps.install(manifestURL, parameters);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,8 @@ WebappRT.config = {
|
|||
registryDir: Services.dirsvc.get("ProfD", Ci.nsIFile).path,
|
||||
};
|
||||
|
||||
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
|
||||
DOMApplicationRegistry.allAppsLaunchable = true;
|
||||
|
||||
becomeWebapp("http://mochi.test:8888/tests/webapprt/test/content/test.webapp",
|
||||
undefined, function onBecome() {
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
|
||||
ok(true, "true is true!");
|
||||
|
||||
var self = navigator.mozApps.getSelf();
|
||||
|
|
Загрузка…
Ссылка в новой задаче