mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
Bug 1261011 - Remove Inter-App Communication API; r=fabrice
This commit is contained in:
parent
68f5130961
commit
eaba90d427
@ -885,9 +885,6 @@ pref("network.sntp.pools", // Servers separated by ';'.
|
||||
pref("network.sntp.port", 123);
|
||||
pref("network.sntp.timeout", 30); // In seconds.
|
||||
|
||||
// DOM Inter-App Communication API.
|
||||
pref("dom.inter-app-communication-api.enabled", true);
|
||||
|
||||
// Allow ADB to run for this many hours before disabling
|
||||
// (only applies when marionette is disabled)
|
||||
// 0 disables the timer.
|
||||
|
@ -27,10 +27,6 @@ category xpcom-directory-providers b2g-directory-provider @mozilla.org/b2g/direc
|
||||
component {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e} ActivitiesGlue.js
|
||||
contract @mozilla.org/dom/activities/ui-glue;1 {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e}
|
||||
|
||||
# InterAppCommUIGlue.js
|
||||
component {879ee66c-e246-11e3-9910-74d02b97e723} InterAppCommUIGlue.js
|
||||
contract @mozilla.org/dom/apps/inter-app-comm-ui-glue;1 {879ee66c-e246-11e3-9910-74d02b97e723}
|
||||
|
||||
# SystemMessageGlue.js
|
||||
component {2846f034-e614-11e3-93cd-74d02b97e723} SystemMessageGlue.js
|
||||
contract @mozilla.org/dom/messages/system-message-glue;1 {2846f034-e614-11e3-93cd-74d02b97e723}
|
||||
|
@ -1,91 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
"use strict"
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
|
||||
"resource://gre/modules/SystemAppProxy.jsm");
|
||||
|
||||
const DEBUG = false;
|
||||
function debug(aMsg) {
|
||||
dump("-- InterAppCommUIGlue: " + Date.now() + ": " + aMsg + "\n");
|
||||
}
|
||||
|
||||
function InterAppCommUIGlue() {
|
||||
// This matrix is to store the callerID (a random UUID) / deferral binding.
|
||||
// An example of the object literal is shown below:
|
||||
//
|
||||
// {
|
||||
// "callerID1" : deferred1,
|
||||
// "callerID2" : deferred2
|
||||
// }
|
||||
this._deferreds = {};
|
||||
|
||||
// Listen to the result of selected apps from front-end.
|
||||
SystemAppProxy.addEventListener ("mozIACContentEvent", function (aEvent) {
|
||||
let detail = aEvent.detail;
|
||||
if (detail.type != "inter-app-comm-permission") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
debug("mozIACContentEvent: " + JSON.stringify(detail));
|
||||
}
|
||||
|
||||
let callerID = detail.chromeEventID;
|
||||
let deferred = this._deferreds[callerID];
|
||||
if (!deferred) {
|
||||
if (DEBUG) {
|
||||
debug("Error! Cannot find the deferred for callerID: " + callerID);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
delete this._deferreds[callerID];
|
||||
deferred.resolve({ callerID: callerID,
|
||||
keyword: detail.keyword,
|
||||
manifestURL: detail.manifestURL,
|
||||
selectedApps: detail.peers });
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
InterAppCommUIGlue.prototype = {
|
||||
selectApps: function(aCallerID, aPubAppManifestURL, aKeyword, aAppsToSelect) {
|
||||
let deferred = Promise.defer();
|
||||
this._deferreds[aCallerID] = deferred;
|
||||
|
||||
SystemAppProxy._sendCustomEvent("mozIACChromeEvent",
|
||||
{ type: "inter-app-comm-permission",
|
||||
chromeEventID: aCallerID,
|
||||
manifestURL: aPubAppManifestURL,
|
||||
keyword: aKeyword,
|
||||
peers: aAppsToSelect });
|
||||
|
||||
// TODO Bug 897169 Simulate the return of the app-selected result by
|
||||
// the prompt, which always allows the connection. This dummy codes
|
||||
// will be removed when the UX/UI for the prompt is ready.
|
||||
SystemAppProxy._sendCustomEvent("mozIACContentEvent",
|
||||
{ type: "inter-app-comm-permission",
|
||||
chromeEventID: aCallerID,
|
||||
manifestURL: aPubAppManifestURL,
|
||||
keyword: aKeyword,
|
||||
peers: aAppsToSelect });
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
classID: Components.ID("{879ee66c-e246-11e3-9910-74d02b97e723}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIInterAppCommUIGlue])
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppCommUIGlue]);
|
@ -17,7 +17,6 @@ EXTRA_COMPONENTS += [
|
||||
'FilePicker.js',
|
||||
'FxAccountsUIGlue.js',
|
||||
'HelperAppDialog.js',
|
||||
'InterAppCommUIGlue.js',
|
||||
'KillSwitch.js',
|
||||
'MailtoProtocolHandler.js',
|
||||
'MobileIdentityUIGlue.js',
|
||||
|
@ -626,11 +626,6 @@
|
||||
@RESPATH@/components/PushComponents.js
|
||||
#endif
|
||||
|
||||
@RESPATH@/components/InterAppComm.manifest
|
||||
@RESPATH@/components/InterAppCommService.js
|
||||
@RESPATH@/components/InterAppConnection.js
|
||||
@RESPATH@/components/InterAppMessagePort.js
|
||||
|
||||
@RESPATH@/components/nsDOMIdentity.js
|
||||
@RESPATH@/components/nsIDService.js
|
||||
@RESPATH@/components/Identity.manifest
|
||||
@ -910,7 +905,6 @@ bin/libfreebl_32int64_3.so
|
||||
@RESPATH@/components/FilePicker.js
|
||||
@RESPATH@/components/HelperAppDialog.js
|
||||
@RESPATH@/components/DownloadsUI.js
|
||||
@RESPATH@/components/InterAppCommUIGlue.js
|
||||
@RESPATH@/components/SystemMessageGlue.js
|
||||
@RESPATH@/components/B2GAppMigrator.js
|
||||
@RESPATH@/components/B2GPresentationDevicePrompt.js
|
||||
|
@ -535,13 +535,6 @@
|
||||
@RESPATH@/components/TVSimulatorService.js
|
||||
@RESPATH@/components/TVSimulatorService.manifest
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
@RESPATH@/components/InterAppComm.manifest
|
||||
@RESPATH@/components/InterAppCommService.js
|
||||
@RESPATH@/components/InterAppConnection.js
|
||||
@RESPATH@/components/InterAppMessagePort.js
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ACTIVITIES
|
||||
@RESPATH@/components/SystemMessageCache.js
|
||||
@RESPATH@/components/SystemMessageInternal.js
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "InterAppComm.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "AccessCheck.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/* static */ bool
|
||||
InterAppComm::EnabledForScope(JSContext* /* unused */,
|
||||
JS::Handle<JSObject*> /* unused */)
|
||||
{
|
||||
// Disable the constructors if they're disabled by the preference for sure.
|
||||
if (!Preferences::GetBool("dom.inter-app-communication-api.enabled", false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only expose the constructors to the chrome codes for Gecko internal uses.
|
||||
// The content pages shouldn't be aware of the constructors.
|
||||
return nsContentUtils::ThreadsafeIsCallerChrome();
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_apps_InterAppComm_h
|
||||
#define mozilla_dom_apps_InterAppComm_h
|
||||
|
||||
#include "mozilla/dom/MozInterAppMessageEvent.h"
|
||||
|
||||
// Forward declarations.
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class InterAppComm
|
||||
{
|
||||
public:
|
||||
static bool EnabledForScope(JSContext* /* unused */,
|
||||
JS::Handle<JSObject*> /* unused */);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_apps_InterAppComm_h
|
@ -1,16 +0,0 @@
|
||||
component {9dbfa904-0718-11e3-8e77-0721a45514b8} InterAppConnection.js
|
||||
contract @mozilla.org/dom/inter-app-connection;1 {9dbfa904-0718-11e3-8e77-0721a45514b8}
|
||||
|
||||
component {6a77e9e0-0645-11e3-b90b-73bb7c78e06a} InterAppConnection.js
|
||||
contract @mozilla.org/dom/inter-app-connection-request;1 {6a77e9e0-0645-11e3-b90b-73bb7c78e06a}
|
||||
|
||||
component {c66e0f8c-e3cb-11e2-9e85-43ef6244b884} InterAppMessagePort.js
|
||||
contract @mozilla.org/dom/inter-app-message-port;1 {c66e0f8c-e3cb-11e2-9e85-43ef6244b884}
|
||||
|
||||
component {3dd15ce6-e7be-11e2-82bc-77967e7a63e6} InterAppCommService.js
|
||||
contract @mozilla.org/inter-app-communication-service;1 {3dd15ce6-e7be-11e2-82bc-77967e7a63e6}
|
||||
category profile-after-change InterAppCommService @mozilla.org/inter-app-communication-service;1
|
||||
|
||||
component {d7c7a466-f91d-11e2-812a-6fab12ece58e} InterAppConnection.js
|
||||
contract @mozilla.org/dom/system-messages/wrapper/connection;1 {d7c7a466-f91d-11e2-812a-6fab12ece58e}
|
||||
|
@ -1,43 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/InterAppCommService.jsm");
|
||||
|
||||
const DEBUG = false;
|
||||
function debug(aMsg) {
|
||||
dump("-- InterAppCommServiceProxy: " + Date.now() + ": " + aMsg + "\n");
|
||||
}
|
||||
|
||||
function InterAppCommServiceProxy() {
|
||||
}
|
||||
|
||||
InterAppCommServiceProxy.prototype = {
|
||||
registerConnection: function(aKeyword, aHandlerPageURI, aManifestURI,
|
||||
aDescription, aRules) {
|
||||
InterAppCommService.
|
||||
registerConnection(aKeyword, aHandlerPageURI, aManifestURI,
|
||||
aDescription, aRules);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic != "profile-after-change") {
|
||||
if (DEBUG) {
|
||||
debug("Should receive 'profile-after-change' only.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
classID: Components.ID("{3dd15ce6-e7be-11e2-82bc-77967e7a63e6}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIInterAppCommService,
|
||||
Ci.nsIObserver])
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppCommServiceProxy]);
|
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
"@mozilla.org/AppsService;1",
|
||||
"nsIAppsService");
|
||||
|
||||
const DEBUG = false;
|
||||
function debug(aMsg) {
|
||||
dump("-- InterAppConnection: " + Date.now() + ": " + aMsg + "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* MozInterAppConnection implementation.
|
||||
*/
|
||||
|
||||
function InterAppConnection() {
|
||||
if (DEBUG) debug("InterAppConnection()");
|
||||
this.keyword = null;
|
||||
this.publisher = null;
|
||||
this.subscriber = null;
|
||||
};
|
||||
|
||||
InterAppConnection.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
classDescription: "MozInterAppConnection",
|
||||
|
||||
classID: Components.ID("{9dbfa904-0718-11e3-8e77-0721a45514b8}"),
|
||||
|
||||
contractID: "@mozilla.org/dom/inter-app-connection;1",
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
__init: function(aKeyword, aPublisher, aSubscriber) {
|
||||
if (DEBUG) {
|
||||
debug("__init: aKeyword: " + aKeyword +
|
||||
" aPublisher: " + aPublisher + " aSubscriber: " + aSubscriber);
|
||||
}
|
||||
this.keyword = aKeyword;
|
||||
this.publisher = aPublisher;
|
||||
this.subscriber = aSubscriber;
|
||||
},
|
||||
|
||||
// Ci.nsIDOMGlobalPropertyInitializer implementation.
|
||||
init: function(aWindow) {
|
||||
if (DEBUG) debug("init");
|
||||
|
||||
this.initDOMRequestHelper(aWindow, []);
|
||||
let principal = aWindow.document.nodePrincipal;
|
||||
this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
if (DEBUG) debug("cancel");
|
||||
|
||||
cpmm.sendAsyncMessage("InterAppConnection:Cancel",
|
||||
{ keyword: this.keyword,
|
||||
pubAppManifestURL: this.publisher,
|
||||
subAppManifestURL: this.subscriber,
|
||||
manifestURL: this._manifestURL });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* MozInterAppConnectionRequest implementation.
|
||||
*/
|
||||
|
||||
function InterAppConnectionRequest() {
|
||||
if (DEBUG) debug("InterAppConnectionRequest()");
|
||||
this.keyword = null;
|
||||
this.port = null;
|
||||
this.from = null;
|
||||
};
|
||||
|
||||
InterAppConnectionRequest.prototype = {
|
||||
classDescription: "MozInterAppConnectionRequest",
|
||||
|
||||
classID: Components.ID("{6a77e9e0-0645-11e3-b90b-73bb7c78e06a}"),
|
||||
|
||||
contractID: "@mozilla.org/dom/inter-app-connection-request;1",
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
||||
|
||||
__init: function(aKeyword, aPort, aFrom) {
|
||||
if (DEBUG) debug("__init: aKeyword: " + aKeyword + " aPort: " + aPort +
|
||||
" aFrom: " + aFrom);
|
||||
this.keyword = aKeyword;
|
||||
this.port = aPort;
|
||||
this.from = aFrom;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* InterAppConnectionRequestWrapper implementation.
|
||||
*
|
||||
* This implements nsISystemMessagesWrapper.wrapMessage(), which provides a
|
||||
* plugable way to wrap a "connection" type system message.
|
||||
*
|
||||
* Please see SystemMessageManager.js to know how it customizes the wrapper.
|
||||
*/
|
||||
|
||||
function InterAppConnectionRequestWrapper() {
|
||||
if (DEBUG) debug("InterAppConnectionRequestWrapper()");
|
||||
}
|
||||
|
||||
InterAppConnectionRequestWrapper.prototype = {
|
||||
// nsISystemMessagesWrapper implementation.
|
||||
wrapMessage: function(aMessage, aWindow) {
|
||||
if (DEBUG) debug("wrapMessage: " + JSON.stringify(aMessage));
|
||||
|
||||
let port = new aWindow.MozInterAppMessagePort(aMessage.messagePortID);
|
||||
let connectionRequest =
|
||||
new aWindow.MozInterAppConnectionRequest(aMessage.keyword, port,
|
||||
aMessage.pubPageURL);
|
||||
|
||||
return connectionRequest;
|
||||
},
|
||||
|
||||
classDescription: "InterAppConnectionRequestWrapper",
|
||||
|
||||
classID: Components.ID("{d7c7a466-f91d-11e2-812a-6fab12ece58e}"),
|
||||
|
||||
contractID: "@mozilla.org/dom/system-messages/wrapper/connection;1",
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesWrapper])
|
||||
}
|
||||
|
||||
|
||||
this.NSGetFactory =
|
||||
XPCOMUtils.generateNSGetFactory([InterAppConnection,
|
||||
InterAppConnectionRequest,
|
||||
InterAppConnectionRequestWrapper]);
|
@ -1,280 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// TODO Bug 907060 Per off-line discussion, after the MessagePort is done
|
||||
// at Bug 643325, we will start to refactorize the common logic of both
|
||||
// Inter-App Communication and Shared Worker. For now, we hope to design an
|
||||
// MozInterAppMessagePort to meet the timeline, which still follows exactly
|
||||
// the same interface and semantic as the MessagePort is. In the future,
|
||||
// we can then align it back to MessagePort with backward compatibility.
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
|
||||
const DEBUG = false;
|
||||
function debug(aMsg) {
|
||||
dump("-- InterAppMessagePort: " + Date.now() + ": " + aMsg + "\n");
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
"@mozilla.org/AppsService;1",
|
||||
"nsIAppsService");
|
||||
|
||||
const kMessages = ["InterAppMessagePort:OnClose",
|
||||
"InterAppMessagePort:OnMessage",
|
||||
"InterAppMessagePort:Shutdown"];
|
||||
|
||||
function InterAppMessagePort() {
|
||||
if (DEBUG) debug("InterAppMessagePort()");
|
||||
};
|
||||
|
||||
InterAppMessagePort.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
classDescription: "MozInterAppMessagePort",
|
||||
|
||||
classID: Components.ID("{c66e0f8c-e3cb-11e2-9e85-43ef6244b884}"),
|
||||
|
||||
contractID: "@mozilla.org/dom/inter-app-message-port;1",
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
// Ci.nsIDOMGlobalPropertyInitializer implementation.
|
||||
init: function(aWindow) {
|
||||
if (DEBUG) debug("Calling init().");
|
||||
|
||||
this.initDOMRequestHelper(aWindow, kMessages);
|
||||
|
||||
let principal = aWindow.document.nodePrincipal;
|
||||
this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
|
||||
this._pageURL = principal.URI.specIgnoringRef;
|
||||
|
||||
// Remove query string.
|
||||
this._pageURL = this._pageURL.split("?")[0];
|
||||
|
||||
this._started = false;
|
||||
this._closed = false;
|
||||
this._messageQueue = [];
|
||||
this._deferredClose = false;
|
||||
},
|
||||
|
||||
// WebIDL implementation for constructor.
|
||||
__init: function(aMessagePortID) {
|
||||
if (DEBUG) {
|
||||
debug("Calling __init(): aMessagePortID: " + aMessagePortID);
|
||||
}
|
||||
|
||||
this._messagePortID = aMessagePortID;
|
||||
|
||||
cpmm.sendAsyncMessage("InterAppMessagePort:Register",
|
||||
{ messagePortID: this._messagePortID,
|
||||
manifestURL: this._manifestURL,
|
||||
pageURL: this._pageURL });
|
||||
},
|
||||
|
||||
// DOMRequestIpcHelper implementation.
|
||||
uninit: function() {
|
||||
if (DEBUG) debug("Calling uninit().");
|
||||
|
||||
// When the message port is uninitialized, we need to disentangle the
|
||||
// coupling ports, as if the close() method had been called.
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Don't need to close again.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
postMessage: function(aMessage) {
|
||||
if (DEBUG) debug("Calling postMessage().");
|
||||
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Cannot post message.");
|
||||
return;
|
||||
}
|
||||
|
||||
cpmm.sendAsyncMessage("InterAppMessagePort:PostMessage",
|
||||
{ messagePortID: this._messagePortID,
|
||||
manifestURL: this._manifestURL,
|
||||
message: aMessage });
|
||||
},
|
||||
|
||||
start: function() {
|
||||
// Begin dispatching messages received on the port.
|
||||
if (DEBUG) debug("Calling start().");
|
||||
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Cannot call start().");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._started) {
|
||||
if (DEBUG) debug("start() has been called. Don't need to start again.");
|
||||
return;
|
||||
}
|
||||
|
||||
// When a port's port message queue is enabled, the event loop must use it
|
||||
// as one of its task sources.
|
||||
this._started = true;
|
||||
while (this._messageQueue.length) {
|
||||
let message = this._messageQueue.shift();
|
||||
this._dispatchMessage(message);
|
||||
}
|
||||
|
||||
if (this._deferredClose) {
|
||||
this._dispatchClose();
|
||||
}
|
||||
},
|
||||
|
||||
close: function() {
|
||||
// Disconnecting the port, so that it is no longer active.
|
||||
if (DEBUG) debug("Calling close().");
|
||||
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Don't need to close again.");
|
||||
return;
|
||||
}
|
||||
|
||||
this._closed = true;
|
||||
this._deferredClose = false;
|
||||
this._messageQueue.length = 0;
|
||||
|
||||
// When this method called on a local port that is entangled with another
|
||||
// port, must cause the user agent to disentangle the coupling ports.
|
||||
cpmm.sendAsyncMessage("InterAppMessagePort:Unregister",
|
||||
{ messagePortID: this._messagePortID,
|
||||
manifestURL: this._manifestURL });
|
||||
|
||||
this.removeMessageListeners(kMessages);
|
||||
|
||||
this._dispatchClose();
|
||||
},
|
||||
|
||||
get onmessage() {
|
||||
if (DEBUG) debug("Getting onmessage handler.");
|
||||
|
||||
return this.__DOM_IMPL__.getEventHandler("onmessage");
|
||||
},
|
||||
|
||||
set onmessage(aHandler) {
|
||||
if (DEBUG) debug("Setting onmessage handler.");
|
||||
|
||||
this.__DOM_IMPL__.setEventHandler("onmessage", aHandler);
|
||||
|
||||
// The first time a MessagePort object's onmessage IDL attribute is set,
|
||||
// the port's message queue must be enabled, as if the start() method had
|
||||
// been called.
|
||||
if (this._started) {
|
||||
if (DEBUG) debug("start() has been called. Don't need to start again.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.start();
|
||||
},
|
||||
|
||||
get onclose() {
|
||||
if (DEBUG) debug("Getting onclose handler.");
|
||||
return this.__DOM_IMPL__.getEventHandler("onclose");
|
||||
},
|
||||
|
||||
set onclose(aHandler) {
|
||||
if (DEBUG) debug("Setting onclose handler.");
|
||||
this.__DOM_IMPL__.setEventHandler("onclose", aHandler);
|
||||
},
|
||||
|
||||
_dispatchMessage: function _dispatchMessage(aMessage) {
|
||||
let wrappedMessage = Cu.cloneInto(aMessage, this._window);
|
||||
if (DEBUG) {
|
||||
debug("_dispatchMessage: wrappedMessage: " +
|
||||
JSON.stringify(wrappedMessage));
|
||||
}
|
||||
|
||||
let event = new this._window
|
||||
.MozInterAppMessageEvent("message",
|
||||
{ data: wrappedMessage });
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
},
|
||||
|
||||
_dispatchClose() {
|
||||
if (DEBUG) debug("_dispatchClose");
|
||||
let event = new this._window.Event("close", {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
if (DEBUG) debug("receiveMessage: name: " + aMessage.name);
|
||||
|
||||
let message = aMessage.json;
|
||||
if (message.manifestURL != this._manifestURL ||
|
||||
message.pageURL != this._pageURL ||
|
||||
message.messagePortID != this._messagePortID) {
|
||||
if (DEBUG) debug("The message doesn't belong to this page. Returning. " +
|
||||
uneval(message));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "InterAppMessagePort:OnMessage":
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Drop the message.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._started) {
|
||||
if (DEBUG) debug("Not yet called start(). Queue up the message.");
|
||||
this._messageQueue.push(message.message);
|
||||
return;
|
||||
}
|
||||
|
||||
this._dispatchMessage(message.message);
|
||||
break;
|
||||
|
||||
case "InterAppMessagePort:OnClose":
|
||||
if (this._closed) {
|
||||
if (DEBUG) debug("close() has been called. Drop the message.");
|
||||
return;
|
||||
}
|
||||
|
||||
// It is possible that one side of the port posts messages and calls
|
||||
// close() before calling start() or setting the onmessage handler. In
|
||||
// that case we need to queue the messages and defer the onclose event
|
||||
// until the messages are delivered to the other side of the port.
|
||||
if (!this._started) {
|
||||
if (DEBUG) debug("Not yet called start(). Defer close notification.");
|
||||
this._deferredClose = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this._dispatchClose();
|
||||
break;
|
||||
|
||||
case "InterAppMessagePort:Shutdown":
|
||||
this.close();
|
||||
break;
|
||||
|
||||
default:
|
||||
dump("WARNING - Invalid InterAppMessagePort message type " +
|
||||
aMessage.name + "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppMessagePort]);
|
||||
|
@ -609,35 +609,6 @@ WebappsApplication.prototype = {
|
||||
return request;
|
||||
},
|
||||
|
||||
connect: function(aKeyword, aRules) {
|
||||
this.addMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
return this.createPromiseWithId((aResolverId) => {
|
||||
let from = this._window.location.origin + this._window.location.pathname;
|
||||
cpmm.sendAsyncMessage("Webapps:Connect", {
|
||||
keyword: aKeyword,
|
||||
rules: aRules,
|
||||
manifestURL: this.manifestURL,
|
||||
pubPageURL: from,
|
||||
outerWindowID: this._id,
|
||||
topWindowID: this._topId,
|
||||
requestID: aResolverId
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getConnections: function() {
|
||||
this.addMessageListeners("Webapps:GetConnections:Return:OK");
|
||||
return this.createPromiseWithId((aResolverId) => {
|
||||
cpmm.sendAsyncMessage("Webapps:GetConnections", {
|
||||
manifestURL: this.manifestURL,
|
||||
outerWindowID: this._id,
|
||||
topWindowID: this._topId,
|
||||
requestID: aResolverId
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
addReceipt: function(receipt) {
|
||||
let request = this.createRequest();
|
||||
|
||||
@ -745,10 +716,7 @@ WebappsApplication.prototype = {
|
||||
receiveMessage: function(aMessage) {
|
||||
let msg = aMessage.json;
|
||||
let req;
|
||||
if (aMessage.name == "Webapps:Connect:Return:OK" ||
|
||||
aMessage.name == "Webapps:Connect:Return:KO" ||
|
||||
aMessage.name == "Webapps:GetConnections:Return:OK" ||
|
||||
aMessage.name == "Webapps:Export:Return" ||
|
||||
if (aMessage.name == "Webapps:Export:Return" ||
|
||||
aMessage.name == "Webapps:GetLocalizedValue:Return") {
|
||||
req = this.takePromiseResolver(msg.requestID);
|
||||
} else {
|
||||
@ -774,33 +742,6 @@ WebappsApplication.prototype = {
|
||||
this.removeMessageListeners(aMessage.name);
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:Connect:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
let messagePorts = new this._window.Array();
|
||||
msg.messagePortIDs.forEach((aPortID) => {
|
||||
let port = new this._window.MozInterAppMessagePort(aPortID);
|
||||
messagePorts.push(port);
|
||||
});
|
||||
req.resolve(messagePorts);
|
||||
break;
|
||||
case "Webapps:Connect:Return:KO":
|
||||
this.removeMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
req.reject("No connections registered");
|
||||
break;
|
||||
case "Webapps:GetConnections:Return:OK":
|
||||
this.removeMessageListeners(aMessage.name);
|
||||
let connections = new this._window.Array();
|
||||
msg.connections.forEach((aConnection) => {
|
||||
let connection =
|
||||
new this._window.MozInterAppConnection(aConnection.keyword,
|
||||
aConnection.pubAppManifestURL,
|
||||
aConnection.subAppManifestURL);
|
||||
connections.push(connection);
|
||||
});
|
||||
req.resolve(connections);
|
||||
break;
|
||||
case "Webapps:AddReceipt:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:AddReceipt:Return:OK",
|
||||
"Webapps:AddReceipt:Return:KO"]);
|
||||
|
@ -142,11 +142,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "interAppCommService", function() {
|
||||
return Cc["@mozilla.org/inter-app-communication-service;1"]
|
||||
.getService(Ci.nsIInterAppCommService);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
"@mozilla.org/AppsService;1",
|
||||
"nsIAppsService");
|
||||
@ -866,69 +861,6 @@ this.DOMApplicationRegistry = {
|
||||
});
|
||||
},
|
||||
|
||||
// |aEntryPoint| is either the entry_point name or the null in which case we
|
||||
// use the root of the manifest.
|
||||
//
|
||||
// TODO Bug 908094 Refine _registerInterAppConnectionsForEntryPoint(...).
|
||||
_registerInterAppConnectionsForEntryPoint: function(aManifest, aApp,
|
||||
aEntryPoint) {
|
||||
let root = aManifest;
|
||||
if (aEntryPoint && aManifest.entry_points[aEntryPoint]) {
|
||||
root = aManifest.entry_points[aEntryPoint];
|
||||
}
|
||||
|
||||
let connections = root.connections;
|
||||
if (!connections) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((typeof connections) !== "object") {
|
||||
debug("|connections| is not an object. Skipping: " + connections);
|
||||
return;
|
||||
}
|
||||
|
||||
let manifest = new ManifestHelper(aManifest, aApp.origin, aApp.manifestURL);
|
||||
let launchPathURI = Services.io.newURI(manifest.fullLaunchPath(aEntryPoint),
|
||||
null, null);
|
||||
let manifestURI = Services.io.newURI(aApp.manifestURL, null, null);
|
||||
|
||||
for (let keyword in connections) {
|
||||
let connection = connections[keyword];
|
||||
|
||||
// Resolve the handler path from origin. If |handler_path| is absent,
|
||||
// use |launch_path| as default.
|
||||
let fullHandlerPath;
|
||||
let handlerPath = connection.handler_path;
|
||||
if (handlerPath) {
|
||||
try {
|
||||
fullHandlerPath = manifest.resolveURL(handlerPath);
|
||||
} catch(e) {
|
||||
debug("Connection's handler path is invalid. Skipping: keyword: " +
|
||||
keyword + " handler_path: " + handlerPath);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let handlerPageURI = fullHandlerPath
|
||||
? Services.io.newURI(fullHandlerPath, null, null)
|
||||
: launchPathURI;
|
||||
|
||||
if (SystemMessagePermissionsChecker
|
||||
.isSystemMessagePermittedToRegister("connection",
|
||||
aApp.manifestURL,
|
||||
aApp.origin,
|
||||
aManifest)) {
|
||||
msgmgr.registerPage("connection", handlerPageURI, manifestURI);
|
||||
}
|
||||
|
||||
interAppCommService.
|
||||
registerConnection(keyword,
|
||||
handlerPageURI,
|
||||
manifestURI,
|
||||
connection.description,
|
||||
connection.rules);
|
||||
}
|
||||
},
|
||||
|
||||
_registerSystemMessages: function(aManifest, aApp) {
|
||||
this._registerSystemMessagesForEntryPoint(aManifest, aApp, null);
|
||||
|
||||
@ -941,19 +873,6 @@ this.DOMApplicationRegistry = {
|
||||
}
|
||||
},
|
||||
|
||||
_registerInterAppConnections: function(aManifest, aApp) {
|
||||
this._registerInterAppConnectionsForEntryPoint(aManifest, aApp, null);
|
||||
|
||||
if (!aManifest.entry_points) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let entryPoint in aManifest.entry_points) {
|
||||
this._registerInterAppConnectionsForEntryPoint(aManifest, aApp,
|
||||
entryPoint);
|
||||
}
|
||||
},
|
||||
|
||||
// |aEntryPoint| is either the entry_point name or the null in which case we
|
||||
// use the root of the manifest.
|
||||
_createActivitiesToRegister: function(aManifest, aApp, aEntryPoint,
|
||||
@ -1123,7 +1042,6 @@ this.DOMApplicationRegistry = {
|
||||
}
|
||||
app.kind = this.appKind(app, aResult.manifest);
|
||||
this._registerSystemMessages(manifest, app);
|
||||
this._registerInterAppConnections(manifest, app);
|
||||
appsToRegister.push({ manifest: manifest, app: app });
|
||||
UserCustomizations.register(app);
|
||||
Langpacks.register(app, manifest);
|
||||
@ -2005,7 +1923,6 @@ this.DOMApplicationRegistry = {
|
||||
}
|
||||
this._registerSystemMessages(aNewManifest, aApp);
|
||||
this._registerActivities(aNewManifest, aApp, true);
|
||||
this._registerInterAppConnections(aNewManifest, aApp);
|
||||
} else {
|
||||
// Nothing else to do but notifying we're ready.
|
||||
this.notifyAppsRegistryReady();
|
||||
|
@ -9,25 +9,12 @@ XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
||||
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += [
|
||||
'tests/b2g_chrome.ini',
|
||||
'tests/chrome.ini'
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'InterAppComm.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'InterAppComm.cpp',
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'AppsService.js',
|
||||
'AppsService.manifest',
|
||||
'InterAppComm.manifest',
|
||||
'InterAppCommService.js',
|
||||
'InterAppConnection.js',
|
||||
'InterAppMessagePort.js',
|
||||
'Webapps.js',
|
||||
'Webapps.manifest',
|
||||
]
|
||||
@ -48,17 +35,7 @@ EXTRA_JS_MODULES += [
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
'AppsUtils.jsm',
|
||||
'ImportExport.jsm',
|
||||
'InterAppCommService.jsm',
|
||||
'OperatorApps.jsm',
|
||||
'ScriptPreloader.jsm',
|
||||
'Webapps.jsm',
|
||||
]
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wshadow']
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/js/xpconnect/wrappers',
|
||||
]
|
||||
|
@ -1,6 +0,0 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp != 'b2g'
|
||||
support-files =
|
||||
iac/*
|
||||
|
||||
[test_iac.html]
|
@ -1,3 +0,0 @@
|
||||
subscriber.list and publisher.zip contain the lists of files that are part of each app.
|
||||
|
||||
To update the packages of both apps when changing one of those files listed on *.list, run makezips.sh.
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm publisher/publisher.zip
|
||||
rm subscriber/subscriber.zip
|
||||
cd publisher
|
||||
zip publisher.zip `cat publisher.list`
|
||||
cd ../subscriber
|
||||
zip subscriber.zip `cat subscriber.list`
|
||||
cd ..
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Publisher app for IAC API</title>
|
||||
<script src="test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "IAC publisher app",
|
||||
"launch_path": "/index.html",
|
||||
"type": "certified"
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
manifest.webapp
|
||||
index.html
|
||||
test.js
|
Binary file not shown.
@ -1,46 +0,0 @@
|
||||
function ok(aCondition, aMessage) {
|
||||
if (aCondition) {
|
||||
alert("OK: " + aMessage);
|
||||
} else {
|
||||
alert("KO: " + aMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function ready() {
|
||||
alert("READY");
|
||||
}
|
||||
|
||||
let _port = null;
|
||||
let responseReceived = false;
|
||||
|
||||
function onmessage(message) {
|
||||
responseReceived = (message.data == "response");
|
||||
ok(responseReceived, "response received");
|
||||
}
|
||||
|
||||
function onclose() {
|
||||
ok(true, "onclose received");
|
||||
if (responseReceived) {
|
||||
ready();
|
||||
}
|
||||
}
|
||||
|
||||
(function makeConnection() {
|
||||
ok(true, "Connecting");
|
||||
navigator.mozApps.getSelf().onsuccess = event => {
|
||||
ok(true, "Got self");
|
||||
let app = event.target.result;
|
||||
app.connect("a-connection").then(ports => {
|
||||
if (!ports || !ports.length) {
|
||||
return ok(false, "No ports");
|
||||
}
|
||||
ok(true, "Got port");
|
||||
_port = ports[0];
|
||||
_port.onmessage = onmessage;
|
||||
_port.onclose = onclose;
|
||||
_port.postMessage('something');
|
||||
}).catch(error => {
|
||||
ok(false, "Unexpected " + error);
|
||||
});
|
||||
};
|
||||
})();
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "IAC publisher app",
|
||||
"launch_path": "/index.html",
|
||||
"package_path": "publisher.zip",
|
||||
"type": "certified"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Content-Type: application/x-web-app-manifest+json
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Subscriber app for IAC API</title>
|
||||
<script src="test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "IAC subscriber app",
|
||||
"launch_path": "/index.html",
|
||||
"type": "certified",
|
||||
"connections": {
|
||||
"a-connection": {
|
||||
"description": "A connection",
|
||||
"rules": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
manifest.webapp
|
||||
index.html
|
||||
test.js
|
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
let port;
|
||||
navigator.mozSetMessageHandler('connection', request => {
|
||||
port = request.port;
|
||||
port.onmessage = () => {
|
||||
port.postMessage('response');
|
||||
port.close();
|
||||
};
|
||||
});
|
||||
alert('READY');
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "IAC subscriber app",
|
||||
"launch_path": "/index.html",
|
||||
"type": "certified",
|
||||
"package_path": "subscriber.zip",
|
||||
"connections": {
|
||||
"a-connection": {
|
||||
"description": "A connection",
|
||||
"rules": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
Content-Type: application/x-web-app-manifest+json
|
@ -1,236 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=915880
|
||||
-->
|
||||
<head>
|
||||
<title>Test for IAC API</title>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="http://test/chrome/dom/activities/tests/mochi/common.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={915880}">Mozilla Bug {915880}</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript;version=1.7">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const gURL = "http://test/chrome/dom/apps/tests/iac/";
|
||||
const IAC_UI_GLUE_CID =
|
||||
Components.ID("{384afeee-f1d2-4819-9d2e-9b62f6b0e382}");
|
||||
|
||||
function registerComponent(aObject, aDescription, aContract, aCid) {
|
||||
info("Registering " + aCid);
|
||||
|
||||
var componentManager =
|
||||
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
componentManager.registerFactory(aCid, aDescription, aContract, aObject);
|
||||
|
||||
// Keep the id on the object so we can unregister later.
|
||||
aObject.cid = aCid;
|
||||
}
|
||||
|
||||
function unregisterComponent(aObject) {
|
||||
info("Unregistering " + aObject.cid);
|
||||
var componentManager =
|
||||
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
componentManager.unregisterFactory(aObject.cid, aObject);
|
||||
}
|
||||
|
||||
let InterAppCommUIGlue = {
|
||||
// nsISupports implementation.
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsISupports) ||
|
||||
iid.equals(Ci.nsIFactory) ||
|
||||
iid.equals(Ci.nsIInterAppCommUIGlue)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// nsIFactory implementation.
|
||||
createInstance: function(outer, iid) {
|
||||
return this.QueryInterface(iid);
|
||||
},
|
||||
|
||||
// nsIInterAppCommUIGlue implementation
|
||||
selectApps(aCallerID, aPubAppManifestURL, aKeyword, aAppsToSelect) {
|
||||
return Promise.resolve({
|
||||
callerID: aCallerID,
|
||||
keyword: aKeyword,
|
||||
manifestURL: aPubAppManifestURL,
|
||||
selectedApps: aAppsToSelect
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
registerComponent(InterAppCommUIGlue,
|
||||
"InterAppComm UI Glue",
|
||||
"@mozilla.org/dom/apps/inter-app-comm-ui-glue;1",
|
||||
IAC_UI_GLUE_CID);
|
||||
|
||||
function finish() {
|
||||
unregisterComponent(InterAppCommUIGlue);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function cbError(aEvent) {
|
||||
ok(false, "Error callback invoked " +
|
||||
aEvent.target.error.name + " " + aEvent.target.error.message);
|
||||
finish();
|
||||
}
|
||||
|
||||
let subscriber = null;
|
||||
let publisher = null;
|
||||
|
||||
function installApp(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = navigator.mozApps.installPackage(gURL + path);
|
||||
request.onerror = () => {
|
||||
ok(false, request.error.name);
|
||||
reject();
|
||||
};
|
||||
request.onsuccess = () => {
|
||||
let app = request.result;
|
||||
ok(app, "App is not null");
|
||||
if (app.installState == "installed") {
|
||||
return resolve(app);
|
||||
}
|
||||
app.ondownloadapplied = () => {
|
||||
resolve(app);
|
||||
};
|
||||
app.ondownloaderror = () => {
|
||||
ok(false, "Unexpected download error");
|
||||
reject();
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function launchApp(app) {
|
||||
if (!app) {
|
||||
ok(false, "No app to launch");
|
||||
return Promise.reject();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozapp", app.manifestURL);
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", e => {
|
||||
let message = e.detail.message;
|
||||
if (/OK/.exec(message)) {
|
||||
ok(true, "Message from app: " + message);
|
||||
} else if (/KO/.exec(message)) {
|
||||
ok(false, "Message from app: " + message);
|
||||
} else if (/READY/.exec(message)) {
|
||||
ok(true, "Message from app: " + message);
|
||||
resolve();
|
||||
} else {
|
||||
ok(false, "Unexpected message received: " + message);
|
||||
}
|
||||
}, false);
|
||||
let domParent = document.getElementById("container");
|
||||
domParent.appendChild(iframe);
|
||||
SpecialPowers.wrap(iframe.contentWindow).location =
|
||||
app.origin + app.manifest.launch_path;
|
||||
});
|
||||
}
|
||||
|
||||
const tests = [() => {
|
||||
info("Test start");
|
||||
SpecialPowers.autoConfirmAppInstall(() => {
|
||||
SpecialPowers.autoConfirmAppUninstall(next);
|
||||
});
|
||||
}, () => {
|
||||
info("Installing subscriber app");
|
||||
installApp("subscriber/update.webapp").then(app => {
|
||||
subscriber = app;
|
||||
next();
|
||||
}).catch(() => {
|
||||
ok(false, "Unable to install app");
|
||||
finish();
|
||||
});
|
||||
}, () => {
|
||||
info("Launching " + subscriber.manifest.name);
|
||||
launchApp(subscriber).then(next);
|
||||
}, () => {
|
||||
info("Installing publisher app");
|
||||
installApp("publisher/update.webapp").then(app => {
|
||||
publisher = app;
|
||||
next();
|
||||
}).catch(() => {
|
||||
ok(false, "Unable to install app");
|
||||
finish();
|
||||
});
|
||||
}, () => {
|
||||
info("Launching " + publisher.manifest.name);
|
||||
launchApp(publisher).then(next);
|
||||
}, () => {
|
||||
navigator.mozApps.mgmt.onuninstall = event => {
|
||||
let app = event.application;
|
||||
next();
|
||||
};
|
||||
let request = navigator.mozApps.mgmt.uninstall(subscriber);
|
||||
request.onerror = cbError;
|
||||
}, () => {
|
||||
navigator.mozApps.mgmt.onuninstall = event => {
|
||||
let app = event.application;
|
||||
next();
|
||||
};
|
||||
let request = navigator.mozApps.mgmt.uninstall(publisher);
|
||||
request.onerror = cbError;
|
||||
}];
|
||||
|
||||
const next = () => {
|
||||
let step = tests.shift();
|
||||
if (!step) {
|
||||
return finish();
|
||||
}
|
||||
try {
|
||||
step();
|
||||
} catch(e) {
|
||||
ok(false, "Test threw: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
SpecialPowers.pushPermissions([{
|
||||
"type": "webapps-manage",
|
||||
"allow": 1,
|
||||
"context": document
|
||||
}, {
|
||||
"type": "browser",
|
||||
"allow": 1,
|
||||
"context": document
|
||||
}, {
|
||||
"type": "embed-apps",
|
||||
"allow": 1,
|
||||
"context": document
|
||||
}], () => {
|
||||
// IAC is only allowed for certified apps. We use dev mode to
|
||||
// skip the security checks.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["dom.mozApps.debug", true],
|
||||
["dom.apps.developer_mode", true],
|
||||
["dom.mozBrowserFramesEnabled", true],
|
||||
["dom.sysmsg.enabled", true]
|
||||
]
|
||||
}, next);
|
||||
});
|
||||
|
||||
</script>
|
||||
<div id="container"></div>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@ head = head.js
|
||||
tail = tail.js
|
||||
|
||||
[test_has_widget_criterion.js]
|
||||
[test_inter_app_comm_service.js]
|
||||
[test_manifestSanitizer.js]
|
||||
[test_manifestHelper.js]
|
||||
[test_moziapplication.js]
|
||||
|
@ -8,8 +8,6 @@ XPIDL_SOURCES += [
|
||||
'mozIApplication.idl',
|
||||
'mozIApplicationClearPrivateDataParams.idl',
|
||||
'nsIAppsService.idl',
|
||||
'nsIInterAppCommService.idl',
|
||||
'nsIInterAppCommUIGlue.idl'
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_apps'
|
||||
|
@ -1,37 +0,0 @@
|
||||
/* 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 "domstubs.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* Implemented by the contract id @mozilla.org/inter-app-communication-service;1
|
||||
*
|
||||
* This interface contains helpers for Inter-App Communication API [1] related
|
||||
* purposes. A singleton service of this interface will be instantiated during
|
||||
* the system boot-up, which plays the role of the central service receiving
|
||||
* messages from and interacting with the content processes.
|
||||
*
|
||||
* [1] https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal
|
||||
*/
|
||||
[scriptable, uuid(b3d711a4-c6a4-11e3-8fd3-738e7fbcb6d6)]
|
||||
interface nsIInterAppCommService : nsISupports
|
||||
{
|
||||
/*
|
||||
* Registration of a page that wants to be connected to other apps through
|
||||
* the Inter-App Communication API.
|
||||
*
|
||||
* @param keyword The connection's keyword.
|
||||
* @param handlerPageURI The URI of the handler's page.
|
||||
* @param manifestURI The webapp's manifest URI.
|
||||
* @param description The connection's description.
|
||||
* @param rules The connection's rules.
|
||||
*/
|
||||
void registerConnection(in DOMString keyword,
|
||||
in nsIURI handlerPageURI,
|
||||
in nsIURI manifestURI,
|
||||
in DOMString description,
|
||||
in jsval rules);
|
||||
};
|
@ -1,29 +0,0 @@
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* To be implemented by @mozilla.org/dom/apps/inter-app-comm-ui-glue;1
|
||||
*/
|
||||
[scriptable, uuid(634555c6-e246-11e3-b427-74d02b97e723)]
|
||||
interface nsIInterAppCommUIGlue : nsISupports
|
||||
{
|
||||
/**
|
||||
* This method is to notify the prompt to let the user select some of the
|
||||
* IAC-eligible apps.
|
||||
*
|
||||
* @param callerID The generated UUID to identify the caller and
|
||||
* should be unique for each call.
|
||||
* @param pubAppManifestURL The manifest URL of the publisher.
|
||||
* @param keyword The IAC keyword.
|
||||
* @param appsToSelect The IAC-eligible apps for selection.
|
||||
*
|
||||
* Returns a promise.
|
||||
*/
|
||||
jsval selectApps(in AString callerID,
|
||||
in AString pubAppManifestURL,
|
||||
in AString keyword,
|
||||
in jsval appsToSelect);
|
||||
};
|
@ -58,7 +58,6 @@ this.SystemMessagePermissionsTable = {
|
||||
"cellbroadcast-received": {
|
||||
"cellbroadcast": []
|
||||
},
|
||||
"connection": { },
|
||||
"captive-portal": {
|
||||
"wifi-manage": []
|
||||
},
|
||||
|
@ -88,16 +88,6 @@ interface DOMApplication : EventTarget {
|
||||
DOMRequest clearBrowserData();
|
||||
DOMRequest checkForUpdate();
|
||||
|
||||
/**
|
||||
* Inter-App Communication APIs.
|
||||
*
|
||||
* https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal
|
||||
*
|
||||
*/
|
||||
Promise<MozInterAppConnection> connect(DOMString keyword, optional any rules);
|
||||
|
||||
Promise<sequence<MozInterAppMessagePort>> getConnections();
|
||||
|
||||
// Receipts handling functions.
|
||||
DOMRequest addReceipt(optional DOMString receipt);
|
||||
DOMRequest removeReceipt(optional DOMString receipt);
|
||||
|
@ -1,15 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||
Constructor(DOMString keyword, DOMString publisher, DOMString subsriber),
|
||||
JSImplementation="@mozilla.org/dom/inter-app-connection;1"]
|
||||
interface MozInterAppConnection {
|
||||
readonly attribute DOMString keyword;
|
||||
readonly attribute DOMString publisher;
|
||||
readonly attribute DOMString subscriber;
|
||||
|
||||
void cancel();
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||
Constructor(DOMString keyword, MozInterAppMessagePort port,
|
||||
DOMString from),
|
||||
JSImplementation="@mozilla.org/dom/inter-app-connection-request;1"]
|
||||
interface MozInterAppConnectionRequest {
|
||||
readonly attribute DOMString keyword;
|
||||
|
||||
readonly attribute MozInterAppMessagePort port;
|
||||
|
||||
readonly attribute DOMString from;
|
||||
};
|
@ -1,25 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// TODO Bug 907060 Per off-line discussion, after the MessagePort is done
|
||||
// at Bug 643325, we will start to refactorize the common logic of both
|
||||
// Inter-App Communication and Shared Worker. For now, we hope to design an
|
||||
// MozInterAppMessagePort to meet the timeline, which still follows exactly
|
||||
// the same interface and semantic as the MessagePort is. In the future,
|
||||
// we can then align it back to MessagePort with backward compatibility.
|
||||
|
||||
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||
Constructor(DOMString messagePortID),
|
||||
JSImplementation="@mozilla.org/dom/inter-app-message-port;1"]
|
||||
interface MozInterAppMessagePort : EventTarget {
|
||||
void postMessage(any message);
|
||||
|
||||
void start();
|
||||
|
||||
void close();
|
||||
|
||||
attribute EventHandler onmessage;
|
||||
attribute EventHandler onclose;
|
||||
};
|
@ -1,15 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
dictionary MozInterAppMessageEventInit : EventInit {
|
||||
any data = null;
|
||||
};
|
||||
|
||||
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||
Constructor(DOMString type,
|
||||
optional MozInterAppMessageEventInit eventInitDict)]
|
||||
interface MozInterAppMessageEvent : Event {
|
||||
readonly attribute any data;
|
||||
};
|
@ -276,9 +276,6 @@ WEBIDL_FILES = [
|
||||
'InputPort.webidl',
|
||||
'InputPortManager.webidl',
|
||||
'InspectorUtils.webidl',
|
||||
'InterAppConnection.webidl',
|
||||
'InterAppConnectionRequest.webidl',
|
||||
'InterAppMessagePort.webidl',
|
||||
'IterableIterator.webidl',
|
||||
'KeyAlgorithm.webidl',
|
||||
'KeyboardEvent.webidl',
|
||||
@ -795,7 +792,6 @@ GENERATED_EVENTS_WEBIDL_FILES = [
|
||||
'MozClirModeEvent.webidl',
|
||||
'MozContactChangeEvent.webidl',
|
||||
'MozEmergencyCbModeEvent.webidl',
|
||||
'MozInterAppMessageEvent.webidl',
|
||||
'MozMessageDeletedEvent.webidl',
|
||||
'MozMmsEvent.webidl',
|
||||
'MozOtaStatusEvent.webidl',
|
||||
|
@ -4946,9 +4946,6 @@ pref("dom.voicemail.enabled", false);
|
||||
// parameter omitted.
|
||||
pref("dom.voicemail.defaultServiceId", 0);
|
||||
|
||||
// DOM Inter-App Communication API.
|
||||
pref("dom.inter-app-communication-api.enabled", false);
|
||||
|
||||
// Disable mapped array buffer by default.
|
||||
pref("dom.mapped_arraybuffer.enabled", false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user