Open Bug 661043 Opened 14 years ago Updated 2 years ago

Testing frame work should handle event listener in itself

Categories

(Testing :: Mochitest, defect)

defect

Tracking

(Not tracked)

People

(Reporter: hiro, Unassigned)

Details

Attachments

(1 file)

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.
Attached patch Proposed patchSplinter Review
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
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: