зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1026072 - this.getContextForMM(...).RP is undefined. r=MattN
This commit is contained in:
Родитель
2cd40ad8a5
Коммит
9687f01760
|
@ -4,7 +4,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
const {classes: Cc,
|
||||
interfaces: Ci,
|
||||
utils: Cu,
|
||||
results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
@ -18,12 +21,14 @@ this.EXPORTED_SYMBOLS = ["DOMIdentity"];
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "objectCopy",
|
||||
"resource://gre/modules/identity/IdentityUtils.jsm");
|
||||
|
||||
/* jshint ignore:start */
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "IdentityService",
|
||||
#ifdef MOZ_B2G_VERSION
|
||||
"resource://gre/modules/identity/MinimalIdentity.jsm");
|
||||
#else
|
||||
"resource://gre/modules/identity/Identity.jsm");
|
||||
#endif
|
||||
/* jshint ignore:end */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FirefoxAccounts",
|
||||
"resource://gre/modules/identity/FirefoxAccounts.jsm");
|
||||
|
@ -51,6 +56,23 @@ function IDDOMMessage(aOptions) {
|
|||
objectCopy(aOptions, this);
|
||||
}
|
||||
|
||||
function _sendAsyncMessage(identifier, message) {
|
||||
if (this._mm) {
|
||||
try {
|
||||
this._mm.sendAsyncMessage(identifier, message);
|
||||
} catch(err) {
|
||||
// We may receive a NS_ERROR_NOT_INITIALIZED if the target window has
|
||||
// been closed. This can legitimately happen if an app has been killed
|
||||
// while we are in the midst of a sign-in flow.
|
||||
if (err.result == Cr.NS_ERROR_NOT_INITIALIZED) {
|
||||
log("Cannot sendAsyncMessage because the recipient frame has closed");
|
||||
return;
|
||||
}
|
||||
log("ERROR: sendAsyncMessage: " + err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function IDPProvisioningContext(aID, aOrigin, aTargetMM) {
|
||||
this._id = aID;
|
||||
this._origin = aOrigin;
|
||||
|
@ -61,19 +83,21 @@ IDPProvisioningContext.prototype = {
|
|||
get id() this._id,
|
||||
get origin() this._origin,
|
||||
|
||||
sendAsyncMessage: _sendAsyncMessage,
|
||||
|
||||
doBeginProvisioningCallback: function IDPPC_doBeginProvCB(aID, aCertDuration) {
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
message.identity = aID;
|
||||
message.certDuration = aCertDuration;
|
||||
this._mm.sendAsyncMessage("Identity:IDP:CallBeginProvisioningCallback",
|
||||
message);
|
||||
this.sendAsyncMessage("Identity:IDP:CallBeginProvisioningCallback",
|
||||
message);
|
||||
},
|
||||
|
||||
doGenKeyPairCallback: function IDPPC_doGenKeyPairCallback(aPublicKey) {
|
||||
log("doGenKeyPairCallback");
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
message.publicKey = aPublicKey;
|
||||
this._mm.sendAsyncMessage("Identity:IDP:CallGenKeyPairCallback", message);
|
||||
this.sendAsyncMessage("Identity:IDP:CallGenKeyPairCallback", message);
|
||||
},
|
||||
|
||||
doError: function(msg) {
|
||||
|
@ -91,11 +115,13 @@ IDPAuthenticationContext.prototype = {
|
|||
get id() this._id,
|
||||
get origin() this._origin,
|
||||
|
||||
sendAsyncMessage: _sendAsyncMessage,
|
||||
|
||||
doBeginAuthenticationCallback: function IDPAC_doBeginAuthCB(aIdentity) {
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
message.identity = aIdentity;
|
||||
this._mm.sendAsyncMessage("Identity:IDP:CallBeginAuthenticationCallback",
|
||||
message);
|
||||
this.sendAsyncMessage("Identity:IDP:CallBeginAuthenticationCallback",
|
||||
message);
|
||||
},
|
||||
|
||||
doError: function IDPAC_doError(msg) {
|
||||
|
@ -123,37 +149,39 @@ function RPWatchContext(aOptions, aTargetMM, aPrincipal) {
|
|||
}
|
||||
|
||||
RPWatchContext.prototype = {
|
||||
sendAsyncMessage: _sendAsyncMessage,
|
||||
|
||||
doLogin: function RPWatchContext_onlogin(aAssertion, aMaybeInternalParams) {
|
||||
log("doLogin: " + this.id);
|
||||
let message = new IDDOMMessage({id: this.id, assertion: aAssertion});
|
||||
if (aMaybeInternalParams) {
|
||||
message._internalParams = aMaybeInternalParams;
|
||||
}
|
||||
this._mm.sendAsyncMessage("Identity:RP:Watch:OnLogin", message);
|
||||
this.sendAsyncMessage("Identity:RP:Watch:OnLogin", message);
|
||||
},
|
||||
|
||||
doLogout: function RPWatchContext_onlogout() {
|
||||
log("doLogout: " + this.id);
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
this._mm.sendAsyncMessage("Identity:RP:Watch:OnLogout", message);
|
||||
this.sendAsyncMessage("Identity:RP:Watch:OnLogout", message);
|
||||
},
|
||||
|
||||
doReady: function RPWatchContext_onready() {
|
||||
log("doReady: " + this.id);
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
this._mm.sendAsyncMessage("Identity:RP:Watch:OnReady", message);
|
||||
this.sendAsyncMessage("Identity:RP:Watch:OnReady", message);
|
||||
},
|
||||
|
||||
doCancel: function RPWatchContext_oncancel() {
|
||||
log("doCancel: " + this.id);
|
||||
let message = new IDDOMMessage({id: this.id});
|
||||
this._mm.sendAsyncMessage("Identity:RP:Watch:OnCancel", message);
|
||||
this.sendAsyncMessage("Identity:RP:Watch:OnCancel", message);
|
||||
},
|
||||
|
||||
doError: function RPWatchContext_onerror(aMessage) {
|
||||
log("doError: " + this.id + ": " + JSON.stringify(aMessage));
|
||||
let message = new IDDOMMessage({id: this.id, message: aMessage});
|
||||
this._mm.sendAsyncMessage("Identity:RP:Watch:OnError", message);
|
||||
this.sendAsyncMessage("Identity:RP:Watch:OnError", message);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,7 +235,8 @@ this.DOMIdentity = {
|
|||
*/
|
||||
getService: function(message) {
|
||||
if (!this._serviceContexts.has(message.id)) {
|
||||
throw new Error("getService called before newContext for " + message.id);
|
||||
log("ERROR: getService called before newContext for " + message.id);
|
||||
return null;
|
||||
}
|
||||
|
||||
let context = this._serviceContexts.get(message.id);
|
||||
|
@ -348,7 +377,9 @@ this.DOMIdentity = {
|
|||
},
|
||||
|
||||
_subscribeListeners: function DOMIdentity__subscribeListeners() {
|
||||
if (!ppmm) return;
|
||||
if (!ppmm) {
|
||||
return;
|
||||
}
|
||||
for (let message of this.messages) {
|
||||
ppmm.addMessageListener(message, this);
|
||||
}
|
||||
|
@ -373,20 +404,31 @@ this.DOMIdentity = {
|
|||
// not have the right callbacks, we don't want unwatch to throw, because it
|
||||
// will break the process of releasing the page's resources and leak
|
||||
// memory.
|
||||
try {
|
||||
this.getService(message).RP.unwatch(message.id, targetMM);
|
||||
} catch(ex) {
|
||||
log("ERROR: can't unwatch " + message.id + ": " + ex);
|
||||
let service = this.getService(message);
|
||||
if (service && service.RP) {
|
||||
service.RP.unwatch(message.id, targetMM);
|
||||
this.deleteContextForMM(targetMM);
|
||||
return;
|
||||
}
|
||||
log("Can't find a service to unwatch() for " + message.id);
|
||||
},
|
||||
|
||||
_request: function DOMIdentity__request(message) {
|
||||
this.getService(message).RP.request(message.id, message);
|
||||
let service = this.getService(message);
|
||||
if (service && service.RP) {
|
||||
service.RP.request(message.id, message);
|
||||
return;
|
||||
}
|
||||
log("No context in which to call request(); Did you call watch() first?");
|
||||
},
|
||||
|
||||
_logout: function DOMIdentity__logout(message) {
|
||||
log("logout " + message + "\n");
|
||||
this.getService(message).RP.logout(message.id, message.origin, message);
|
||||
let service = this.getService(message);
|
||||
if (service && service.RP) {
|
||||
service.RP.logout(message.id, message.origin, message);
|
||||
return;
|
||||
}
|
||||
log("No context in which to call logout(); Did you call watch() first?");
|
||||
},
|
||||
|
||||
_childProcessShutdown: function DOMIdentity__childProcessShutdown(targetMM) {
|
||||
|
@ -394,7 +436,11 @@ this.DOMIdentity = {
|
|||
return;
|
||||
}
|
||||
|
||||
this.getContextForMM(targetMM).RP.childProcessShutdown(targetMM);
|
||||
let service = this.getContextForMM(targetMM);
|
||||
if (service && service.RP) {
|
||||
service.RP.childProcessShutdown(targetMM);
|
||||
}
|
||||
|
||||
this.deleteContextForMM(targetMM);
|
||||
|
||||
let options = makeMessageObject({messageManager: targetMM, id: null, origin: null});
|
||||
|
|
Загрузка…
Ссылка в новой задаче