Closed Bug 1642685 Opened 4 years ago Closed 4 years ago

WeakRef and FinalizationRegistry should preserve DOM wrappers

Categories

(Core :: JavaScript: GC, defect)

defect

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(2 files)

As pointed out by smaug:

does use of WeakRef force preserving wrappers?
since if not, what happens if one does:
  document.body.appendChild(document.createElement("div")); 
  var w = new WeakRef(document.body.lastChild);
document.body.lastChild certainly stays alive there, but its wrapper may die
when GC runs

A user may observe that the wrapper to the DOM object dies, even though the DOM object itself is still alive.

The same issue applies to objects registered with FinalizationRegistry. The solution is to preserve DOM wrappers in this case, the same as we do for WeakMap keys.

Blocks: 1639246
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7d6899087a54 WeakRef and FinalizationRegistry should preserve DOM wrappers r=sfink https://hg.mozilla.org/integration/autoland/rev/8b90826d7abe Add WeakRef and FinalizationRegistry tests involving DOM objects r=smaug
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Regressions: 1643676
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: