bug 962858 - bypass native installation during automated tests; r=mfinkle,fabrice

--HG--
extra : rebase_source : bf4a585b4f7bee784d36a7338ba1f592bdedae94
This commit is contained in:
Myk Melez 2014-01-24 20:51:30 -08:00
parent afb16c34a0
commit 01c2a7f857
4 changed files with 48 additions and 7 deletions

View File

@ -1131,7 +1131,7 @@ this.DOMApplicationRegistry = {
switch (aMessage.name) {
case "Webapps:Install": {
#ifdef MOZ_ANDROID_SYNTHAPKS
Services.obs.notifyObservers(null, "webapps-download-apk", JSON.stringify(msg));
Services.obs.notifyObservers(mm, "webapps-runtime-install", JSON.stringify(msg));
#else
this.doInstall(msg, mm);
#endif
@ -1160,7 +1160,7 @@ this.DOMApplicationRegistry = {
break;
case "Webapps:InstallPackage": {
#ifdef MOZ_ANDROID_SYNTHAPKS
Services.obs.notifyObservers(null, "webapps-download-apk", JSON.stringify(msg));
Services.obs.notifyObservers(mm, "webapps-runtime-install-package", JSON.stringify(msg));
#else
this.doInstallPackage(msg, mm);
#endif

View File

@ -334,7 +334,8 @@ var BrowserApp = {
Services.obs.addObserver(this, "gather-telemetry", false);
Services.obs.addObserver(this, "keyword-search", false);
#ifdef MOZ_ANDROID_SYNTHAPKS
Services.obs.addObserver(this, "webapps-download-apk", false);
Services.obs.addObserver(this, "webapps-runtime-install", false);
Services.obs.addObserver(this, "webapps-runtime-install-package", false);
Services.obs.addObserver(this, "webapps-ask-install", false);
Services.obs.addObserver(this, "webapps-launch", false);
Services.obs.addObserver(this, "webapps-uninstall", false);
@ -1579,8 +1580,12 @@ var BrowserApp = {
break;
#ifdef MOZ_ANDROID_SYNTHAPKS
case "webapps-download-apk":
WebappManager.downloadApk(JSON.parse(aData));
case "webapps-runtime-install":
WebappManager.install(JSON.parse(aData), aSubject);
break;
case "webapps-runtime-install-package":
WebappManager.installPackage(JSON.parse(aData), aSubject);
break;
case "webapps-ask-install":

View File

@ -28,9 +28,37 @@ function sendMessageToJava(aMessage) {
this.WebappManager = {
__proto__: DOMRequestIpcHelper.prototype,
downloadApk: function(aMsg) {
get _testing() {
try {
return Services.prefs.getBoolPref("browser.webapps.testing");
} catch(ex) {
return false;
}
},
install: function(aMessage, aMessageManager) {
if (this._testing) {
// Go directly to DOM. Do not download/install APK, do not collect $200.
DOMApplicationRegistry.doInstall(aMessage, aMessageManager);
return;
}
this._downloadApk(aMessage);
},
installPackage: function(aMessage, aMessageManager) {
if (this._testing) {
// Go directly to DOM. Do not download/install APK, do not collect $200.
DOMApplicationRegistry.doInstallPackage(aMessage, aMessageManager);
return;
}
this._downloadApk(aMessage);
},
_downloadApk: function(aMsg) {
let manifestUrl = aMsg.app.manifestURL;
dump("downloadApk for " + manifestUrl);
dump("_downloadApk for " + manifestUrl);
// Get the endpoint URL and convert it to an nsIURI/nsIURL object.
const GENERATOR_URL_PREF = "browser.webapps.apkFactoryUrl";
@ -117,6 +145,11 @@ this.WebappManager = {
uninstall: function(aData) {
dump("uninstall: " + aData.manifestURL);
if (this._testing) {
// We don't have to do anything, as the registry does all the work.
return;
}
// TODO: uninstall the APK.
},

View File

@ -156,3 +156,6 @@ user_pref("browser.download.panel.shown", true);
// prefs for firefox metro.
// Disable first-tun tab
user_pref("browser.firstrun.count", 0);
// Enable webapps testing mode, which bypasses native installation.
user_pref("browser.webapps.testing", true);