Closed Bug 609139 Opened 14 years ago Closed 14 years ago

QueryInterfaced objects forget some interfaces when they cross compartments

Categories

(Core :: XPConnect, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- beta8+

People

(Reporter: Mardak, Assigned: mrbkap)

References

Details

(Keywords: regression)

Attachments

(1 file)

If I do the following from the error console, it correctly reports nsPIPlacesDatabase:

const {utils: Cu} = Components;
Cu.import("resource://services-sync/util.js");
Cu.reportError(Svc.History);

[xpconnect wrapped (nsISupports, nsINavHistoryService, nsIGlobalHistory3, nsIGlobalHistory2, nsIDownloadHistory, nsIBrowserHistory, nsPIPlacesDatabase)]

However, if I do that from a restartless add-on, it doesn't have nsPIPlacesDatabase without first QIing it:

const {interfaces: Ci, utils: Cu} = Components;

function startup() {
  Cu.import("resource://services-sync/util.js");
  Cu.reportError(Svc.History);
  Cu.reportError(Svc.History.QueryInterface(Ci.nsPIPlacesDatabase));
  Cu.reportError(Svc.History);
}

[xpconnect wrapped (nsISupports, nsINavHistoryService, nsIGlobalHistory3, nsIGlobalHistory2, nsIDownloadHistory, nsIBrowserHistory)]
[xpconnect wrapped (nsISupports, nsINavHistoryService, nsIGlobalHistory3, nsIGlobalHistory2, nsIDownloadHistory, nsIBrowserHistory, nsPIPlacesDatabase)]
[xpconnect wrapped (nsISupports, nsINavHistoryService, nsIGlobalHistory3, nsIGlobalHistory2, nsIDownloadHistory, nsIBrowserHistory, nsPIPlacesDatabase)]
Testing without the restartless addon:

var {classes: Cc, interfaces: Ci, utils: Cu} = Components; expr = "Components.utils.import('resource://services-sync/util.js'); Svc.History"; [Cu.evalInSandbox(expr, Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal))).toString(), eval(expr)].join("\n")
This won't be fixed for beta7. The problem is that we have some code to rewrap wrapped natives as they cross compartment boundaries, and two wrapped natives for the same native object don't necessarily share the same interface list. The proper way to fix this is to merge the two wrapped natives' sets when we rewrap.
blocking2.0: --- → ?
blocking2.0: ? → beta8+
Summary: QueryInterfaced objects forget some interfaces in restartless add-ons → QueryInterfaced objects forget some interfaces when they cross compartments
Rather than do the "merge", this just uses the passed-in wrapped native's sets in more cases. This could have unexpected behavior if the wrapped native on the other side of the conversion here was QI'd to a different set of interfaces, but I hope that would be a pretty rare case.
Assignee: nobody → mrbkap
Status: NEW → ASSIGNED
Attachment #489070 - Flags: review?(jst)
Attachment #489070 - Flags: review?(jst) → review+
http://hg.mozilla.org/mozilla-central/rev/43781a14501d
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: