Closed Bug 1655422 Opened 6 years ago Closed 1 month ago

Remove exceptions added by allowMatchingRejectionsGlobally after each test

Categories

(Testing :: Mochitest, task, P3)

Default
task

Tracking

(firefox154 fixed)

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

Details

Attachments

(1 file, 1 obsolete file)

The helper allowMatchingRejectionsGlobally allows to ignore promise rejections matching a given regexp:

  allowMatchingRejectionsGlobally(regExp) {
    this._globalRejectionIgnoreFns.push(rejection =>
      regExp.test(rejection.message)
    );
  },

https://searchfox.org/mozilla-central/rev/cf561cece0ca9aeaf0202e68699836d957d0c670/toolkit/modules/tests/modules/PromiseTestUtils.jsm#223

However, _globalRejectionIgnoreFns is never emptied. This means that if any test calls allowMatchingRejectionsGlobally, all the subsequent tests in the suite will be impacted. This means also some tests can fail in isolation, but succeed in a suite (example: Bug 1655411).

I don't know if we should modify the behavior, or just add an API to cleanup the array so that individual tests can cleanup the state on demand.

See Also: → 1655411

CC'ing Joel in case it's something we want to see fixed. It will also affect some Remote Agent mochitests soon, and a workaround would be to put these specific files into their own manifest file.

(In reply to Julian Descottes [:jdescottes] from comment #0)

I don't know if we should modify the behavior, or just add an API to cleanup the array so that individual tests can cleanup the state on demand.

I will do the latter, seems safer than impacting all the tests currently using this. Consumers which care about cleaning up the state can call the API in registerCleanupFunction.

Summary: List for allowMatchingRejectionsGlobally is never emptied → Add an API to remove exceptions added via allowMatchingRejectionsGlobally
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Priority: -- → P3
Attachment #9604178 - Attachment description: Bug 1655422 - Add an API to remove exceptions added via allowMatchingRejectionsGlobally → Bug 1655422 - Add parameter to allowMatchingRejectionsGlobally to self cleanup after the test
Attachment #9604178 - Attachment description: Bug 1655422 - Add parameter to allowMatchingRejectionsGlobally to self cleanup after the test → Bug 1655422 - Remove exceptions from allowMatchingRejectionsGlobally after each test
Blocks: 2053685
Summary: Add an API to remove exceptions added via allowMatchingRejectionsGlobally → Remove exceptions added by allowMatchingRejectionsGlobally after each test
Attachment #9605992 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: