mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 802564 - Can't set window.location in inline disposition web activity when its App frame is opened. r=fabrice
1. SystemMessageInternal: Handle the "_listeners" correctly by using "manifest" and "winID" 2. SystemMessageManager: Remove cpmm message listerners when receiving "inner-window-destroyed"; Add winID for the reg/unreg message. 3. DOMRequestIpcHelper: Check aTopic in observe method
This commit is contained in:
parent
d2e9fb6a55
commit
7fbd972549
@ -52,6 +52,10 @@ DOMRequestIpcHelper.prototype = {
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic !== "inner-window-destroyed") {
|
||||
return;
|
||||
}
|
||||
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == this.innerWindowID) {
|
||||
Services.obs.removeObserver(this, "inner-window-destroyed");
|
||||
|
@ -32,6 +32,7 @@ try {
|
||||
const kMessages =["SystemMessageManager:GetPendingMessages",
|
||||
"SystemMessageManager:HasPendingMessages",
|
||||
"SystemMessageManager:Register",
|
||||
"SystemMessageManager:Unregister",
|
||||
"SystemMessageManager:Message:Return:OK",
|
||||
"SystemMessageManager:AskReadyToRegister",
|
||||
"child-process-shutdown"]
|
||||
@ -81,14 +82,15 @@ SystemMessageInternal.prototype = {
|
||||
debug("Sending " + aType + " " + JSON.stringify(aMessage) +
|
||||
" for " + aPageURI.spec + " @ " + aManifestURI.spec);
|
||||
if (this._listeners[aManifestURI.spec]) {
|
||||
this._listeners[aManifestURI.spec].forEach(function sendMsg(aListener) {
|
||||
aListener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aManifestURI.spec,
|
||||
uri: aPageURI.spec,
|
||||
msgID: messageID })
|
||||
});
|
||||
let manifest = this._listeners[aManifestURI.spec];
|
||||
for (let winID in manifest) {
|
||||
manifest[winID].sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aManifestURI.spec,
|
||||
uri: aPageURI.spec,
|
||||
msgID: messageID });
|
||||
}
|
||||
}
|
||||
|
||||
let pagesToOpen = {};
|
||||
@ -130,14 +132,15 @@ SystemMessageInternal.prototype = {
|
||||
this._pages.forEach(function(aPage) {
|
||||
if (aPage.type == aType) {
|
||||
if (this._listeners[aPage.manifest]) {
|
||||
this._listeners[aPage.manifest].forEach(function sendMsg(aListener) {
|
||||
aListener.sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aPage.manifest,
|
||||
uri: aPage.uri,
|
||||
msgID: messageID })
|
||||
});
|
||||
let manifest = this._listeners[aPage.manifest];
|
||||
for (let winID in manifest) {
|
||||
manifest[winID].sendAsyncMessage("SystemMessageManager:Message",
|
||||
{ type: aType,
|
||||
msg: aMessage,
|
||||
manifest: aPage.manifest,
|
||||
uri: aPage.uri,
|
||||
msgID: messageID });
|
||||
}
|
||||
}
|
||||
// Queue this message in the corresponding pages.
|
||||
this._queueMessage(aPage, aMessage, messageID);
|
||||
@ -172,29 +175,36 @@ SystemMessageInternal.prototype = {
|
||||
break;
|
||||
case "SystemMessageManager:Register":
|
||||
{
|
||||
let manifest = msg.manifest;
|
||||
debug("Got Register from " + manifest);
|
||||
if (!this._listeners[manifest]) {
|
||||
this._listeners[manifest] = [];
|
||||
debug("Got Register from " + msg.manifest);
|
||||
if (!this._listeners[msg.manifest]) {
|
||||
this._listeners[msg.manifest] = {};
|
||||
}
|
||||
this._listeners[manifest].push(aMessage.target);
|
||||
debug("listeners for " + manifest + " : " + this._listeners[manifest].length);
|
||||
this._listeners[msg.manifest][msg.innerWindowID] = aMessage.target;
|
||||
debug("listeners for " + msg.manifest + " innerWinID " + msg.innerWindowID);
|
||||
break;
|
||||
}
|
||||
case "child-process-shutdown":
|
||||
{
|
||||
debug("Got Unregister from " + aMessage.target);
|
||||
let mm = aMessage.target;
|
||||
debug("Got child-process-shutdown from " + aMessage.target);
|
||||
for (let manifest in this._listeners) {
|
||||
let index = this._listeners[manifest].indexOf(mm);
|
||||
while (index != -1) {
|
||||
debug("Removing " + mm + " at index " + index);
|
||||
this._listeners[manifest].splice(index, 1);
|
||||
index = this._listeners[manifest].indexOf(mm);
|
||||
for (let winID in this._listeners[manifest]) {
|
||||
if (aMessage.target === this._listeners[manifest][winID]) {
|
||||
debug("remove " + manifest );
|
||||
delete this._listeners[manifest];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "SystemMessageManager:Unregister":
|
||||
{
|
||||
debug("Got Unregister from " + aMessage.target + "innerWinID " + msg.innerWindowID);
|
||||
delete this._listeners[msg.manifest][msg.innerWindowID];
|
||||
debug("Removing " + aMessage.target + "innerWinID " + msg.innerWindowID );
|
||||
|
||||
break;
|
||||
}
|
||||
case "SystemMessageManager:GetPendingMessages":
|
||||
{
|
||||
debug("received SystemMessageManager:GetPendingMessages " + msg.type +
|
||||
|
@ -124,6 +124,11 @@ SystemMessageManager.prototype = {
|
||||
if (this._isParentProcess) {
|
||||
Services.obs.removeObserver(this, kSystemMessageInternalReady);
|
||||
}
|
||||
|
||||
cpmm.sendAsyncMessage("SystemMessageManager:Unregister",
|
||||
{ manifest: this._manifest,
|
||||
innerWindowID: this.innerWindowID
|
||||
});
|
||||
},
|
||||
|
||||
receiveMessage: function sysMessMgr_receiveMessage(aMessage) {
|
||||
@ -174,7 +179,6 @@ SystemMessageManager.prototype = {
|
||||
let appsService = Cc["@mozilla.org/AppsService;1"]
|
||||
.getService(Ci.nsIAppsService);
|
||||
this._manifest = appsService.getManifestURLByLocalId(principal.appId);
|
||||
this._window = aWindow;
|
||||
|
||||
// Two cases are valid to register the manifest for the current process:
|
||||
// 1. This is asked by a child process (parent process must be ready).
|
||||
@ -199,12 +203,16 @@ SystemMessageManager.prototype = {
|
||||
if (aTopic === kSystemMessageInternalReady) {
|
||||
this._registerManifest();
|
||||
}
|
||||
//call the DOMRequestIpcHelper.observe method
|
||||
this.__proto__.__proto__.observe.call(this, aSubject, aTopic, aData);
|
||||
},
|
||||
|
||||
_registerManifest: function sysMessMgr_registerManifest() {
|
||||
if (!this._registerManifestReady) {
|
||||
cpmm.sendAsyncMessage("SystemMessageManager:Register",
|
||||
{ manifest: this._manifest });
|
||||
{ manifest: this._manifest,
|
||||
innerWindowID: this.innerWindowID
|
||||
});
|
||||
this._registerManifestReady = true;
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user