The trick here is figuring out whether they are wrapper cached or not. One solution would be to add a flag on the class info that indicates whether they are or not. See discussion in bug 777385 and bug 825053. This will require modifying TryPreserveWrapper. Assuming we cover all cases, then TryPreserveWrapper can be made infallible and renamed to PreserveWrapper.
We could add a hook to the DOMClass for preserving a wrapper, set it to null if the wrapper can't be preserved, generate it for non-nsISupports and have a generic one for nsISupports. Xrays also need to preserve, and they currently bail for non-nsISupports.
This is going to be a bigger problem now, as many WebGL classes are being converted away from nsISupports.
Is the following TypeError related to this bug? In Chrome code: ``` var wm = new WeakMap(); // messageManager is a "ChromeMessageSender" instance var mm = gBrowser.tabs.linkedBrowser.messageManager; wm.set(mm, "whatever"); // TypeError: cannot use the given object as a weak map key ```
If it helps, the __proto__ for messageManager is "XPC_WN_ModsAllowed_NoCall_Proto_JSClass"
(In reply to Marcos Caceres [:marcosc] from comment #3) > Is the following TypeError related to this bug? In Chrome code: I think it isn't the same. It looks like ChromeMessageSender is implemented by nsFrameMessageManager, which is ISupports. I think the issue is that we don't support non-WebIDL things as weak map keys. The relevant line is PreserveWrapper in XPCJSRuntime.cpp: return mozilla::dom::IsDOMObject(obj) && mozilla::dom::TryPreserveWrapper(obj); We did used to support nsINode, but I think that was removed after node was converted to WebIDL: http://hg.mozilla.org/mozilla-central/diff/d7553251cf43/js/xpconnect/src/XPCJSRuntime.cpp
Summary: Support Paris bindings objects that are both non-nsISupports and cycle-collected as weak maps keys → Support WebIDL objects that are both non-nsISupports and cycle-collected as weak map keys
The answer to comment 3 is to convert message manager to webidl. Which we need to do anyway.
(In reply to Not doing reviews right now from comment #6) > The answer to comment 3 is to convert message manager to webidl. Which we > need to do anyway. Yeah. That's bug 888600.
Thanks for the clarifications+pointers.
You need to log in before you can comment on or make changes to this bug.