Closed Bug 1493237 Opened Last year Closed Last year

Add and use test-only WebIDL classes for WeakMap key tests

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

Details

Attachments

(1 file)

Support for WebIDL objects as weak map keys uses wrapper preservation, so there are a bunch of cases depending on whether something is nsISupports or not, and wrapper cached or not. Right now, these tests mostly use existing standard classes, but that is bad because it relies on things that may change without anybody noticing, or if somebody does notice, they have to do some additional work to find another similar class.

This can be avoided by defining some debug-only WebIDL classes and using those in the test. These classes need a way to be created and, for wrapper cached classes, somehow store an instance of the class in a C++ object in a way that can be re-gotten from JS.

This might also be a good excuse to convert these tests from Mochitest Chrome tests to regular mochitests. The high privilege things these tests do are call GC/CC and call nondeterministicGetWeakMapKeys, so that should not be hard to do.

The lists of tests (that include "weakmap" in the name at least) are:
  js/xpconnect/tests/chrome/test_getweakmapkeys.xul
  js/xpconnect/tests/chrome/test_paris_weakmap_keys.xul
  js/xpconnect/tests/chrome/test_weakmap_keys_preserved.xul
  js/xpconnect/tests/chrome/test_weakmap_keys_preserved2.xul
  js/xpconnect/tests/chrome/test_weakmaps.xul
A more complete lists of XPConnect tests that should be looked at is the list of tests that contain the string "weakmap":

https://searchfox.org/mozilla-central/search?q=WeakMap&case=false&regexp=false&path=js%2Fxpconnect%2Ftests%2F
Priority: -- → P2
Depends on: 1497342
I'm just going to focus on the immediate issue here so I don't sink into a backlog of test cleanups.

I've updated the test. I verified that the key is dropped from the map if TryPreserveWrapper doesn't preserve the wrapper for a non-nsISupports object, and that you can't set the key in the first place if it returns false.
Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a19bd92250b6
Use a test-only non-nsISupports wrapper cached WebIDL class in a weak map test r=bzbarsky
https://hg.mozilla.org/mozilla-central/rev/a19bd92250b6
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.