Testing frame work should handle event listener in itself

NEW
Unassigned

Status

defect
8 years ago
2 years ago

People

(Reporter: hiro, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

For example, many tests have codes like this:

window.addEventListener("needThisEvent", function(event) {
  window.removeEventListener("needThisEvent", arguments.callee, false);
  ...
}, false);

But this listener is not removed when the test is timed out.

So we currently have to do something like this:

var listener = function(event) {
 ..
}
registerCleanupFunction(function() {
  window.removeEventListener("needThisEvent", listener, false);
});
window.addEventListener("needThisEvent", listener, false);

But this code is a little bit inconvenient to write, many test codes does actually not use registerCleanupFunction for removal of event listener.

So I'd propose more convenient way and testing frame work does remove event listener even if the test is timed out.
Add registerEventListener and unregisterEventListener.
Group: core-security
Bug 454717 is related.

IIRC removeEventListener can't throw, so I don't think you need the try/catch.

A unregisterListener(listeningObject) method would allow sharing some code.
Component: BrowserTest → Mochitest
You need to log in before you can comment on or make changes to this bug.