From d7947a3d5aac212f042d5e7665a6a93046e8f711 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Tue, 11 Sep 2012 13:53:42 -0700 Subject: [PATCH] bug 777400 - disable mozApps.installPackage API in Firefox for Desktop and Android; r=fabrice, sr=sicking --- dom/apps/src/Makefile.in | 5 +- dom/apps/src/Webapps.js | 66 +++++++++++++++---- dom/interfaces/apps/Makefile.in | 1 + .../apps/nsIDOMApplicationRegistry.idl | 15 +---- .../apps/nsIDOMApplicationRegistry2.idl | 24 +++++++ .../mochitest/webapps/test_install_errors.xul | 7 ++ dom/tests/mochitest/webapps/test_list_api.xul | 1 - 7 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 dom/interfaces/apps/nsIDOMApplicationRegistry2.idl diff --git a/dom/apps/src/Makefile.in b/dom/apps/src/Makefile.in index a1cf29ed2c47..cd45b7b8853f 100644 --- a/dom/apps/src/Makefile.in +++ b/dom/apps/src/Makefile.in @@ -12,10 +12,13 @@ include $(DEPTH)/config/autoconf.mk EXTRA_COMPONENTS = \ AppsService.js \ AppsService.manifest \ - Webapps.js \ Webapps.manifest \ $(NULL) +EXTRA_PP_COMPONENTS = \ + Webapps.js \ + $(NULL) + EXTRA_PP_JS_MODULES += \ Webapps.jsm \ AppsServiceChild.jsm \ diff --git a/dom/apps/src/Webapps.js b/dom/apps/src/Webapps.js index f5ad514d0a11..1cc6cf3709ac 100644 --- a/dom/apps/src/Webapps.js +++ b/dom/apps/src/Webapps.js @@ -33,7 +33,19 @@ WebappsRegistry.prototype = { __proto__: DOMRequestIpcHelper.prototype, __exposedProps__: { install: 'r', +#ifdef MOZ_PHOENIX +# Firefox Desktop: installPackage not implemented +#elifdef ANDROID +#ifndef MOZ_WIDGET_GONK +# Firefox Android (Fennec): installPackage not implemented +#else +# B2G Gonk: installPackage implemented installPackage: 'r', +#endif +#else +# B2G Desktop and others: installPackage implementation status varies + installPackage: 'r', +#endif getSelf: 'r', getInstalled: 'r', mgmt: 'r' @@ -167,6 +179,18 @@ WebappsRegistry.prototype = { return request; }, + get mgmt() { + if (!this._mgmt) + this._mgmt = new WebappsApplicationMgmt(this._window); + return this._mgmt; + }, + + uninit: function() { + this._mgmt = null; + }, + + // mozIDOMApplicationRegistry2 implementation + installPackage: function(aPackageURL, aParams) { let request = this.createRequest(); let requestID = this.getRequestId(request); @@ -185,16 +209,6 @@ WebappsRegistry.prototype = { return request; }, - get mgmt() { - if (!this._mgmt) - this._mgmt = new WebappsApplicationMgmt(this._window); - return this._mgmt; - }, - - uninit: function() { - this._mgmt = null; - }, - // nsIDOMGlobalPropertyInitializer implementation init: function(aWindow) { this.initHelper(aWindow, ["Webapps:Install:Return:OK", "Webapps:Install:Return:KO", @@ -207,11 +221,39 @@ WebappsRegistry.prototype = { classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"), - QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationRegistry, Ci.nsIDOMGlobalPropertyInitializer]), + QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationRegistry, +#ifdef MOZ_PHOENIX +# Firefox Desktop: installPackage not implemented +#elifdef ANDROID +#ifndef MOZ_WIDGET_GONK +# Firefox Android (Fennec): installPackage not implemented +#else +# B2G Gonk: installPackage implemented + Ci.mozIDOMApplicationRegistry2, +#endif +#else +# B2G Desktop and others: installPackage implementation status varies + Ci.mozIDOMApplicationRegistry2, +#endif + Ci.nsIDOMGlobalPropertyInitializer]), classInfo: XPCOMUtils.generateCI({classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"), contractID: "@mozilla.org/webapps;1", - interfaces: [Ci.mozIDOMApplicationRegistry], + interfaces: [Ci.mozIDOMApplicationRegistry, +#ifdef MOZ_PHOENIX +# Firefox Desktop: installPackage not implemented +#elifdef ANDROID +#ifndef MOZ_WIDGET_GONK +# Firefox Android (Fennec): installPackage not implemented +#else +# B2G Gonk: installPackage implemented + Ci.mozIDOMApplicationRegistry2, +#endif +#else +# B2G Desktop and others: installPackage implementation status varies + Ci.mozIDOMApplicationRegistry2, +#endif + ], flags: Ci.nsIClassInfo.DOM_OBJECT, classDescription: "Webapps Registry"}) } diff --git a/dom/interfaces/apps/Makefile.in b/dom/interfaces/apps/Makefile.in index 7c3cd00cd9a3..e800727f3071 100644 --- a/dom/interfaces/apps/Makefile.in +++ b/dom/interfaces/apps/Makefile.in @@ -17,6 +17,7 @@ GRE_MODULE = 1 XPIDLSRCS = \ mozIApplication.idl \ nsIDOMApplicationRegistry.idl \ + nsIDOMApplicationRegistry2.idl \ nsIAppsService.idl \ nsIDOMMozApplicationEvent.idl \ $(NULL) diff --git a/dom/interfaces/apps/nsIDOMApplicationRegistry.idl b/dom/interfaces/apps/nsIDOMApplicationRegistry.idl index b63def5712ef..e4e688b83b61 100644 --- a/dom/interfaces/apps/nsIDOMApplicationRegistry.idl +++ b/dom/interfaces/apps/nsIDOMApplicationRegistry.idl @@ -73,7 +73,7 @@ interface mozIDOMApplicationMgmt : nsISupports attribute nsIDOMEventListener onuninstall; }; -[scriptable, uuid(8ce06dd2-4c2e-4523-8ea1-960f4a7f0456)] +[scriptable, uuid(dd9a044c-1073-4d2b-a17d-c9b5834b3420)] interface mozIDOMApplicationRegistry : nsISupports { /** @@ -99,18 +99,5 @@ interface mozIDOMApplicationRegistry : nsISupports */ nsIDOMDOMRequest getInstalled(); - /** - * Install a packaged web app. - * - * @param packageUrl : the URL of the webapps manifest. - * @param parameters : A structure with optional information. - * { - * receipts: ... Will be used to specify the payment receipts for this installation. - * categories: ... Will be used to specify the categories of the webapp. - * } - * @returns : A DOMRequest object, returning the app object in |result| if install succeeds. - */ - nsIDOMDOMRequest installPackage(in DOMString packageUrl, [optional] in jsval parameters); - readonly attribute mozIDOMApplicationMgmt mgmt; }; diff --git a/dom/interfaces/apps/nsIDOMApplicationRegistry2.idl b/dom/interfaces/apps/nsIDOMApplicationRegistry2.idl new file mode 100644 index 000000000000..621b2636b037 --- /dev/null +++ b/dom/interfaces/apps/nsIDOMApplicationRegistry2.idl @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsIDOMApplicationRegistry.idl" + +interface nsIDOMDOMRequest; + +[scriptable, uuid(34498a66-3aee-4b80-8b8b-a9c5d5ba32b6)] +interface mozIDOMApplicationRegistry2 : mozIDOMApplicationRegistry +{ + /** + * Install a packaged web app. + * + * @param packageUrl : the URL of the webapps manifest. + * @param parameters : A structure with optional information. + * { + * receipts: ... Will be used to specify the payment receipts for this installation. + * categories: ... Will be used to specify the categories of the webapp. + * } + * @returns : A DOMRequest object, returning the app object in |result| if install succeeds. + */ + nsIDOMDOMRequest installPackage(in DOMString packageUrl, [optional] in jsval parameters); +}; diff --git a/dom/tests/mochitest/webapps/test_install_errors.xul b/dom/tests/mochitest/webapps/test_install_errors.xul index b4feeece4436..5f5325829e49 100644 --- a/dom/tests/mochitest/webapps/test_install_errors.xul +++ b/dom/tests/mochitest/webapps/test_install_errors.xul @@ -24,6 +24,7 @@ var steps = [ invalidManifest, permissionDenied, invalidContent, + installPackageNotImplemented, ]; runAll(steps); @@ -96,5 +97,11 @@ function invalidContent(next) { }; } +function installPackageNotImplemented(next) { + ok(!("installPackage" in navigator.mozApps), + "installPackage not in navigator.mozApps"); + next(); +} + diff --git a/dom/tests/mochitest/webapps/test_list_api.xul b/dom/tests/mochitest/webapps/test_list_api.xul index e8b6482096d5..a6138be50ab8 100644 --- a/dom/tests/mochitest/webapps/test_list_api.xul +++ b/dom/tests/mochitest/webapps/test_list_api.xul @@ -23,7 +23,6 @@ var props = { getInstalled: "function", getSelf: "function", install: "function", - installPackage: "function", mgmt: "object", };