mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 865207 - Move webapps actor from /b2g/chrome/content to /toolkit/devtools/apps/. r=fabrice, r=dcamp
--HG-- rename : dom/apps/tests/unit/data/app.zip => toolkit/devtools/apps/tests/unit/data/app.zip rename : dom/apps/tests/unit/test_webappsActor.js => toolkit/devtools/apps/tests/unit/test_webappsActor.js rename : b2g/chrome/content/dbg-webapps-actors.js => toolkit/devtools/server/actors/webapps.js
This commit is contained in:
parent
d6dbd572c6
commit
5a8eadd448
@ -1009,7 +1009,7 @@ let RemoteDebugger = {
|
||||
}
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js");
|
||||
DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js');
|
||||
DebuggerServer.addActors('chrome://browser/content/dbg-webapps-actors.js');
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webapps.js");
|
||||
}
|
||||
|
||||
let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000;
|
||||
|
@ -10,7 +10,6 @@ chrome.jar:
|
||||
|
||||
content/arrow.svg (content/arrow.svg)
|
||||
* content/dbg-browser-actors.js (content/dbg-browser-actors.js)
|
||||
* content/dbg-webapps-actors.js (content/dbg-webapps-actors.js)
|
||||
content/forms.js (content/forms.js)
|
||||
* content/settings.js (content/settings.js)
|
||||
* content/shell.xul (content/shell.xul)
|
||||
|
@ -84,6 +84,11 @@ this.DOMApplicationRegistry = {
|
||||
webapps: { },
|
||||
children: [ ],
|
||||
allAppsLaunchable: false,
|
||||
#ifdef MOZ_OFFICIAL_BRANDING
|
||||
get allowSideloadingCertified() false,
|
||||
#else
|
||||
get allowSideloadingCertified() true,
|
||||
#endif
|
||||
|
||||
init: function() {
|
||||
this.messages = ["Webapps:Install", "Webapps:Uninstall",
|
||||
|
@ -3,5 +3,3 @@ head =
|
||||
tail =
|
||||
|
||||
[test_manifestSanitizer.js]
|
||||
[test_webappsActor.js]
|
||||
run-if = toolkit == "gonk"
|
||||
|
@ -30,6 +30,7 @@
|
||||
[include:toolkit/components/contentprefs/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/components/contentprefs/tests/unit_cps2/xpcshell.ini]
|
||||
[include:toolkit/devtools/server/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/devtools/apps/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/devtools/sourcemap/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/components/passwordmgr/test/unit/xpcshell.ini]
|
||||
# Bug 676989: tests hang on Android
|
||||
|
@ -5,6 +5,7 @@
|
||||
[include:dom/apps/tests/unit/xpcshell.ini]
|
||||
[include:dom/mobilemessage/tests/xpcshell.ini]
|
||||
[include:dom/system/gonk/tests/xpcshell.ini]
|
||||
[include:toolkit/devtools/apps/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/devtools/debugger/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/devtools/sourcemap/tests/unit/xpcshell.ini]
|
||||
[include:toolkit/mozapps/downloads/tests/unit/xpcshell.ini]
|
||||
|
15
toolkit/devtools/apps/Makefile.in
Normal file
15
toolkit/devtools/apps/Makefile.in
Normal file
@ -0,0 +1,15 @@
|
||||
# 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/.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#libs::
|
||||
# $(INSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
|
7
toolkit/devtools/apps/moz.build
Normal file
7
toolkit/devtools/apps/moz.build
Normal file
@ -0,0 +1,7 @@
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
TEST_DIRS += ['tests']
|
||||
|
15
toolkit/devtools/apps/tests/Makefile.in
Normal file
15
toolkit/devtools/apps/tests/Makefile.in
Normal file
@ -0,0 +1,15 @@
|
||||
# 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/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = @relativesrcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
XPCSHELL_TESTS = unit
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
7
toolkit/devtools/apps/tests/moz.build
Normal file
7
toolkit/devtools/apps/tests/moz.build
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
MODULE = 'test_webapps_actor'
|
@ -7,6 +7,11 @@ Components.utils.import("resource://gre/modules/devtools/dbg-client.jsm");
|
||||
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
let gClient, gActor;
|
||||
let gAppId = "actor-test";
|
||||
|
||||
@ -16,7 +21,6 @@ add_test(function testSetup() {
|
||||
// We need to register browser actors to have `listTabs` working
|
||||
// and also have a root actor
|
||||
DebuggerServer.addBrowserActors();
|
||||
DebuggerServer.addActors("chrome://browser/content/dbg-webapps-actors.js");
|
||||
|
||||
// Setup client and actor used in all tests
|
||||
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
@ -61,6 +65,12 @@ add_test(function testInstallPackaged() {
|
||||
// if the installation succeed or failed
|
||||
gClient.addListener("webappsEvent", function (aState, aType, aPacket) {
|
||||
do_check_eq(aType.appId, gAppId);
|
||||
if ("error" in aType) {
|
||||
do_print("Error: " + aType.error);
|
||||
}
|
||||
if ("message" in aType) {
|
||||
do_print("Error message: " + aType.message);
|
||||
}
|
||||
do_check_eq("error" in aType, false);
|
||||
|
||||
run_next_test();
|
||||
@ -175,6 +185,10 @@ function run_test() {
|
||||
// will throw random exception when trying to get profile folder
|
||||
do_get_profile();
|
||||
|
||||
// The webapps dir isn't registered on b2g xpcshell tests,
|
||||
// we have to manually set it to the directory service.
|
||||
do_get_webappsdir();
|
||||
|
||||
// We also need a valid nsIXulAppInfo service as Webapps.jsm is querying it
|
||||
Components.utils.import("resource://testing-common/AppInfo.jsm");
|
||||
updateAppInfo();
|
||||
@ -187,3 +201,39 @@ function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function do_get_webappsdir() {
|
||||
var webappsDir = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
|
||||
webappsDir.append("test_webapps");
|
||||
if (!webappsDir.exists())
|
||||
webappsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
|
||||
var coreAppsDir = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
|
||||
coreAppsDir.append("test_coreapps");
|
||||
if (!coreAppsDir.exists())
|
||||
coreAppsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
|
||||
// Register our own provider for the profile directory.
|
||||
// It will return our special docshell profile directory.
|
||||
var provider = {
|
||||
getFile: function(prop, persistent) {
|
||||
persistent.value = true;
|
||||
if (prop == "webappsDir") {
|
||||
return webappsDir.clone();
|
||||
}
|
||||
else if (prop == "coreAppsDir") {
|
||||
return coreAppsDir.clone();
|
||||
}
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
|
||||
}
|
||||
|
||||
|
5
toolkit/devtools/apps/tests/unit/xpcshell.ini
Normal file
5
toolkit/devtools/apps/tests/unit/xpcshell.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[DEFAULT]
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_webappsActor.js]
|
@ -9,5 +9,6 @@ PARALLEL_DIRS += [
|
||||
'client',
|
||||
'gcli',
|
||||
'sourcemap',
|
||||
'webconsole'
|
||||
'webconsole',
|
||||
'apps'
|
||||
]
|
||||
|
@ -8,12 +8,6 @@ let Cu = Components.utils;
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
|
||||
|
||||
function debug(aMsg) {
|
||||
/*
|
||||
Cc["@mozilla.org/consoleservice;1"]
|
||||
@ -22,17 +16,21 @@ function debug(aMsg) {
|
||||
*/
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
const DIRECTORY_NAME = "webappsDir";
|
||||
#else
|
||||
const DIRECTORY_NAME = "ProfD";
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Creates a WebappsActor. WebappsActor provides remote access to
|
||||
* install apps.
|
||||
*/
|
||||
function WebappsActor(aConnection) { debug("init"); }
|
||||
function WebappsActor(aConnection) {
|
||||
debug("init");
|
||||
// Load actor dependencies lazily as this actor require extra environnement
|
||||
// preparation to work (like have a profile setup in xpcshell tests)
|
||||
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
|
||||
}
|
||||
|
||||
WebappsActor.prototype = {
|
||||
actorPrefix: "webapps",
|
||||
@ -46,7 +44,7 @@ WebappsActor.prototype = {
|
||||
aApp.installState = "installed";
|
||||
aApp.removable = true;
|
||||
aApp.id = aId;
|
||||
aApp.basePath = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true).path;
|
||||
aApp.basePath = reg.getWebAppsBasePath();
|
||||
aApp.localId = (aId in reg.webapps) ? reg.webapps[aId].localId
|
||||
: reg._nextLocalId();
|
||||
|
||||
@ -128,15 +126,14 @@ WebappsActor.prototype = {
|
||||
let appType = self._getAppType(aManifest.type);
|
||||
|
||||
// In production builds, don't allow installation of certified apps.
|
||||
#ifdef MOZ_OFFICIAL_BRANDING
|
||||
if (appType == Ci.nsIPrincipal.APP_STATUS_CERTIFIED) {
|
||||
if (!DOMApplicationRegistry.allowSideloadingCertified &&
|
||||
appType == Ci.nsIPrincipal.APP_STATUS_CERTIFIED) {
|
||||
self._sendError("Installing certified apps is not allowed.", aId);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The destination directory for this app.
|
||||
let installDir = FileUtils.getDir(DIRECTORY_NAME,
|
||||
["webapps", aId], true);
|
||||
let installDir = DOMApplicationRegistry._getAppDir(aId);
|
||||
manFile.moveTo(installDir, "manifest.webapp");
|
||||
|
||||
// Read the origin and manifest url from metadata.json
|
||||
@ -186,8 +183,7 @@ WebappsActor.prototype = {
|
||||
run: function run() {
|
||||
try {
|
||||
// The destination directory for this app.
|
||||
let installDir = FileUtils.getDir(DIRECTORY_NAME,
|
||||
["webapps", aId], true);
|
||||
let installDir = DOMApplicationRegistry._getAppDir(aId);
|
||||
|
||||
// Move application.zip to the destination directory, and
|
||||
// extract manifest.webapp there.
|
||||
@ -210,12 +206,12 @@ WebappsActor.prototype = {
|
||||
let appType = self._getAppType(aManifest.type);
|
||||
|
||||
// In production builds, don't allow installation of certified apps.
|
||||
#ifdef MOZ_OFFICIAL_BRANDING
|
||||
if (appType == Ci.nsIPrincipal.APP_STATUS_CERTIFIED) {
|
||||
if (!DOMApplicationRegistry.allowSideloadingCertified &&
|
||||
appType == Ci.nsIPrincipal.APP_STATUS_CERTIFIED) {
|
||||
self._sendError("Installing certified apps is not allowed.", aId);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
let origin = "app://" + aId;
|
||||
|
||||
// Create a fake app object with the minimum set of properties we need.
|
@ -184,6 +184,7 @@ var DebuggerServer = {
|
||||
this.addActors("resource://gre/modules/devtools/server/actors/profiler.js");
|
||||
|
||||
this.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js");
|
||||
this.addActors("resource://gre/modules/devtools/server/actors/webapps.js");
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user