Filter state not reset when filter is removed and added back
Environment
If we remove a filter, then add it back, its state isn't reset. This is a problem if the filter was disabled, because when it is added back, it remain disabled.
See https://gitlab.com/eyeo/webext/webext-sdk/-/issues/122
How to reproduce
- Add a filter to the storage
- Disable the filter
- Remove the filter to the storage
- Add the filter back.
Observed behavior
Filter.disabled is true
Expected behavior
Filter.disabled should return false. Also hitCount should be 0
This is a bug and regression. Before filterState the state was stored within the filter object, thus when the filter was removed, it disappeared. This is what was missed in the transition.
What to change
- In
lib/filterStorage.js, in removeFilter, remove the filter from the filter state on removal from the storage - In
test/filterStorage.js, add test for this.
Hint for tester
- after removing a filter, and adding it back, the state (hit count, disabled) should be reset to (0, false).
Edited by Hubert Figuière