Open Bug 1746935 Opened 4 years ago

Add tests to ensure that listeners keep alive MIDI port & access objects

Categories

(Core :: DOM: Device Interfaces, task)

task

Tracking

()

People

(Reporter: gsvelto, Unassigned)

References

Details

It should be possible to test this like so (using a browser mochitest):

  1. Browse to a page that creates the objects
  2. Request access and accept the permission prompt
  3. Get the test input and output ports (specifically MIDITestUtils.inputInfo and MIDITestUtils.outputInfo)
  4. Set statechange listeners on all the objects
  5. Register all the objects using the FinalizationRegistry. For each object we'll have a callback that checks a global flag. If the flag is true then the object should have been collected and the test passes, if it's false then the test fails.
  6. Set the aforementioned global flag to false
  7. Force a GC with SpecialPowers.exactGC()
  8. Without the change in bug 1745443 this would cause the callbacks set in step 5 to fail
  9. Now set the global flag to true
  10. Browse away from the page (and maybe call SpecialPowers.exactGC() again)
  11. The objects should now be collected, the callback in the FinalizationRegistry will all be called and the test should finish
You need to log in before you can comment on or make changes to this bug.