Closed Bug 875694 Opened 11 years ago Closed 11 years ago

System Message API: the listeners should be indexed by [manifestURL + pageURL]

Categories

(Core :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: airpingu, Unassigned)

References

Details

In SystemMessageInternal.js, the current ._listners[aManifestURI] mechanism is indexed by the manifest URL only. I suggest we should make it indexed by (manifest URL + page URL) when registering the target, because one [manifest URL + page URL] must be equivalent to *one* target (i.e. one SystemMessageManager). I mean, only *one* target is going to be delivered with the system message, since the system message's target [manifest URL + page URL] is always unique in any way. If my assumption is yes, then we don't need the |targets| loop and the page URL check as shown as the following code segment. We should just focus on that unique target to send our system message.

let targets = this._listeners[aManifestURI];
if (targets) {
  for (let index = 0; index < targets.length; ++index) {
     let target = targets[index];
     // We only need to send the system message to the targets which match
     // the manifest URL and page URL of the destination of system message.
     if (target.uri != aPageURI) {
       continue;
     }
     ...
     let manager = target.target;
     manager.sendAsyncMessage("SystemMessageManager:Message", ...);
  }
}

Looping some people who used to modify the codes here.
(In reply to Gene Lian [:gene] from comment #0)
> In SystemMessageInternal.js, the current ._listners[aManifestURI] mechanism
> is indexed by the manifest URL only. I suggest we should make it indexed by
> (manifest URL + page URL) when registering the target, because one [manifest
> URL + page URL] must be equivalent to *one* target (i.e. one
> SystemMessageManager).

This assumption is wrong. Multiple window pages can share the same target (see bug 878395).
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.