Closed
Bug 829239
Opened 12 years ago
Closed 6 years ago
Support WebIDL objects that are both non-nsISupports and cycle-collected as weak map keys
Categories
(Core :: DOM: Core & HTML, defect, P5)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
DUPLICATE
of bug 1351501
People
(Reporter: mccr8, Unassigned)
Details
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.
Comment 1•12 years ago
|
||
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.
Reporter | ||
Comment 2•11 years ago
|
||
This is going to be a bigger problem now, as many WebGL classes are being converted away from nsISupports.
Comment 3•10 years ago
|
||
Is the following TypeError related to this bug? In Chrome code:
```
var wm = new WeakMap();
// messageManager is a "ChromeMessageSender" instance
var mm = gBrowser.tabs[0].linkedBrowser.messageManager;
wm.set(mm, "whatever");
// TypeError: cannot use the given object as a weak map key
```
Comment 4•10 years ago
|
||
If it helps, the __proto__ for messageManager is "XPC_WN_ModsAllowed_NoCall_Proto_JSClass"
Reporter | ||
Comment 5•10 years ago
|
||
(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
Reporter | ||
Updated•10 years ago
|
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
![]() |
||
Comment 6•10 years ago
|
||
The answer to comment 3 is to convert message manager to webidl. Which we need to do anyway.
Reporter | ||
Comment 7•10 years ago
|
||
(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.
Comment 8•10 years ago
|
||
Thanks for the clarifications+pointers.
Comment 9•7 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046
Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.
If you have questions, please contact :mdaly.
Priority: -- → P5
Reporter | ||
Comment 10•6 years ago
|
||
Oops, looks like I filed an even older bug about this. Oh well. The newer bug has some discussion so I'll dupe this.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•